轨道上的红宝石和多线程
当您进行多线程时,我遇到了Ruby并没有真正的性能好处。因为 gil nature 。
我认为在Rails应用中使用多线程没有意义。 铁轨应用中多线程的用例是什么?
I came across that Ruby doesn't really have any performance benefit when you do multi threading. because of GIL nature.
I see there is no point of using multi-threading in Rails app.
What is use case of multi-threading in Rails app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IO(输入/输出)操作是不是在您的CPU上操作的,例如从硬盘驱动器阅读,对服务的API调用,某种数据库操作。
即使使用GIL,任何繁重的事情都会受益于多线程。 IO操作在等待结果时会在Ruby中阻塞,因此在等待操作的结果时,这是合理的,要切换到另一个线程进行一些工作。
An IO (input/output) operation is one that is not operating on your CPU, such as, reading from a hard drive, an API call to a service, a database operation of some kind.
Anything that is IO heavy would benefit from multi-threading even with GIL. IO operations are blocking in ruby while they wait for the result, so it's only reasonable, while you are waiting for the result of the operation, to want to switch to another thread to do some work.