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