LoginSignup
54
50

More than 5 years have passed since last update.

nginxとapacheとMySQLの同時接続数の考え方

Posted at

nginxの場合

workerのプロセス数×workerのコネクション数が同時接続数となる。

max_clients = worker_processes * worker_connections

下記の様な設定がされていた場合、nginxが捌ける同時接続数は 2048 となる。

nginx.conf
worker_processes  2;

events {
    worker_connections  1024;
}

apacheの場合

preforkの場合、MaxClientsの値そのまま。
下記のような設定がされていた場合、apacheが捌ける同時接続数は 256 となる。

httpd.conf
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

MaxClientsを修正する場合は、それに伴ってServerLimitの値も変更する必要がある。

MySQLの場合

下記のコマンドをMySQL内で実行すれば現在の設定値が確認できる。

show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 100   |
+-----------------+-------+

設定を変更するには下記のコマンドを実行。

 set global max_connections = 500;
54
50
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
54
50