Best Lightweight Ruby Web Framework for Your Needs

Source: Internet
Author: User
Keywords lightweight ruby web framework best ruby web framework ruby web frameworks
I recommend two lightweight web frameworks that are more suitable for writing web service interfaces: Grape and Sinatra. The main differences between the two are:

Grape is a pure API writing framework. It provides a lot of convenient functions for writing API. It is cool to write API with Grape and should be the first choice. It only provides output in json/xml/txt format.

Sinatra is a relatively complete Web framework with template rendering function, but if you simply write API, it is not as cool as Grape. However, if your API Server is likely to output HTML page fragments and template functions are needed, Sinatra is more suitable, otherwise it is still very troublesome to use Grape to spell strings in the code.


Alibaba Cloud Simple Application Server:  Anti COVID-19 SME Enablement Program

$300 coupon package for all new SMEs and a $500 coupon for paying customers.

Grape and Sinatra are both very lightweight packages based on Rack. I did a test of the frame processing request speed and a simple test of multi-threaded concurrency. Basically, the performance difference is very small. Grape is a little faster, but not more than 5%. Test Results

It is more suitable for writing a website framework. Of course, the most complete function is Rails, but I used Padrino to make my own website project and found it to be very good. I recommend you to use it.

Finally, when it comes to concurrency performance, my own test results show that Ruby's multithreading performance is very good when the amount of concurrency is not super high. Compared with Fiber, the performance difference is very small. I have done Goliath(raw code), Goliath(Grape), Rainbows(Grape), Puma(Grape), Rainbows(Sinatra), Puma(Sinatra), concurrent performance tests, which are basically on the same level. Test Results

So if you use Ruby to write a high-concurrency API server, even if you don’t use Goliath, you can use Grape/Sinatra to write the API and use Rainbows to run. The performance is also very good, and the manageability of Rainbows is also very good, as convenient as Unicorn .
Related Article

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.