Comparative study Ruby & Rai

2015-06-06  本文已影响71人  王谙然

1.Web server

  1. Unicorn

  2. Unicorn is designed for fast-running requests.

  3. Single-threaded, multi-process。

  4. All processes listen on a single shared socket, this simplifies reverse proxy configuration

  5. Good stability.

  6. Thin

  7. Allows high concurrency.

  8. Uses the evented I/O model by utilizing the EventMachine library.

  9. Need to monitor crashes etc.

  10. High customization, but it is difficult to design efficient clusters.

  11. Rainbows: based on unicorn, for sleepy apps and slow clients

  12. Puma

  13. Built For Concurrency.

  14. Can change Single-process mode to Multi-process. Single-process, multi-threaded, use Thread Pool.

  15. According to the number of requests to adjust the number of threads between min and max.

  16. Use less resource of RAM when the number of request is small.

  17. Allowing blocking IO to be run concurrentl.

  18. To make best use of multi-CUP, change MRI to JRuby or Rubinius.

  19. Not very good stability.

  20. Passenger(Raptor)

  21. Most Simple config.(Passeger's goal is to make everything Just Work(tm) with as little hassle as possible.)

  22. Integrates directly into Apache or Nginx.

  23. Not easy to customize,advanced features need to pay.

  24. References:

  25. Ruby on Rails Server options

  26. The Philosophy Behind unicorn

  27. Puma README

  28. Ruby multi-threaded server

2.Sidekiq

  1. Simple, efficient background processing for Ruby. In some cases like delivering many emails in one task.

  2. Sidekiq build a page for managing background processes.

  3. Both Resque and Sidekiq are Redis-backed.

  4. Resque forks a new process for every job, Sidekiq uses multithreading.

  5. Use Resque to makes a queue of jobs in Radis then let Sidekiq process them in some particular situations like creating a user firstly and then upload a avatar.

3.Zeus

  1. Speed up rails command execution.

  2. Bugs Issues.

4.Rails vs Sinatra

  1. Rails

    1. Pros
      1. Rails is a integration for web development.
        1. Database access, ActiveRecord.
        2. Template engine, Erb.
        3. Test framwork
        4. Many open-source and high-quality gems.
      2. Use Rails can build a porject very fastly.
  2. Cons

    1. ActiveRecord: Easy to use, but bad design like 1 + N query.
    2. Performance: Rails applications are not as fast as Java or C.
    3. Scaling: it's not easy to optimize and refactor when the project becomes large.
  1. Sintra

    1. Pros

      1. Easy to learn.(Simple wrapper for Rack)
      2. Focus on HTTP.
      3. Good performance compare to Rails.
      4. Easy to work with ruby gems, easy to customize for small web porject.
    2. Cons

      1. Need to draw up a standard for development of Sintra.

      2. Need to do many work for efficient development.

        1. Srcipts doing some work like rails new
        2. Building development, test and production evrionments
        3. Connnecting database.
        4. Loging.
        5. Some thing like rails console
        6. Deploy
        7. Maintain
      3. Hand-over, need readable and overall documents.

  2. How do we make decision on which framework to use?

  3. It depends on requirements.

  4. Rails:

    1. When we need launch a poject as far as possible for test our new ideas or the feedback from users.
  5. Sinatra:

    1. Help fresher to learn what file structure and components a web server need, for understanding deeply how Rails works.
    2. When a poject needn't do every things a normal web app will, like API server, use Sinatra with good design of project structure and proper gems can make a better performance than Rails.
上一篇下一篇

猜你喜欢

热点阅读