gpt4 book ai didi

ruby-on-rails - 如果Puma是多线程而不是多进程,为什么会创建多个PID?

转载 作者:行者123 更新时间:2023-12-03 12:54:38 24 4
gpt4 key购买 nike

如果Puma是多线程的,为什么还要创建多个PID?

我认为多个线程将存在于同一进程中。

在本地启动Puma时:

=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
[22095] Puma starting in cluster mode...
[22095] * Version 3.6.0 (ruby 2.2.2-p95), codename: Sleepy Sunday Serenity
[22095] * Min threads: 1, max threads: 1
[22095] * Environment: development
[22095] * Process workers: 2
[22095] * Preloading application
[22095] * Listening on tcp://localhost:3000
[22095] Use Ctrl-C to stop
[22095] - Worker 0 (pid: 22183) booted, phase: 0
[22095] - Worker 1 (pid: 22184) booted, phase: 0

运行 ps aux | grep puma时:
me  22184  ... puma: cluster worker 1: 22095 [app]    
me 22183 ... puma: cluster worker 0: 22095 [app]
me 22095 ... puma 3.6.0 (tcp://localhost:3000) [app]
me 22289 ... grep puma

我一直在学习线程与进程的关系,我认为线程是“进程内部的执行路径”,所以这让我感到困惑。

最佳答案

Puma是线程服务器,但也允许多个工作程序(进程)。如果查看初始化日志,它会提到它产生了多少workers

[22095] * Process workers: 2

这称为Puma的群集模式。每个过程都会产生
[22095] * Min threads: 1, max threads: 1

并发处理请求的线程数量。

进一步了解它: Puma Clustered Mode

关于ruby-on-rails - 如果Puma是多线程而不是多进程,为什么会创建多个PID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43837850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com