我应该如何配置 Nginx 以最大化 Passenger 上单个 Ruby 应用程序 运行 的吞吐量?
How should I configure Nginx to maximise the throughput for single Ruby application running on Passenger?
我想对 Nginx+Passenger 进行基准测试,想知道是否可以在以下 nginx.conf
中进行调整以提高吞吐量并减少延迟。这是 运行 在具有 16GB 主内存的 4 核 i7(8 个硬件线程)上。
load_module /usr/lib/nginx/modules/ngx_http_passenger_module.so;
# One per CPU core:
worker_processes auto;
events {
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
keepalive_timeout 60;
# 8 should be number of CPU threads.
passenger_root /usr/lib/passenger;
passenger_max_pool_size 8;
server {
listen [::]:80;
server_name passenger;
root /srv/http/benchmark/public;
passenger_enabled on;
passenger_min_instances 8;
passenger_ruby /usr/bin/ruby;
passenger_sticky_sessions on;
}
}
我正在使用 wrk
多个并发连接(例如 100)。
以下是一些具体问题:
- Nginx的配置能否再改进一下?
- 是否使用 HTTP/1.1 到 Passenger 应用程序服务器的持久连接?
- 使用动态模块是否会导致任何性能问题?
- 我是否需要做任何其他事情来最大限度地提高集成工作的效率?
- 我没有设置乘客日志文件以确保日志记录 IO 不是瓶颈。
- 关于进程数 - 我有 8 个硬件线程,所以我将其设置为至少使用 8 个实例。
- 每个应用程序服务器使用线程有意义吗?我假设它只与 IO 绑定工作负载相关。
- 如果我将处理器与 8 个应用程序服务器挂钩,是否表示服务器数量足够?或者我应该试试,比方说,16?
- Nginx+Passenger 与 Passenger Standalone 之间的预期性能差异是什么?
这里是乘客开发。
"Can the Nginx configuration be improved further?"
可能,Nginx 有很多杠杆,如果您所做的只是在基准测试中提供已知的有效负载,那么您可以使用 Nginx 的缓存来显着提高性能,例如。
"Is it using HTTP/1.1 persistent connections to the Passenger application servers?"
不,它使用 unix 套接字。
"Is using a dynamic module causing any performance issues?"
不,一旦 nginx 加载库,对其进行函数调用与任何其他 c++ 函数调用相同。
"Do I need to do anything else to maximize the efficiency of how the integration is working?"
您可能想查看 Passenger 的涡轮缓存,and/or nginx 缓存。
"I haven't set a passenger log file to ensure that logging IO is not a bottleneck."
很好,但是将日志记录级别调低到 0 以避免一些处理。
"Would it make sense to use threads per application server? I assume it's only relevant for IO bound workloads."
不确定您的意思,您是在谈论 Passenger 的多线程支持还是 nginx 的支持?
"If I am pegging the processors with 8 application servers, does that indicate a sufficient amount of servers?"
如果您 CPU 绑定了,那么添加更多进程将无济于事。
"What is the expected performance difference between Nginx+Passenger vs Passenger Standalone?"
不多,Passenger standalone内部使用nginx。如果您将内置引擎与 passenger standalone 一起使用,您可能会看到一些改进,但这意味着您不能使用更重要的缓存。
我想对 Nginx+Passenger 进行基准测试,想知道是否可以在以下 nginx.conf
中进行调整以提高吞吐量并减少延迟。这是 运行 在具有 16GB 主内存的 4 核 i7(8 个硬件线程)上。
load_module /usr/lib/nginx/modules/ngx_http_passenger_module.so;
# One per CPU core:
worker_processes auto;
events {
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
keepalive_timeout 60;
# 8 should be number of CPU threads.
passenger_root /usr/lib/passenger;
passenger_max_pool_size 8;
server {
listen [::]:80;
server_name passenger;
root /srv/http/benchmark/public;
passenger_enabled on;
passenger_min_instances 8;
passenger_ruby /usr/bin/ruby;
passenger_sticky_sessions on;
}
}
我正在使用 wrk
多个并发连接(例如 100)。
以下是一些具体问题:
- Nginx的配置能否再改进一下?
- 是否使用 HTTP/1.1 到 Passenger 应用程序服务器的持久连接?
- 使用动态模块是否会导致任何性能问题?
- 我是否需要做任何其他事情来最大限度地提高集成工作的效率?
- 我没有设置乘客日志文件以确保日志记录 IO 不是瓶颈。
- 关于进程数 - 我有 8 个硬件线程,所以我将其设置为至少使用 8 个实例。
- 每个应用程序服务器使用线程有意义吗?我假设它只与 IO 绑定工作负载相关。
- 如果我将处理器与 8 个应用程序服务器挂钩,是否表示服务器数量足够?或者我应该试试,比方说,16?
- Nginx+Passenger 与 Passenger Standalone 之间的预期性能差异是什么?
这里是乘客开发。
"Can the Nginx configuration be improved further?"
可能,Nginx 有很多杠杆,如果您所做的只是在基准测试中提供已知的有效负载,那么您可以使用 Nginx 的缓存来显着提高性能,例如。
"Is it using HTTP/1.1 persistent connections to the Passenger application servers?"
不,它使用 unix 套接字。
"Is using a dynamic module causing any performance issues?"
不,一旦 nginx 加载库,对其进行函数调用与任何其他 c++ 函数调用相同。
"Do I need to do anything else to maximize the efficiency of how the integration is working?"
您可能想查看 Passenger 的涡轮缓存,and/or nginx 缓存。
"I haven't set a passenger log file to ensure that logging IO is not a bottleneck."
很好,但是将日志记录级别调低到 0 以避免一些处理。
"Would it make sense to use threads per application server? I assume it's only relevant for IO bound workloads."
不确定您的意思,您是在谈论 Passenger 的多线程支持还是 nginx 的支持?
"If I am pegging the processors with 8 application servers, does that indicate a sufficient amount of servers?"
如果您 CPU 绑定了,那么添加更多进程将无济于事。
"What is the expected performance difference between Nginx+Passenger vs Passenger Standalone?"
不多,Passenger standalone内部使用nginx。如果您将内置引擎与 passenger standalone 一起使用,您可能会看到一些改进,但这意味着您不能使用更重要的缓存。