开发者

Does Ruby on Rails handle concurrent requests?

开发者 https://www.devze.com 2023-02-16 02:02 出处:网络
Does Ruby on Rails handle concurrent requests? If not, ho开发者_高级运维w 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

Does Ruby on Rails handle concurrent requests?

If not, ho开发者_高级运维w 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消