gpt4 book ai didi

ruby - Phusion passenger 中的多个请求是否在各自的线程中运行?

转载 作者:数据小太阳 更新时间:2023-10-29 07:06:09 25 4
gpt4 key购买 nike

我有一个使用 Phusion passenger + Apache 网络服务器部署的 Ruby on Rails 应用程序。每个请求是否都在由 Phusion Passenger 生成的自己的线程中运行?

最佳答案

Passenger(以及大多数其他应用程序服务器)每个线程运行不超过一个请求。通常每个进程也只有一个线程。来自Phusion Passenger docs :

Phusion Passenger supports two concurrency models:

  • process: single-threaded, multi-processed I/O concurrency. Each application process only has a single thread and can only handle 1 request at a time. This is the concurrency model that Ruby applications traditionally used. It has excellent compatibility (can work with applications that are not designed to be thread-safe) but is unsuitable workloads in which the application has to wait for a lot of external I/O (e.g. HTTP API calls), and uses more memory because each process has a large memory overhead.

  • thread: multi-threaded, multi-processed I/O concurrency. Each application process has multiple threads (customizable via PassengerThreadCount). This model provides much better I/O concurrency and uses less memory because threads share memory with each other within the same process. However, using this model may cause compatibility problems if the application is not designed to be thread-safe.

(强调我自己)

关于ruby - Phusion passenger 中的多个请求是否在各自的线程中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18648379/

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