简体   繁体   中英

Does Ruby on Rails handle concurrent requests?

Does Ruby on Rails handle concurrent requests?

If not, how to make it so?

It's less that Ruby on Rails handles the concurrent requests as it is the server that is running Ruby on Rails that handles the concurrent requests. When I say a server that is running Ruby on Rails I am referring to Phusion Passenger, Mongrel or WEBrick in combination with Apache or Nginx for example. In most cases concurrency is achieved by launching multiple Ruby on Rails applications that each handle requests separately. While this may take more memory than a truly threaded approach it does not require that Ruby on Rails developers write thread-safe code.

You need to run a threaded server like Puma on a threaded Ruby like JRuby for that. Otherwise it's just the server creating processes instead of threads, like Pushion Passenger. Of course, you need to write thread safe code for that, which can be very hard to develop and mantain. For this reason most of the people sticks to single threaded solutions, althought Rails 4 is multithread by default and so we might see a trend change in the near future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM