Re: What is the best way to handle "too many open files" errors?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It was thus said that the Great Ben Welsh once stated:
> When I study my lsof logs on httpd instances, I'm seeing the use of a number
> of image libraries, or instance, that I cannot imagine any use for in my
> applications. then when I look at the yum log the DV provisioned by my host
> I see those same libraries as default installs. To me there seem to be two
> possible explanations -- one, there are unnecessary libraries installed on
> the system that are racking up my open files needlessly; 

  First off, libraries being referenced aren't counted towards open files
[1]. The thing is, if you are running Apache under Linux, you can find the
process ID of Apache (one of many, probably), say, it's 32345.  Then, within
a shell, do:

GenericRootPrompt> cd /proc/32345/fd
GenericRootPrompt> ls -l | more

  And that will list all the open files in that particular process.  From
there, you can figure out what you might need to do.

  As to why Apache has so many linked libraries, one question is:  do you
run PHP?  If so, that includes a ton of libraries (in my experience with
typical distributions), but since they don't count against the open file
limit, don't bother looking there to solve this issue.

  -spc

[1]	I wrote a quick program to settle this.  All the program does is
	attempt to open as many files as possible at once and see were I
	get.  This is what I got:

	[spc]lucy:/tmp/blah>../t 
	me:        21464
	max files: 1024
	01021.txt: Too many open files

	At that point, the program pauses so I can check things out.  In
	/proc/21464/fd I see there are in fact 1,024 files open.  The first
	/file opened, 00000.txt, is actually the *fourth* file to be open,
	the first three are:

	lrwx------  1 spc spc 64 May 26 17:37 0 -> /dev/pts/3
	lrwx------  1 spc spc 64 May 26 17:37 1 -> /dev/pts/3
	lrwx------  1 spc spc 64 May 26 17:37 2 -> /dev/pts/3

	which correspond to STDIN, STDOUT and STDERR (what every process
	starts with).  Further more, 1,024 files are open and yet, when I
	check to see what libraries are loaded:

	[spc]lucy:/proc/21464>more maps 
	00777000-0078c000 r-xp 00000000 fd:00 18187218   /lib/ld-2.3.4.so
	0078c000-0078d000 r--p 00015000 fd:00 18187218   /lib/ld-2.3.4.so
	0078d000-0078e000 rw-p 00016000 fd:00 18187218   /lib/ld-2.3.4.so
	00795000-008ba000 r-xp 00000000 fd:00 18187219   /lib/tls/libc-2.3.4.so
	008ba000-008bc000 r--p 00124000 fd:00 18187219   /lib/tls/libc-2.3.4.so
	008bc000-008be000 rw-p 00126000 fd:00 18187219   /lib/tls/libc-2.3.4.so
	008be000-008c0000 rw-p 008be000 00:00 0 
	08048000-08049000 r-xp 00000000 fd:00 15942114   /tmp/t
	08049000-0804a000 rw-p 00000000 fd:00 15942114   /tmp/t
	b7ef1000-b7ef2000 rw-p b7ef1000 00:00 0 
	b7f11000-b7f13000 rw-p b7f11000 00:00 0 
	bfe3e000-c0000000 rw-p bfe3e000 00:00 0 
	ffffe000-fffff000 ---p 00000000 00:00 0 

	If these had any effect on open files, then I would have only been
	able to create 1,013 files, not the 1,022 I did (I started from 0,
	which is why there seems to be a discrpancy of one).

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux