Giter Club home page Giter Club logo

reel's Introduction

Reel

Build Status

Reel is a fast, non-blocking "evented" web server built on http_parser.rb, websocket_parser, Celluloid::IO, and nio4r. Thanks to Celluloid, Reel also works great for multithreaded applications and provides traditional multithreaded blocking I/O support too.

Connections to Reel can be either non-blocking and handled entirely within the Reel::Server thread, or the same connections can be dispatched to worker threads where they will perform ordinary blocking IO. Reel provides no built-in thread pool, however you can build one yourself using Celluloid.pool, or because Celluloid already pools threads to begin with, you can simply use an actor per connection.

This gives you the best of both worlds: non-blocking I/O for when you're primarily I/O bound, and threads for where you're compute bound.

Is it any good?

Yes

Here's a "hello world" web server benchmark, run on a 2GHz i7 (OS X 10.7.3). All servers used in a single-threaded mode.

Reel performance on various Ruby VMs:

# httperf --num-conns=50 --num-calls=1000

Ruby Version        Throughput    Latency
------------        ----------    -------
JRuby HEAD          5650 reqs/s   (0.2 ms/req)
Ruby 1.9.3          5263 reqs/s   (0.2 ms/req)
JRuby 1.6.7         4303 reqs/s   (0.2 ms/req)
rbx HEAD            2288 reqs/s   (0.4 ms/req)

Comparison with other web servers:

Web Server          Throughput    Latency
----------          ----------    -------
Goliath (0.9.4)     2058 reqs/s   (0.5 ms/req)
Thin    (1.2.11)    7502 reqs/s   (0.1 ms/req)
Node.js (0.6.5)     11735 reqs/s  (0.1 ms/req)

All Ruby benchmarks done on Ruby 1.9.3. Latencies given are average-per-request and are not amortized across all concurrent requests.

Usage

Reel provides an extremely simple API:

require 'reel'

Reel::Server.supervise("0.0.0.0", 3000) do |connection|
  while request = connection.request
    case request
    when Reel::Request
      puts "Client requested: #{request.method} #{request.url}"
      connection.respond :ok, "hello, world"
    when Reel::WebSocket
      puts "Client made a WebSocket request to: #{request.url}"
      request << "Hello there"
      connection.close
      break
    end
  end
end

When we read a request from the incoming connection, we'll either get back a Reel::Request object, indicating a normal HTTP connection, or a Reel::WebSocket object for WebSockets connections.

Status

Reel is still in an extremely early stage of development and may be missing a lot of features. It seems to be doing a rudimentary job of speaking HTTP and has basic keep-alive support.

Contributing

  • Fork this repository on github
  • Make your changes and send me a pull request
  • If I like them I'll merge them
  • If I've accepted a patch, feel free to ask for commit access

License

Copyright (c) 2012 Tony Arcieri. Distributed under the MIT License. See LICENSE.txt for further details.

reel's People

Contributors

afcapel avatar collin avatar danielsz avatar grantr avatar seancribbs avatar sebastianedwards avatar shtirlic avatar splattael avatar tarcieri avatar

Watchers

 avatar  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.