ruby – Phusion乘客中的多个请求是否在他们自己的线程中运行?

前端之家收集整理的这篇文章主要介绍了ruby – Phusion乘客中的多个请求是否在他们自己的线程中运行?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用Phusion客户Apache Web服务器部署的 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.

(强调我自己)

原文链接:https://www.f2er.com/ruby/265062.html

猜你在找的Ruby相关文章