GithubHelp home page GithubHelp logo

fatum / goliath Goto Github PK

View Code? Open in Web Editor NEW

This project forked from postrank-labs/goliath

0.0 2.0 0.0 1.27 MB

Goliath is a non-blocking Ruby web server framework

Home Page: http://goliath.io

License: Other

Ruby 97.14% CSS 2.70% JavaScript 0.15%

goliath's Introduction

Goliath

Goliath is an open source version of the non-blocking (asynchronous) Ruby web server framework. It is a lightweight framework designed to meet the following goals: bare metal performance, Rack API and middleware support, simple configuration, fully asynchronous processing, and readable and maintainable code (read: no callbacks).

The framework is powered by an EventMachine reactor, a high-performance HTTP parser and Ruby 1.9+ runtime. The one major advantage Goliath has over other asynchronous frameworks is the fact that by leveraging Ruby fibers introduced in Ruby 1.9+, it can untangle the complicated callback-based code into a format we are all familiar and comfortable with: linear execution, which leads to more maintainable and readable code.

Each HTTP request within Goliath is executed within its own Ruby fiber and all asynchronous I/O operations can transparently suspend and later resume the processing without requiring the developer to write any additional code. Both request processing and response processing can be done in fully asynchronous fashion: streaming uploads, firehose API's, request/response, websockets, and so on.

Installation & Prerequisites

  • 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

Getting Started: Hello World

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.

Performance: MRI, JRuby, Rubinius

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.

FAQ

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

Guides

Hands-on applications:

If you are you new to EventMachine, or want a detailed walk-through of building a Goliath powered API? You're in luck, we have two super-awesome Peepcode screencasts which will teach you all you need to know:

Additionally, you can also watch this presentation from GoGaRuCo 2011, which describes the design and motivation behind Goliath:

Other resources:

Discussion and Support

License & Acknowledgments

Goliath is distributed under the MIT license, for full details please see the LICENSE file.

goliath's People

Contributors

alexkwolfe avatar andrewle avatar cldwalker avatar dj2 avatar djones avatar duksis avatar dustalov avatar endel avatar gregwebs avatar igrigorik avatar joshbuddy avatar juanmcuello avatar justinko avatar karlfreeman avatar kybishop avatar mattetti avatar mikelewis avatar moretea avatar nolman avatar nviennot avatar radsaq avatar schmurfy avatar seenmyfate avatar sleeper avatar stevemohapibanks avatar subosito avatar timblair avatar tomykaira avatar wicz avatar xentek 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.