Add rb_thread_schedule() and threaded_processing option
[ebb.git] / README
blob551caf065c7cbac3aa2230facdab7b4f3cea99a5
1 # A Web Server Called *Ebb*
3 Ebb aims to be a small and fast web server specifically for hosting 
4 web frameworks like Rails, Merb, and in the future Django.
6 It is not meant to be a full featured web server like Lighttpd, Apache, or
7 Nginx. Rather it should be used in multiplicity behind a 
8 [load balancer](http://brainspl.at/articles/2007/11/09/a-fair-proxy-balancer-for-nginx-and-mongrel) 
9 and a front-end server. It is not meant to serve static files in production.
11 ## Design
13 The design is similar to the [Evented
14 Mongrel](http://swiftiply.swiftcore.org/mongrel.html) web server; except
15 instead of using [EventMachine](http://rubyeventmachine.com/) to drive
16 network interactions, the Ebb web server handles sockets directly in C and
17 employs the use of the [libev](http://software.schmorp.de/pkg/libev.html)
18 event loop.
20 Connections are processed as follows:
22 1. libev loops and waits for incoming connections.
24 2. When Ebb receives a connection, it passes the request into the
25    [mongrel state machine](http://mongrel.rubyforge.org/browser/tags/rel_1-0-1/ext/http11/http11_parser.rl) 
26    which securely parses the headers.
28 3. When the request is complete, Ebb passes the information to a user
29    supplied callback.
31 4. The Ruby binding supplying this callback transforms the
32    request into a [Rack](http://rack.rubyforge.org/) compatible `env` hash 
33    and passes it on a Rack adapter.
35 Because Ebb is written mostly in C, other language bindings can be added to
36 make it useful to Non-Ruby frameworks. For example, a Python WSGI interface is
37 forthcoming.
39 ## Install
41 The Ruby binding is available as a Ruby Gem. It can be install by executing
43   `gem install ebb`
45 Ebb depends on having glib2 headers and libraries installed. For example, in
46 Macintosh if one is using Darwin ports then the following should do the trick
47   
48   `port install glib2`
49   
50 Downloads are available at
51 the [RubyForge project page](http://rubyforge.org/frs/?group_id=5640).
53 ## Running
55 Using the executable `ebb_rails` one can start Ebb with a Rails project. Use
56 `ebb_rails -h` to see all of the options but to start one can try
57   
58   `cd my_rails_project/; ebb_rails start`
59   
60 To use Ebb with a different framework you will have to do a small amount of
61 hacking at the moment! :)
63 ## Why?
65 Because by building the server in C one is able to side-step the 
66 limitations on speed of many scripting languages. Inefficiencies are okay
67 for quick and beautiful code, but for production web servers that might handle
68 thousands of requests a second, an attempt should be made to be as efficient
69 as possible in processing connections.
71 Following are some benchmarks. Please take these measurements with a grain of
72 salt. Benchmarks like these are notorious for presenting an inaccurate or
73 highly slanted view of how software performs. These are tests using a very
74 simple Rack applications, not with Ruby-on-Rails. The code for these can be
75 found in the `benchmark` directory.
77 ![Response Size](http://s3.amazonaws.com/four.livejournal/20080227/response_size.png)
79 This shows how the web servers perform with respect to throughput (using a 
80 simple Rack application). Concurrency is at 50 clients.
82 ![Concurrency](http://s3.amazonaws.com/four.livejournal/20080227/concurrency.png)
84 A simple concurrent clients benchmark serving a *hello world* page.
86 ![Uploads](http://s3.amazonaws.com/four.livejournal/20080227/post_size.png)
88 Ebb processes uploads before handing it over to the web application. This 
89 allows Ebb to continue to process other clients while the upload is in 
90 progress. The cliff at 40k here is because Ebb's internal request
91 buffer is set at 40 kilobytes before it writes to file.
93 ## Contributions
95 Contributions (patches, criticism, advice) are very welcome! The source code
96 is hosted at [repo.or.cz](http://repo.or.cz/w/ebb.git) (and also mirrored at
97 [github](http://github.com/ry/ebb/tree/master)). It can be retrieved by
98 executing
100 `git clone http://repo.or.cz/r/ebb.git`
102 I intend to keep the C code base very small, so do email me before writing any
103 large additions. Here are some features that I would like to add:
104 * Streaming responses!
105 * HTTP 1.1 Expect/Continue (RFC 2616, sections 8.2.3 and 10.1.1)
106 * A parser for multipart/form-data
107 * Optimize and clean up upload handling
108 * Option to listen on unix sockets instead of TCP
109 * Python binding
111 ## (The MIT) License
113 Copyright © 2008 [Ry Dahl](http://tinyclouds.org) (ry at tiny clouds dot org)
115 <div id="license">
116 Permission is hereby granted, free of charge, to any person obtaining
117 a copy of this software and associated documentation files (the
118 "Software"), to deal in the Software without restriction, including
119 without limitation the rights to use, copy, modify, merge, publish,
120 distribute, sublicense, and/or sell copies of the Software, and to
121 permit persons to whom the Software is furnished to do so, subject to
122 the following conditions:
124 The above copyright notice and this permission notice shall be
125 included in all copies or substantial portions of the Software.
127 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
128 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
129 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
130 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
131 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
132 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
133 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
134 </div>