Nginx Tuning

Maxim Dounin mdounin at mdounin.ru
Tue Jul 4 12:27:47 UTC 2017


Hello!

On Tue, Jul 04, 2017 at 04:01:44AM -0400, guruprasads wrote:

> Hi,
> 
> I am trying to tune nginx server.
> I want to restrict number of client connection per server and restrict
> bandwidth.
> I tried 
> worker_connections 2; 
> for max connections in nginx.conf file. 
> but its connecting only after worker_connection value set to 7.
> 
> my conf file look like below.
> 
> user nginx;
> worker_processes auto;
> error_log /var/log/nginx/error.log;
> pid /run/nginx.pid;
> 
> # Load dynamic modules. See /usr/share/nginx/README.dynamic.
> include /usr/share/nginx/modules/*.conf;
> 
> events {
>     worker_connections 7;
> }
> 
> thanks.

The worker_connections directive is to control number of internal 
connection structures in nginx.  It should not be set to low 
values, as these structures are used in many places in nginx - 
including listening sockets, client connections, connections to 
upstream servers, and so on.  And shortage of these structures 
will result in fatal errors.  Instead, you may want to use large 
numbers if you want to handle reasonable load, as default 512 is 
very small in the modern world.

If you want to limit connections, consider using the limit_conn 
module instead see here:

http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html

To restrict bandwidth on a per-connection basis, there is 
the limit_rate directive (http://nginx.org/r/limit_rate).

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list