Ruby的高性能HTTP服務器
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 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 gem install agoo
由於Agoo支持機架兼容應用程序,您可以將其用於Rails應用程序:
將Agoo添加到Gemfile:
# Gemfile
gem 'agoo'
安裝捆綁包:
$ bundle install
用Agoo作為服務器啟動Rails:
$ rails server -u agoo
享受提高的性能!
Agoo是一種用於飛行魚類的日本人。這個寶石飛起來。這是一款高性能HTTP服務器,以每秒數十萬個獲取為靜態資源。一個簡單的Hello World Ruby處理程序,每秒在台式計算機上以超過100,000個請求。這使Agoo的速度比Sinatra快85倍,而Rails的速度快1000倍。在這兩種情況下,延遲均低兩個或更高的數量級。檢查基準。
Agoo支持Ruby Rack API,該API允許使用兼容的寶石,例如Hanami和Rails。 Agoo還支持Websocket和SSE。
Windows上沒有Agoo。
可以在example目錄中找到一些示例。其他一些有記錄在使用Agoo的示例的步行路程中,還有misc目錄。這些示例在Markdown文件中描述。有些像歌曲示例很簡單,而其他類似膠水則更為複雜。經過示例的記錄步行是:
2.11.0版本支持GraphQL訂閱。添加了TLS(SSL,HTTPS)支持。兩者的示例。相關的是,將GraphQL基準存儲庫提供給基礎測試器。
Agoo有一個新的GraphQl模塊,具有簡單,易於使用的API。結帳hello或歌曲示例。帶有Ruby的GraphQl的樂器簡介是一個步行路程。
Agoo在Web-Frameworks基準測試中排名第一。延遲不是最高的,但發行版2.5.2改善了這一點。 Agoo-C基准在頂部進行基準測試。所有語言中最快的Web服務器。
聚集的Agoo準備就緒。對於較慢的應用和具有多個內核的機器,實現了顯著改進的性能。該應用程序必須無狀態,因為工人之間沒有共享數據。
支持WebSocket和SSE,並提交了PR以更新了RACK規格。轉到建議的架子延長,如果您喜歡的話,讓它看起來和大拇指或心臟。
Agoo現在為Rails靜態資產提供比默認PUMA快的8000倍以上。沒錯,更快的速度8000倍。
請參閱文件:changelog.md
版本是由主分支製成的。結帳的默認分支是開發分支。應向開發分支提出拉請請求。
通過Tidelift訂閱獲得支持的Agoo。支持安全更新。
文檔:http://rubydoc.info/gems/agoo或http://www.ohler.com/agoo/doc/index.html
github repo :https://github.com/ohler55/agoo
Rubygems repo :https://rubygems.org/gems/agoo
wabur repo :https://github.com/ohler55/wabur可以選擇使用agoo
perfer回購:https://github.com/ohler55/perfer