Will you just look wt that :))
- Install Ruby 1.9 (via RVM or natively)
$> gem install rvm
$> rvm install 1.9.3
$> rvm use 1.9.3
- Install Goliath:
$> gem install goliath
require 'goliath'
class Hello < Goliath::API
def response(env)
[200, {}, "Hello World"]
end
end
> ruby hello.rb -sv
> [97570:INFO] 2011-02-15 00:33:51 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones.
See examples directory for more hands-on examples of building Goliath powered web-services.
Goliath is not tied to a single Ruby runtime - it is able to run on MRI Ruby, JRuby and Rubinius today. Depending on which platform you are working with, you will see different performance characteristics. At the moment, we recommend MRI Ruby 1.9.3+ as the best performing VM: a roundtrip through the full Goliath stack on MRI 1.9.3 takes ~0.33ms (~3000 req/s).
Goliath has been used in production environments for 2+ years, across many different companies: PostRank (now Google), OMGPOP (now Zynga), GameSpy, and many others.
-
How does Goliath compare to other Ruby async app-servers like Thin?
- They are similar (both use Eventmachine reactor), but also very different. Goliath is able to run on different Ruby platforms (see above), uses a different HTTP parser, supports HTTP keepalive & pipelining, and offers a fully asynchronous API for both request and response processing.
-
How does Goliath compare to Mongrel, Passenger, Unicorn?
- Mongrel is a threaded web-server, and both Passenger and Unicorn fork an entire VM to isolate each request from each other. By contrast, Goliath builds a single instance of the Rack app and runs all requests in parallel through a single VM, which leads to a much smaller memory footprint and less overhead.
-
How do I deploy Goliath in production?
- We recommend deploying Goliath behind a reverse proxy such as HAProxy (sample config), Nginx or equivalent. Using one of the above, you can easily run multiple instances of the same application and load balance between them within the reverse proxy.
If you are you new to EventMachine, or want a detailed walk-through of building a Goliath powered API? You're in luck, a super-awesome Pluralsight screencast which will teach you all you need to know:
- Meet EventMachine - introduction to EM, Fibers, building an API with Goliath
Additionally, you can also watch this presentation from GoGaRuCo 2011, which describes the design and motivation behind Goliath:
Other resources:
Goliath is distributed under the MIT license, for full details please see the LICENSE file.