如何使用 Passenger 增加 Rails 的线程数?

How to increase the number of threads for Rails using Passenger?

我在 Rails 应用程序上有一个 Ruby 在非常特定的时间收到非常多的请求,有时 Passenger 的请求队列超过 100 而用户得到 503。

如何设置更多的线程数?

我正在使用 Passenger 和 Nginx,使用 capistrano-passenger 与 Capistrano 一起部署 gem。

This article at Phusion Passenger 似乎直接回答了你的问题,并为相关问题提供了一些指导。

Step 3: configure Passenger

Purely single-threaded multi-process scenarios

Configure:

passenger_max_pool_size <desired_app_processes>;
passenger_min_instances <desired_app_processes>;
passenger_pre_start to have your app started automatically at web server boot.

Multithreaded scenarios

In order to use multithreading you must use Passenger Enterprise. The open source version of Passenger does not support multithreading.

Configure:

passenger_max_pool_size <CHOSEN_NUMBER_OF_PROCESSES>;
passenger_min_instances <CHOSEN_NUMBER_OF_PROCESSES>;
passenger_concurrency_model thread;
passenger_thread_count <desired_app_threads_per_process>;
passenger_pre_start to have your app started automatically at web server boot.
If desired_app_processes is 1, then you should set passenger_spawn_method direct. By using direct spawning instead of

smart spawning, Passenger will not keep a Preloader process around, saving you some memory (learn more at Spawn methods). This is because a Preloader process is useless when there's only 1 application process.