博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Goliath
阅读量:7030 次
发布时间:2019-06-28

本文共 3211 字,大约阅读时间需要 10 分钟。

by

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

The framework is powered by an reactor, a high-performance and Ruby 1.9 runtime. One major major advantage Goliath has over other asynchronous frameworks is the fact that by leveraging 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 Goliath request is executed in 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
: , , , and .

Installation & Prerequisites

Install Ruby 1.9 (via RVM or natively):

  • gem install rvm
  • rvm install 1.9.2
  • rvm use 1.9.2

Install Goliath:

  • gem install goliath

Getting Started

 
require
'goliath'
class
Hello
<
Goliath
::
API
  
# default to JSON output, allow Yaml as secondary
  
use
Goliath
::
Rack
::
Render
,
[
'json'
,
'yaml'
]
  
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.
brought to you by .

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.2 as the best performing VM: a roundtrip through the full Goliath stack on MRI 1.9.2p136 takes ~0.33ms (~3000 req/s).

JRuby performance (with 1.9 mode enabled) is currently much worse than MRI Ruby 1.9.2, due to the fact that all JRuby fibers are mapped to native Java threads. However, there is , existing work that promises to make JRuby fibers even faster than those of MRI Ruby. Once this functionality is built into JRuby (), JRuby may well take the performance crown. At the moment, without the MLVM support, a request through the full Goliath stack takes ~6ms (166 req/s).

Rubinius + Goliath performance is tough to pin down - there is a lot of room for optimization within the Rubinius VM. Currently, requests can take as little as 0.2ms and later spike to 50ms+. Stay tuned!

Goliath has been in production at PostRank for over a year, serving a sustained 500 requests/s for internal and external applications. Many of the Goliath processes have been running for months at a time (read: no memory leaks) and have served hundreds of gigabytes of data without restarts. To scale up and provide failover and redundancy, our individual Goliath servers at PostRank are usually deployed behind a reverse proxy (such as HAProxy).

Discussion and Support

 

Contributing

You can clone the project with by running:

$ git clone git://github.com/postrank-labs/goliath

转载地址:http://skgxl.baihongyu.com/

你可能感兴趣的文章
如何优化您的 Android 应用 (Go 版)
查看>>
Trie树实现
查看>>
Opencv无法调用cvCaptureFromCAM无法打开电脑自带摄像头
查看>>
Exception异常处理机制
查看>>
复杂的web---web中B/S网络架构
查看>>
编写文档的时候各种问题
查看>>
Eclipse里maven的project报Unbound classpath variable: 'M2_REPO/**/***/***.jar
查看>>
新旅程CSS 基础篇分享一
查看>>
查看内核函数调用的调试方法【原创】
查看>>
个人项目中遇到的问题
查看>>
byte与base64string的相互转化以及加密算法
查看>>
20145103 《Java程序设计》第3周学习总结
查看>>
ubuntu声音系统
查看>>
哈哈更新资源列表2
查看>>
冲刺第一周第五天
查看>>
Java 接口
查看>>
Android 微信第三方登录
查看>>
硬盘的读写原理
查看>>
实例 centos自动挂载、备份windows共享文件夹,并删除第7日前当天的备份
查看>>
LNMP下动静分离部署phpmyadmin软件包
查看>>