在Ruby on Rails中,线程,并发和分叉进程的当前状态是什么? [英] What are the current state of affairs on threading, concurrency and forked processes, in Ruby on Rails?

查看:217
本文介绍了在Ruby on Rails中,线程,并发和分叉进程的当前状态是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby on Rails没有执行多线程请求响应,或者至少ActiveRecord没有。

Ruby on Rails does not do multithreaded request-responses very well, or at least, ActiveRecord doesn't.

只有一个请求 - 响应活动的概念在创建需要很长时间才能完成的shell命令的web应用程序时,同样的时间可能是一个麻烦。

The notion of only one request-response active at the same time can be a hassle when creating web applications which fork off a shell-command that takes long to finish.

我想要的是你的一些观点这些类型的设置? Rails可能不适合某些应用程序吗?

What I'd like are some of your views on these kinds of setups? Is Rails maybe not a good fit for some applications?

此外,关于Ruby on Rails中的并发性,当前的事务状态是什么?什么是最佳做法。

Also, what are the current state of affairs in regard to concurrency in Ruby on Rails? What are the best practices. Are there workarounds to the shortcomings?

推荐答案

Rails目前不能处理单个MRI(Matz Ruby Interpreter)中的并发请求处理。每个请求本质上是用一个巨大的互斥体。大量的工作已经使即将到来的Rails 2.2线程安全,但是你不会得到很大的好处,当运行在Ruby 1.8x下。我不能评论Ruby 1.9是否会有所不同,因为我不太熟悉它,但可能不是我想的。

Rails currently doesn't handle concurrent requests within a single MRI (Matz Ruby Interpreter) Ruby process. Each request is essentally wrapped with a giant mutex. A lot of work has gone into making the forthcoming Rails 2.2 thread-safe, but you're not going to get a lot of benefit from this when running under Ruby 1.8x. I can't comment on whether Ruby 1.9 will be different because I'm not very familiar with it, but probably not I'd have thought.

在这方面看起来非常有前途的是使用JRuby运行Rails,因为JVM通常被公认为在多线程方面是好的。来自Sun Microsystems的 Arun Gupta 提供了一些有趣的性能数字

One area that does look very promising in this regard is running Rails using JRuby, because the JVM is generally acknowledged as being good at multi-threading. Arun Gupta from Sun Microsystems gave some interesting performance figures on this setup at RailsConf Europe recently.

这篇关于在Ruby on Rails中,线程,并发和分叉进程的当前状态是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆