How to configure the maximum number of files that can be opened by each Nginx process

How to configure the maximum number of files that can be opened by each Nginx process
1. Check the maximum number of open files in the system
#View the current resource limit settings ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7268
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7268
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

# View the maximum number of open files in the system ulimit -n
1024
2. Set the maximum limit on the number of files opened by the system
#Permanently set the maximum limit on the number of open files in the system vi /etc/security/limits.conf
#Add parameters at the end...
*soft nofile 102400
* hard nofile 102400


#Temporarily set the maximum limit on the number of open files in the system ulimit -n 102400
#Test operation, whether to permanently load the configuration after restart #System restart init 6

#Test successful, set the maximum limit on the number of open files correctly ulimit -n
102400
3. Set the maximum limit on the number of files opened by nginx
vi /usr/local/nginx/conf/nginx.conf
user nginx;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 102400;
......

#Check if there is any problem with nginx configuration nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

#Reload nginx
nginx -s reload

The maximum number of open files in the system is The maximum limit on the number of open files in nginx should be as consistent as possible

Summarize

This is the end of this article about configuring the maximum number of files that can be opened by each Nginx process. For more information about the maximum number of files that can be opened by each Nginx process, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solution to losing nginx.pid after restarting or killing Nginx process
  • How to set the number of Nginx server processes and use multi-core CPUs
  • Two process management methods and optimization of php-fpm used by Nginx
  • Detailed explanation of Nginx process management and reloading principles

<<:  How to configure MySQL master-slave replication under Windows

>>:  Mysql database design three paradigm examples analysis

Recommend

Solve MySQL login error: 'Access denied for user 'root'@'localhost'

First of all, I don't know why I can't lo...

jQuery implements form validation function

jQuery form validation example / including userna...

How to solve the abnormal error ERROR: 2002 in mysql

Recently, an error occurred while starting MySQL....

The whole process of configuring hive metadata to MySQL

In the hive installation directory, enter the con...

MySQL Oracle and SQL Server paging query example analysis

Recently, I have done a simple study on the data ...

Perfect solution to the problem of webpack packaging css background image path

Inside the style tag of the vue component, there ...

Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx

I. Introduction Docker technology is very popular...

Steps to install MySQL 5.7.10 on Windows server 2008 r2

Install using the MSI installation package Downlo...

How to view files in Docker image

How to view files in a docker image 1. If it is a...

How to mark the source and origin of CSS3 citations

I am almost going moldy staying at home due to th...