← 返回日报
精读 预计 1 分钟

Solid Queue 1.6.0 now supports fiber workers

摘要

Solid Queue 1.6.0 版本新增了 fiber worker 执行模式,允许在单个 fiber reactor 线程上运行多个任务,替代原先的线程池方式。配置时只需指定 fiber 数量而非线程数,但需要依赖 Async 库并启用 Rails 的 fiber isolation。该模式对 I / O 密集型工作负载(如 LLM 调用)特别有用。版本还包含其他修复和文档更新。

荐读理由

如果你在 Rails 项目中用 Solid Queue 处理 LLM 调用等 I/O 密集任务,可直接按说明配置 fiber 模式替代线程池,降低资源占用并提升并发效率。同时确认了该功能已正式发布,可纳入技术选型考量。

原文

A long-awaited feature thanks to @crmne on this release: instead of using a thread pool to run jobs in multiple threads per works, you can now use fibers on a single fiber reactor thread. To use this, you just need to specify the number of fibers instead of the number of threads in your worker configuration, like this:

workers:
  - queues: "api*"
    fibers: 100
    polling_interval: 0.05

It uses Async under the hood, so you need to have that as a dependency for it to work. Also, you need to be using fiber isolation in Rails (config.active_support.isolation_level`` = :fiber).

This can be very useful for I/O-bound workloads, such as those involving LLM calls.

What's Changed

  • Add fiber worker execution mode by @crmne in #728

  • Roll back transactions leaked by killed job threads in tests by @rosa in #773

  • Document how to update dynamic recurring tasks by @wintan1418 in #777

New Contributors

Full Changelog: v1.5.1...v1.6.0

Hacker News · 101 赞 · 39 评 讨论 → 阅读原文 →

这条对你有帮助吗?