site update
[ebb.git] / README
blobbe30985c16945a3117dddcfc7eeaab4f9024dbaf
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
58     cd my_rails_project/; ebb_rails start
60 When using `ebb_rails` from monit, the monitrc entry might look like this:
62     check process myApp4000
63       with pidfile /home/webuser/myApp/current/tmp/ebb.4000.pid
64       start program = "/usr/bin/ruby /usr/bin/ebb_rails start -d -e production -p 4000 -P /home/webuser/myApp/current/tmp/ebb.4000.pid -c /home/webuser/myApp/current" as uid webuser and gid webuser
65       stop program = "/usr/bin/ruby /usr/bin/ebb_rails stop -P /home/webuser/myApp/current/tmp/ebb.4000.pid" as uid webuser and gid webuser
66       if totalmem > 120.0 MB for 2 cycles then restart
67       if loadavg(5min) greater than 10 for 8 cycles then restart
68       group myApp
70 To use Ebb with a different framework you will have to do a small amount of
71 hacking at the moment! :)
73 ## Why?
75 Because by building the server in C one is able to side-step the 
76 limitations on speed of many scripting languages. Inefficiencies are okay
77 for quick and beautiful code, but for production web servers that might handle
78 thousands of requests a second, an attempt should be made to be as efficient
79 as possible in processing connections.
81 Following are some benchmarks. Please take these measurements with a grain of
82 salt. Benchmarks like these are notorious for presenting an inaccurate or
83 highly slanted view of how software performs. These are tests using a very
84 simple Rack applications, not with Ruby-on-Rails. The code for these can be
85 found in the `benchmark` directory.
87 ![Response Size](http://s3.amazonaws.com/four.livejournal/20080227/response_size.png)
89 This shows how the web servers perform with respect to throughput (using a 
90 simple Rack application). Concurrency is at 50 clients.
92 ![Concurrency](http://s3.amazonaws.com/four.livejournal/20080227/concurrency.png)
94 A simple concurrent clients benchmark serving a *hello world* page.
96 ![Uploads](http://s3.amazonaws.com/four.livejournal/20080227/post_size.png)
98 Ebb processes uploads before handing it over to the web application. This 
99 allows Ebb to continue to process other clients while the upload is in 
100 progress. The cliff at 40k here is because Ebb's internal request
101 buffer is set at 40 kilobytes before it writes to file.
103 ## Contributions
105 Contributions (patches, criticism, advice) are very welcome! The source code
106 is hosted [github](http://github.com/ry/ebb/tree/master). It can be retrieved 
107 by executing
109     git clone git://github.com/ry/ebb.git
111 I intend to keep the C code base very small, so do email me before writing any
112 large additions. Here are some features that I would like to add:
113 * HTTP 1.1 Expect/Continue (RFC 2616, sections 8.2.3 and 10.1.1)
114 * A parser for multipart/form-data
115 * Optimize and clean up upload handling
116 * Option to listen on unix sockets instead of TCP
117 * Python binding
119 ## (The MIT) License
121 Copyright © 2008 [Ry Dahl](http://tinyclouds.org) (ry at tiny clouds dot org)
123 <div id="license">
124 Permission is hereby granted, free of charge, to any person obtaining
125 a copy of this software and associated documentation files (the
126 "Software"), to deal in the Software without restriction, including
127 without limitation the rights to use, copy, modify, merge, publish,
128 distribute, sublicense, and/or sell copies of the Software, and to
129 permit persons to whom the Software is furnished to do so, subject to
130 the following conditions:
132 The above copyright notice and this permission notice shall be
133 included in all copies or substantial portions of the Software.
135 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
136 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
137 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
138 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
139 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
140 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
141 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
142 </div>