Syndicate content

Apache eating file descriptors

Today we again ran in an out of memory error. As we are adding more websites our foot print is growing... Our servers use a VPS that has limited resources and whenever the limit is reached, the system automatically kills processes. How the VPS selects the process to kill isn't clear to me, but twice it has been our database manager meaning that all of a sudden all the websites stop working.

So... We got an extra bit of RAM because our package allowed it, but that's still small.

Now as I was looking at that, I noticed that we had "too many files open" warning as well.

Looking at the open files with lsof I noticed many files opened by Apache. A lot more than I expected... (2,800+)

Searching the Internet I found out that Apache opens one file per Log (custom and error logs) and if you have multiple logs (as in one for HTML page, one for PHP pages, etc.) then each will be opened once. That is, it will be opened once per Apache sub-process. Similarly, one file descriptor is used per configuration file. Feel free to look at the output of your lsof command to determine all the files you have open.

So... say you limit your Apache server to open only 20 sub-processes and you have 20 sites that each have one error and one custom log file you get:

20 x 2 x 20 = 800 files.

One thing, if you do a full redirect, you probably don't need a specific log for that entry. For instance, I rewrite my domain name without anything m2osw.com as www.m2osw.com instead. That does not require a log. It probably does not even require a document root and the REQUEST_URL definition.

<VirtualHost *:80>
	DocumentRoot /usr/clients/www/www.m2osw.com/public_html/
	ServerName m2osw.com
	SetEnv REQUEST_URL /www.m2osw.com/
	RewriteEngine on
	RewriteRule ^/(.*) http://www.m2osw.com/$1 [R=permanent,L]
</VirtualHost>

By tweaking our setup we saved about 500 file descriptors.

Syndicate content

Diverse Realty

Diverse Realty Team

Want a New Home?
Want to Sell Your House?

Call Alex at
+1 (916)
220 6482

Alexis Wilke, Realtor
Salesperson
Lic. # 02024063

Cory Marcus, Broker
Lic. # 01079165

     

Terms of Site Index

Find the page/content you are looking for with our index.

  • CSV
  • device

    In Information Technology a device is generally a physical item that can be controlled by the computer. The hard drive, a USB camera, a memory chip, etc. are all devices.

  • hard drive

    A hard drive is a device that save a large quantity of data for later recollection.

    Most hard drives today use a magnetic system to save the data. However, those do get really hot and tend to break easily because they use a mechanical head (after 4 to 5 years.) Yet, they have an incredible capacity with drives that can hold as much as 2Tb.

    New modern drives use flash technology. This is like your USB thumb drive. It does not get hot, it is silent, it has much faster read access (no head to move.) It has two drawback: (1) it has a rather slow write and (2) the capacity is still quite small (at time of writing we are starting to get 128Gb drives...) The price is also much higher, but if you consider that these drives will probably last you twice as long as the magnetic drives and you won't need extraneous cooling systems, overall, it probably still worth it.

  • node
  • run