A file descriptor is a simple integer used to indicate the files and sockets opened by each process. The first open file is 0, the second is 1, and so on. A Unix operating system usually imposes a limit on the number of files that can be opened by each process. What's more, unix usually has a system-level limit. On UNIX/Linux platforms, standard input (0), standard output (1), and standard error (2) Output correspond to three file descriptors. Www.2cto.com for squid, because of the working method of squid, file descriptor restrictions may greatly affect the performance. After squid runs out of all file descriptors, it cannot receive new connections from users. That is to say, a denial of service is caused by the use of file descriptors. After a part of the current request is completed, the corresponding file and socket are closed, and squid cannot receive new requests. When squid detects a file descriptor shortage, it will issue a warning. For Apache, when many virtual hosts are used and each host uses different log files, Apache may encounter the dilemma of exhausting file descriptors (sometimes called file handles. The total number of file descriptors used by Apache is as follows: one for each different error log file, one command for each other log file, and 10 ~ 20 are used internally. The Unix operating system limits the number of file descriptors that each process can use. The typical upper limit is 64, but can be expanded until a large hard-limit is reached ). In linux, the maximum file descriptor has two restrictions: one is user-level, and the other is system-level. The following are three methods for viewing Linux file descriptors: [root @ localhost ~] # Sysctl-a | grep-I file-max -- color fs. file-max = 392036 [root @ localhost ~] # Cat/proc/sys/fs/file-max 392036 [root @ localhost ~] # Ulimit-n 1024 [root @ localhost ~] # System-level restrictions: the sysctl command and proc file system view the same value, which is a system-level restriction. It is a user-level limit that limits the total number of file descriptors opened by all users: the ulimit command displays the maximum user-level file descriptor limit. That is to say, the total number of file descriptors occupied by the programs executed after each user log on cannot exceed this limit. How can I modify the file descriptor value? 1. Modify the user-level limit [root @ localhost ~] # Ulimit-SHn 10240 [root @ localhost ~] # Ulimit-n 10240 [root @ localhost ~] # The above modifications only apply to the current session and are temporary. If you need to modify them permanently, You need to modify them as follows: [root @ localhost ~] # Grep-vE '^ $ | ^ #'/etc/security/limits. conf * hard nofile 4096 [root @ localhost ~] # // The default configuration file contains only the hard option. soft indicates the setting value that is effective for the current system. hard indicates the maximum value that can be set in the system [root @ localhost ~] # Grep-vE '^ $ | ^ #'/etc/security/limits. conf * hard nofile 10240 * soft nofile 10240 [root @ localhost ~] # // Soft <= hard soft limit cannot be higher than hard limit 2. Modify system limit [root @ localhost ~] # Sysctl-wfs. file-max = 400000 fs. file-max = 400000 [root @ localhost ~] # Echo350000>/proc/sys/fs/file-max // failure after restart [root @ localhost ~] # Cat/proc/sys/fs/file-max 350000 [root @ localhost ~] # // The above is temporary file descriptor modification // Permanent modification to fs. file-max = 400000 added to/etc/sysctl. in conf, use sysctl-p. The following is an excerpt from The file-max and file-nr parameters in The kernel document. file-max & file-nr: The kernel allocates file handles dynamically, but as yet it doesn' t free them again. the kernel can dynamically allocate file handles, but so far the value in file-max denotes the maximum number of file handles that The Linux kernel will be allocate. when you get lots of error messages about runnin G out of file handles, the value of you might want to increase this limit. file-max is the maximum number of file handles that can be allocated to the Linux kernel. If you see a lot of error messages about the maximum number of opened files, you can try to add Historically, the three values in file-nr denoted the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. linux 2.6 always reports 0 as the number of free file handles -- this is not an error, it just means that the number of allocated file handles exactly matches the number of used file Handles. in versions earlier than kernel 2.6, the values in file-nr are composed of three parts: 1. number of allocated file handles, 2. number of file handles not used in the allocated ticket, 3. the maximum number of file handles. But in kernel 2.6, the value of the second item is always 0. This is not an error. It actually means that all the allocated file handles are used. See Wikipedia.