How to solve the problem of too many open files in Linux

How to solve the problem of too many open files in Linux

The cause is that the process opens a number of files and communication links that exceed the system limit at a certain moment. You can use the command ulimit -a to view the maximum number of handles currently set by the system.

core file size (blocks, -c) 0

data seg size (kbytes, -d) unlimited

scheduling priority (-e) 0

file size (blocks, -f) unlimited

pending signals (-i) 31767

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) 31767

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited

As you can see, the configuration of open files is 1024. You can increase the open files by running the following command

ulimit -n 65535

This modification method can temporarily increase the number of open files to 65535, but this configuration will become invalid after the system restarts.

Another way is to modify the system configuration file. Taking Ubuntu as an example, the default configuration file is

/etc/security/limits.conf

Add this configuration file

* soft nofile 65535 * hard nofile 6553

If you want to view the number of handles currently opened by a process, you can use the following command:

lsof -p process ID | wc -l

In addition, if you use supervisor to host and start the project, you will encounter the problem that this configuration cannot take effect. The reason is that supervisor will configure the number of open handles to be 1024 by default.

If you want to view the maximum open files of a process, you can view it through the limits corresponding to the process number of this process.

cat /proc/process ID/limits

One of the lines is:

Max open files 10241024bytes

The default value of the supervisor-hosted program is 1024, which is the maximum number of supervisor configurations. At this time, you need to manually modify the supervisor configuration file. The modification method is as follows. Taking the Ubuntu system as an example, find the supervisor configuration file supervisord.conf

In the [supervisord] option, add the minfds option configuration

[supervisord]minfds=65535 ; min. avail startup file descriptors; default 1024

After configuration, you need to restart supervisor (taking systemctl as an example)

systemctl restart supervisor

It will take effect

In passing:

cat /proc/process number/limits

Check the number of open files for the corresponding process

Max open files 6553565535 bytes

The above is the detailed content on how to solve the problem of Too many open files under Linux. For more information on solving the problem of Too many open files under Linux, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • A brief discussion on Linux virtual memory
  • Analysis of C++ compilation and linking under Linux
  • Implementation of Linux installation of Pytorch1.8GPU (CUDA11.1)
  • Tutorial on deploying springboot package in linux environment using docker
  • An example of using R language to draw pictures in Linux command line
  • A detailed introduction to the Linux directory structure
  • Linux commonly used commands performance commands
  • Linux View File System Type Example Method
  • Solution to pip upgrade error in Linux system

<<:  It is not recommended to copy the content in Word directly to the editor on the website.

>>:  Input file custom button beautification (demo)

Recommend

Axios project with 77.9K GitHub repository: What are the things worth learning?

Table of contents Preface 1. Introduction to Axio...

MySQL 8.0.20 installation and configuration method graphic tutorial

MySQL download and installation (version 8.0.20) ...

Install three or more tomcats under Linux system (detailed steps)

If you want to install multiple tomcats, you must...

HTTP header information interpretation and analysis (detailed summary)

HTTP Header Explanation 1. Accept: Tells the web s...

Detailed explanation of mandatory and implicit conversion of types in JavaScript

Table of contents 1. Implicit conversion Conversi...

Setting up shared folders in Ubuntu virtual machine of VMWare14.0.0

This is my first blog post. Due to time constrain...

js object-oriented method to achieve drag effect

This article shares the specific code for impleme...

I have sorted out some domestic design websites that I think are good.

<br />I have compiled some domestic design w...

MySQL-8.0.26 Configuration Graphics Tutorial

Preface: Recently, the company project changed th...

Web interview Vue custom components and calling methods

Import: Due to project requirements, we will enca...

Common symbols in Unicode

Unicode is a character encoding scheme developed ...

Introduction to MySQL Connection Control Plugin

Table of contents 1. Introduction to the connecti...

How to modify the forgotten password when installing MySQL on Mac

1. Install MySQL database on mac 1. Download MySQ...