Ruby Web Framework

Source: Internet
Author: User

JGW Maxwell the concurrency test for a Ruby web framework at the end of 2011, and a contrast test for node. js. With 250 concurrent to do the stress test, back end use MongoDB database, a total of 100,000 requests completed, the test results are as follows:

Web Framework Concurrency Model Throughput
Rails Multi-process 531 request/s
Sinatra Multi-process 576 request/s
Sinatra::synchrony Fiber path 1692 request/s
Goliath Fiber path 1924 REQUEST/S
Cramp Event IO 3516 request/s
node. js Event IO 3100 request/s

The performance of the fiber IO model is 3-4 times that of the traditional multi-process model, while the event Io is 6-7 times the number of processes. It is worth mentioning that Ruby's event IO framework Cramp even performance over node. js. It seems that the reason for poor concurrency is not in Ruby.

We look at a Ruby Web framework request Processing performance evaluation, which does not access the database or test concurrency performance, mainly the test framework handles URL request routing, renders text, and returns the processing speed of the results.

Web Framework processing Speed
Rack 1570.43 request/s
Camping 1166.16 request/s
Sinatra 912.81 request/s
Padrino 648.68 request/s
Rails 291.27 request/s

Here I would like to introduce a brief introduction to the 3 Ruby lightweight frameworks, which are much more performance than rails and are ideal for Web Service:

    • Sinatra

      Sinatra itself is a very popular and well-known lightweight web framework in the Ruby community, with no more than 1000 lines of core source code and only 1 pages of documentation. For rails developers, it took a few hours to develop Web service quickly using Sinatra. Sinatra to multithreading support is very good, can use rainbows to run multi-threaded sinatra,io concurrency processing ability is very good. GitHub also uses it to provide open API services. I wrote a Sinatra project template myself, if you use Sinatra to develop a Web Service, you can refer to it.

    • Padrino

      Padrino is a lightweight web framework based on Sinatra that provides named routing, modular Project organization, page helpers and generators, and so on, on a Sinatra basis. Padrino is a highly modeled framework for rails, where the API naming is similar to rails, and rails developers can quickly get started by taking a look at the documentation for 1-2 days. Padrino is easier to learn and use than rails, multithreaded support is good, performance is much better than rails, development website recommended. My own website is also developed with Padrino, source code in: Robbin_site

    • Goliath

      Goliath is a ruby fiber development framework that performs very well and the author itself is a Goliath developed in the development of PostRank products. PostRank is a user social behavior real-time tracking tool that requires high performance to support, PostRank was acquired by Google and the author is now working for Google. Goliath is ideal for developing Web service or real-time applications that are very responsive to performance, but with Goliath there are some thresholds that you cannot use for normal blocking IO libraries, and you must use some fiber libraries that the author encapsulates.

Compare a lightweight web framework for writing Web Service Interfaces I recommend two: Grape and Sinatra, the difference between the two main:

Grape is a purely write API framework, provides a lot of writing API very convenient function, with grape write API very cool, should be preferred, he only provide json/xml/txt format output.

Sinatra is a relatively perfect point of the web framework, with template rendering function, but simply write API, no grape cool. However, if your API server is likely to output HTML page fragments, need template function, or Sinatra more appropriate, otherwise it is very troublesome to use grape to spell strings in the code.

Grape and Sinatra are based on a very lightweight package on the rack, I do the framework processing request speed test, as well as multithreaded concurrency simple test, basically the performance difference is very small, grape a little faster, but not more than 5%.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.