fixed nasty content-length bug.
[ebb.git] / README
blobea7be1ebecfe11f46150872d7713fc48b4db019e
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 load balancer and a
8 front-end server. It is not meant to serve static files in production.
10 ## Design
12 The design is similar to the [Evented
13 Mongrel](http://swiftiply.swiftcore.org/mongrel.html) web server; except
14 instead of using [EventMachine](http://rubyeventmachine.com/) to drive
15 network interactions, the Ebb web server handles sockets directly in C and
16 employs the use of the [libev](http://software.schmorp.de/pkg/libev.html)
17 event loop.
19 Connections are processed as follows:
21 1. libev loops and waits for incoming connections.
23 2. When Ebb receives a connection, it passes the request into the
24    [mongrel state machine](http://mongrel.rubyforge.org/browser/tags/rel_1-0-1/ext/http11/http11_parser.rl) 
25    which securely parses the headers.
27 3. When the request is complete, Ebb passes the information to a user
28    supplied callback.
30 4. The Ruby binding supplying this callback transforms the
31    request into a [Rack](http://rack.rubyforge.org/) compatible `env` hash 
32    and passes it on a Rack adapter.
34 Because Ebb is written mostly in C, other language bindings can be added to
35 make it useful to Non-Ruby frameworks. For example, a Python WSGI interface is
36 forthcoming.
38 ## Install
40 The Ruby binding is available as a Ruby Gem. It can be install by executing
42     gem install ebb
44 Ebb depends on having glib2 headers and libraries installed. For example, in
45 Macintosh if one is using Darwin ports then the following should do the trick
46   
47     port install glib2
48   
49 Downloads are available at
50 the [RubyForge project page](http://rubyforge.org/frs/?group_id=5640).
52 ## Running
54 Using the executable `ebb_rails` one can start Ebb with a Rails project. Use
55 `ebb_rails -h` to see all of the options but to start one can try
57     cd my_rails_project/
58     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! 
106 All should be posted to http://groups.google.com/group/ebbebb or emailed to me.
108 The source code
109 is hosted [github](http://github.com/ry/ebb/tree/master). It can be retrieved 
110 by executing
112     git clone git://github.com/ry/ebb.git
114 Here are some features that I would like to add:
115 * HTTP 1.1 Expect/Continue (RFC 2616, sections 8.2.3 and 10.1.1)
116 * A parser for multipart/form-data
117 * Optimize and clean up upload handling
118 * Option to listen on unix sockets instead of TCP
119 * Python binding
121 ## (The MIT) License
123 Copyright © 2008 [Ry Dahl](http://tinyclouds.org) (ry at tiny clouds dot org)
125 <div id="license">
126 Permission is hereby granted, free of charge, to any person obtaining
127 a copy of this software and associated documentation files (the
128 "Software"), to deal in the Software without restriction, including
129 without limitation the rights to use, copy, modify, merge, publish,
130 distribute, sublicense, and/or sell copies of the Software, and to
131 permit persons to whom the Software is furnished to do so, subject to
132 the following conditions:
134 The above copyright notice and this permission notice shall be
135 included in all copies or substantial portions of the Software.
137 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
138 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
139 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
140 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
141 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
142 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
143 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
144 </div>