轨道上的红宝石和多线程

发布于 2025-02-06 05:52:47 字数 274 浏览 2 评论 0原文

当您进行多线程时,我遇到了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情旳空白 2025-02-13 05:52:48

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文