ohler55 / agoo

A High Performance HTTP Server for Ruby
MIT License
912 stars 39 forks source link
benchmark clustering clusters fast graphql graphql-server http https ipv6 rack rails rails5 ruby server sse unix-domain-socket wabur web webserver websocket

{}j Agoo

Build Status Gem Version Gem TideLift

A High Performance HTTP Server for Ruby

Usage

Rack

require 'agoo'

Agoo::Server.init(6464, './root')

class MyHandler
  def call(req)
    [ 200, { }, [ "hello world" ] ]
  end
end

handler = MyHandler.new
Agoo::Server.handle(:GET, "/hello", handler)
Agoo::Server.start()

# To run this example type the following then go to a browser and enter a URL
# of localhost:6464/hello.
#
# ruby hello.rb

GraphQL

require 'agoo'

class Query
  def hello
    'hello'
  end
end

class Schema
  attr_reader :query

  def initialize
    @query = Query.new()
  end
end

Agoo::Server.init(6464, './root', thread_count: 1, graphql: '/graphql')
Agoo::Server.start()
Agoo::GraphQL.schema(Schema.new) {
  Agoo::GraphQL.load(%^type Query { hello: String }^)
}
sleep

# To run this GraphQL example type the following then go to a browser and enter
# a URL of localhost:6464/graphql?query={hello}
#
# ruby hello.rb

Installation

gem install agoo

Using Agoo as a server for Rails

As agoo supports rack compatible apps you can use it for rails applications:

Add agoo to the Gemfile:

# Gemfile
gem 'agoo'

Install bundle:

$ bundle install

Start rails with agoo as server:

$ rails server -u agoo

Enjoy the increased performance!

What Is This?

Agoo is Japanese for a type of flying fish. This gem flies. It is a high performance HTTP server that serves static resource at hundreds of thousands of fetches per second. A simple hello world Ruby handler at over 100,000 requests per second on a desktop computer. That places Agoo at about 85 times faster than Sinatra and 1000 times faster than Rails. In both cases the latency was two orders of magnitude lower or more. Checkout the benchmarks.

Agoo supports the Ruby rack API which allows for the use of rack compatible gems such as Hanami and Rails. Agoo also supports WebSockets and SSE.

Agoo is not available on Windows.

Getting Started

Some examples can be found in the example directory. Some other documented walk through examples of using Agoo are in the misc directory. These examples are described in markdown files. Some like the song example are simple while others like the glue are more complex. The documented walk through examples are:

News

Releases

See file:CHANGELOG.md

Releases are made from the master branch. The default branch for checkout is the develop branch. Pull requests should be made against the develop branch.

Support

Get supported Agoo with a Tidelift Subscription. Security updates are supported.

Links