GithubHelp home page GithubHelp logo

apuratepp / jubilee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isaiah/jubilee

0.0 2.0 0.0 30.42 MB

A rack server built upon vert.x, can be used as a vertx module

Home Page: http://isaiah.github.io/jubilee

License: MIT License

Ruby 49.27% JavaScript 8.60% CSS 0.49% Java 41.63%

jubilee's Introduction

Jubilee / mod-rack

A rack server for jruby.

Also works as vertx module.

Get started

Please checkout the wiki page before you proceed.

Add the following snippet to $VERTX\_HOME/conf/langs.properties

rackup=isaiah~mod-rack~0.1.2:org.jruby.jubilee.JubileeVerticleFactory
.ru=rackup

Make sure JRUBY_HOME is correctly set, and rack gem is install before proceed.

Then run the rackup file as a normal verticle,

vertx run config.ru

Build from source

First checkout the source from github.

  1. To run as a vertx module, run the following command in the root directory:
mvn package
vertx create-module-link org.jruby.jubilee~mod-rack~0.1.3-SNAPSHOT

then change your langs.properties file to point to the new module:

rackup=org.jruby.jubilee~mod-rack~0.1.3-SNAPSHOT:org.jruby.jubilee.JubileeVerticleFactory
  1. To run as rubygem, run rake install in the root directory, maven is required.

Event Bus

Event Bus is a pub/sub mechanism, it can be used from server to server, server to client and client to client, with the same API! You can use it to build living real time web application.

Examples

Assume necessary javascript files are loaded in the page (they can be found here), run rack application with the following config:

$ cat config.json
{ "host": "0.0.0.0",
  "port": 8080,
  "event_bus": "/eventbus"
}
$ vertx run config.ru -conf config.json

In one browser:

var eb = new vertx.EventBus("/eventbus");
eb.registerHandler("test", function(data){
  console.info(data);
});

In another:

var eb = new vertx.EventBus("/eventbus");
eb.send("test", "hello, world");

In the previous tab it should print the greetings you just sent.

For more advanced examples, please checkout the chatapp.

EventBus Security

The EventBus can (and probably should) be secured by passing in parameters in the config.json object.

The following config will allow all messages from the browser to accounts.get_balances and only allow messages outward that match the format accounts.get_balances.*.

$ cat config.json
{ 
  "host": "0.0.0.0",
  "port": 8080,
  "event_bus": "/eventbus",
  "event_bus_security": 
    {
      "incoming": [{address: "user_accounts.get_balances"}],
      "outgoing": [{address_re: "user_accounts.balances.*"}]
    }
}

More details of parameters can be found in the VertX docs

By default the bridge is left wide open. Any browser connected to an application can observe all messages being passed on your EventBus.

Performance Tuning

If you're creating a lot of connections to a Jubilee(Vert.x) server in a short period of time, e.g. benchmarking with tools like wrk, you may need to tweak some settings in order to avoid the TCP accept queue getting full. This can result in connections being refused or packets being dropped during the handshake which can then cause the client to retry.

A classic symptom of this is if you see long connection times just over 3000ms at your client.

How to tune this is operating system specific but in Linux you need to increase a couple of settings in the TCP / Net config (10000 is an arbitrarily large number)

sudo sysctl -w net.core.somaxconn=10000
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=10000

For other operating systems, please consult your operating system documentation.

License

See LICENSE.txt

Acknowledgment

YourKit is kindly supporting Jubilee Server with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.

jubilee's People

Contributors

isaiah avatar litch avatar adamvduke avatar iconara avatar

Watchers

Josep avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.