LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-13-2013, 10:09 AM   #1
idofxeno
LQ Newbie
 
Registered: Feb 2013
Location: Richmond, VA
Distribution: Mint 14 (Nadia)
Posts: 17

Rep: Reputation: Disabled
Multiple instances of apache2 running?


I couldn't connect to my server last night while I was at work, so once I got home I checked to see if the server was still on and it was (Had a power outage last week that cause me some issues so I thought that could have been it). I did ps aux | more and saw multiple entries of apache2:

Code:
eric@fate ~ $ ps aux | grep apache2
root      1741  0.0  0.1 175636  9912 ?        Ss   10:54   0:00 /usr/sbin/apache2 -k start
www-data  1890  0.0  0.1 175860  6728 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  1891  0.0  0.0 175684  6060 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  1892  0.0  0.1 175708  6300 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  1893  0.0  0.1 175700  6300 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  1894  0.0  0.1 175860  6568 ?        S    10:54   0:00 /usr/sbin/apache2 -k start
www-data  2069  0.0  0.1 175860  6568 ?        S    10:56   0:00 /usr/sbin/apache2 -k start
www-data  2070  0.0  0.0 175660  5808 ?        S    10:57   0:00 /usr/sbin/apache2 -k start
eric      2879  0.0  0.0  13584   940 pts/1    S+   11:00   0:00 grep --colour=auto apache2
I have no idea why it's doing this, but I feel pretty sure it has something to do with my troubles last night. When I checked it before I rebooted, there were like 30 instances of it running. After reboot, it was only like 5, but the number seems to randomly increase the longer the computer is on. Any idea what's going on?
 
Old 02-13-2013, 05:46 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
When Apache starts (as you can see its started as root), then drops privs to the named owner (www-data) and starts a given num of listeners, defined in httpd.conf as per the StartServers setting https://httpd.apache.org/docs/2.2/mo...l#startservers.
See also related directives like MaxClients etc on the same page.
 
Old 02-14-2013, 08:32 AM   #3
idofxeno
LQ Newbie
 
Registered: Feb 2013
Location: Richmond, VA
Distribution: Mint 14 (Nadia)
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
When Apache starts (as you can see its started as root), then drops privs to the named owner (www-data) and starts a given num of listeners, defined in httpd.conf as per the StartServers setting https://httpd.apache.org/docs/2.2/mo...l#startservers.
See also related directives like MaxClients etc on the same page.
Ok I think I understand what I read there, but again this morning I came home and checked and saw the following:

Code:
eric@fate ~ $ ps aux | grep apache2
root      1497  0.0  0.1 175636  9948 ?        Ss   Feb13   0:02 /usr/sbin/apache2 -k start
www-data  5986  0.0  0.1 180100 11640 ?        S    03:23   0:02 /usr/sbin/apache2 -k start
www-data  6061  0.0  0.1 178992 10464 ?        S    03:33   0:01 /usr/sbin/apache2 -k start
www-data  6157  0.0  0.1 180108 11572 ?        S    03:43   0:00 /usr/sbin/apache2 -k start
www-data  6158  0.0  0.1 180100 11648 ?        S    03:43   0:10 /usr/sbin/apache2 -k start
www-data  6161  0.0  0.1 178968 10292 ?        S    03:43   0:00 /usr/sbin/apache2 -k start
www-data  6221  0.0  0.1 178704 10032 ?        S    03:46   0:00 /usr/sbin/apache2 -k start
www-data  6290  0.0  0.1 178704  9864 ?        S    03:50   0:00 /usr/sbin/apache2 -k start
www-data  6409  0.0  0.1 178668  9912 ?        S    03:53   0:00 /usr/sbin/apache2 -k start
www-data  6411  0.0  0.1 179188 10696 ?        S    03:53   0:00 /usr/sbin/apache2 -k start
www-data  7425  0.0  0.1 176204  7928 ?        S    05:42   0:00 /usr/sbin/apache2 -k start
www-data  7490  0.0  0.1 178412  9712 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7491  0.0  0.1 178436  9552 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7492  0.0  0.1 179640 10752 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7493  0.0  0.1 178436  9440 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7494  0.0  0.1 179188 10584 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7495  0.0  0.1 178552  9796 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7496  0.0  0.1 178452 10060 ?        S    05:52   0:00 /usr/sbin/apache2 -k start
www-data  7526  0.0  0.1 178440  9428 ?        S    05:56   0:00 /usr/sbin/apache2 -k start
www-data  7527  0.0  0.1 178452  9800 ?        S    05:56   0:00 /usr/sbin/apache2 -k start
www-data  7534  0.0  0.1 178404  9564 ?        S    05:56   0:00 /usr/sbin/apache2 -k start
www-data  7540  0.0  0.1 176204  7952 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7541  0.0  0.1 179200 10652 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7542  0.0  0.1 178436  9488 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7544  0.0  0.1 178440  9404 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7545  0.0  0.1 178192  9564 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7546  0.0  0.1 178440  9404 ?        S    05:57   0:00 /usr/sbin/apache2 -k start
www-data  7547  0.0  0.1 176204  7932 ?        S    05:58   0:00 /usr/sbin/apache2 -k start
www-data  7548  0.0  0.1 175960  7788 ?        S    05:58   0:00 /usr/sbin/apache2 -k start
www-data  7549  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7550  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7551  0.0  0.1 176112  7932 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7552  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7553  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7554  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7555  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7556  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7557  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7558  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7559  0.0  0.1 176112  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7562  0.0  0.1 178412  9628 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7563  0.0  0.1 179188 10452 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7564  0.0  0.1 178456  9512 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7565  0.0  0.1 176204  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7566  0.0  0.1 176204  7940 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7567  0.0  0.1 178440  9380 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7568  0.0  0.1 176204  7928 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7569  0.0  0.1 178552  9776 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7570  0.0  0.1 178436  9404 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7571  0.0  0.1 178440  9400 ?        S    05:59   0:00 /usr/sbin/apache2 -k start
www-data  7573  0.0  0.1 176204  7944 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7574  0.0  0.1 178456  9944 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7575  0.0  0.1 178536 10124 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7576  0.0  0.1 181268 12052 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7577  0.0  0.1 178552  9752 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7578  0.0  0.1 178440  9392 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7579  0.0  0.1 178712  9744 ?        S    06:00   0:00 /usr/sbin/apache2 -k start
www-data  7605  0.0  0.1 176204  7932 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7606  0.0  0.1 176204  7928 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7607  0.0  0.1 178436  9384 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7609  0.0  0.1 178436  9392 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7613  0.0  0.1 176464  7968 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7614  0.0  0.1 176464  7968 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7615  0.0  0.1 176464  7968 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7616  0.0  0.1 176204  7944 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7617  0.0  0.1 178276  9392 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7618  0.0  0.1 177920  9132 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7619  0.0  0.1 176252  8192 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  7620  0.0  0.1 178452  9524 ?        S    06:01   0:00 /usr/sbin/apache2 -k start
www-data  8727  0.0  0.1 180412 11528 ?        S    08:11   0:00 /usr/sbin/apache2 -k start
www-data  9281  0.0  0.1 179232 10628 ?        S    09:23   0:00 /usr/sbin/apache2 -k start
www-data  9282  0.0  0.1 176204  7936 ?        S    09:23   0:00 /usr/sbin/apache2 -k start
www-data  9283  0.0  0.1 176204  7928 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9284  0.0  0.1 176204  7936 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9285  0.0  0.0 175676  6056 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9286  0.0  0.0 175676  6056 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9288  0.0  0.0 175660  5808 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9289  0.0  0.0 175660  5808 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9290  0.0  0.0 175660  5808 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9291  0.0  0.0 175660  5808 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
www-data  9292  0.0  0.0 175660  5808 ?        S    09:24   0:00 /usr/sbin/apache2 -k start
eric      9320  0.0  0.0  13584   940 pts/1    S+   09:25   0:00 grep --colour=auto apache2
Obviously that's a ridiculous number of processes and isn't normal. What I'm trying to figure out is what may be causing the issue. The only thing I can think of is that I do have a Glype proxy script running on a directory on the web server that a few of my coworkers (only 3 of them have the url) use occasionally to bypass the content filter at work. Does anyone know if there is some sort of bug where the child processes aren't being terminated after the client closes out of the script? Or could it be something else?
 
Old 02-14-2013, 07:37 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,289

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
Like I said, check the (several) related directives eg MaxCLients; there's also one that dictates how many requests an instance serves before it shuts down.
I'd also check the access_log and error_log to see where the requests are coming from & why.
 
Old 02-14-2013, 11:10 PM   #5
idofxeno
LQ Newbie
 
Registered: Feb 2013
Location: Richmond, VA
Distribution: Mint 14 (Nadia)
Posts: 17

Original Poster
Rep: Reputation: Disabled
my httpd.conf doesn't have anything aside from servername localhost, so default MaxClients should be 256. What I don't understand is 1) Why are child processes not being terminated when someone uses glype proxy, 2) How reducing MaxClients (or any of the other settings) is going to impact anything to me site related. As far as I can imagine, the only thing I can think of is that at a certain point it's just going to stop allowing people to access the site at all because it will enter a queue until the child processes are terminated, which won't happen until I figure out why glype acts this way, manually go in and kill all of those processes myself, or I restart the server. There are only 3 people using the proxy on the website, and according to the glype logs they are solely using it to view content on youtube at this point, so I fail to see why I would have that many remaining child processes going unless it was some issue with glype. I guess I'll just remove glype until I can figure it out. Thanks for your help.
 
Old 02-15-2013, 03:18 AM   #6
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 602

Rep: Reputation: 49
But why are you worried? Do you experience some performance problems with this server? If everything is running normally, why do you bother killing processes and restarting the server? I say, let apache do its job, if it needs 256 processes to do it, so be it.
 
Old 02-15-2013, 03:37 AM   #7
pintooo15
Member
 
Registered: May 2004
Location: on the interwebz
Distribution: linux mint 13/sled 11 sp2
Posts: 72

Rep: Reputation: 21
I suppose this is why lightweight alternatives exist.
 
Old 02-15-2013, 04:10 AM   #8
idofxeno
LQ Newbie
 
Registered: Feb 2013
Location: Richmond, VA
Distribution: Mint 14 (Nadia)
Posts: 17

Original Poster
Rep: Reputation: Disabled
Well the main reason is because I suspect it to be part of the reason why I was unable to connect to my server the other day. The modem was alive and when I got home everything appeared to be fine but I couldn't connect still. Checked processes and saw what I've already posted. After restarting, everything worked fine. Went to work and everything was fine until someone came to me saying it was no longer loading content from glype. Checked processes and boom 70 apache processes again. Restart fixed it again. The only thing Ive seen that correlates with the issue is the abundance of child processes that haven't been killed.

Im no expert by any stretch, but I equate it to how you need to delete objects in C++ or they occupy memory indefinitely unless the program exits.
 
Old 02-19-2013, 11:56 PM   #9
pintooo15
Member
 
Registered: May 2004
Location: on the interwebz
Distribution: linux mint 13/sled 11 sp2
Posts: 72

Rep: Reputation: 21
From what I found on the net, Apache 2 will spawn and keep extra processes ready to service any new clients. How much resources it uses for this ought to be configurable, though I haven't gone through the details. You may also look into MPM worker module http://httpd.apache.org/docs/2.2/mod/worker.html to control thread spawning.
 
Old 02-20-2013, 12:05 AM   #10
idofxeno
LQ Newbie
 
Registered: Feb 2013
Location: Richmond, VA
Distribution: Mint 14 (Nadia)
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pintooo15 View Post
From what I found on the net, Apache 2 will spawn and keep extra processes ready to service any new clients. How much resources it uses for this ought to be configurable, though I haven't gone through the details. You may also look into MPM worker module http://httpd.apache.org/docs/2.2/mod/worker.html to control thread spawning.
Thanks, I will be looking into this tonight. On another note, I'm apparently not the only one with this issue ( http://www.netbuilders.org/web-proxi...lype-5860.html ) So I'm going to follow the thread and check out the worker module link and see where it all leads.
 
Old 02-20-2013, 10:19 AM   #11
pintooo15
Member
 
Registered: May 2004
Location: on the interwebz
Distribution: linux mint 13/sled 11 sp2
Posts: 72

Rep: Reputation: 21
idofxeno, if you know for sure, you won't be serving like a humongous userbase. consider seriously the option of shifting to a lightweight and excellent for smaller sites webserver. nginx and lighttpd come to mind. They are very underrated. First thing to find would be if there are specific dependencies on Apache and how the alternatives can possibly satisfy those.
 
Old 02-20-2013, 12:08 PM   #12
ashwin_cse
Member
 
Registered: Jul 2004
Distribution: arch, rhel
Posts: 133

Rep: Reputation: 22
having multiple httpd processes running is perfectly normal behaviour and is nothing to worry about.
 
Old 02-20-2013, 02:45 PM   #13
pintooo15
Member
 
Registered: May 2004
Location: on the interwebz
Distribution: linux mint 13/sled 11 sp2
Posts: 72

Rep: Reputation: 21
It is a matter to worry about if your system slows to a crawl and doesn't function even at least as a webserver itself.
 
Old 02-20-2013, 03:30 PM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,239

Rep: Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577Reputation: 577
Quote:
Originally Posted by pintooo15 View Post
It is a matter to worry about if your system slows to a crawl and doesn't function even at least as a webserver itself.
Then impose a proper MaxClients limit.

count them as 5 per processor (you could also divide your memory size by the data space used by apache, then subtract 10. If the result is below 10, use 10.)

The only reason to allow apache to multi-thread is support concurrent connections. If that overloads the system, the only reasonable thing to do is limit the number threads to what the hardware will support.

256 might be reasonable for my system (8GB with 8 cores), but personally, 10 is enough.
 
Old 02-20-2013, 10:59 PM   #15
ashwin_cse
Member
 
Registered: Jul 2004
Distribution: arch, rhel
Posts: 133

Rep: Reputation: 22
Quote:
Originally Posted by pintooo15 View Post
It is a matter to worry about if your system slows to a crawl and doesn't function even at least as a webserver itself.
Running multiple instances of processes is not a reason for slowing down to crawl. Reason would be when these processes spikes cpu utilization and mem utilization. Usual situations that happens is when you have high traffic or bad code or combination of both. I have seen apache spawn mulitple instances even when there is little traffic and this behaviour has not caused the server to slow down. My server had xeon quad core cpu and 8GB ram. Basically you are looking at the wrong place for the reason for system's slow response.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Running multiple instances of Audacious (slightly urgent) hunternet93 Linux - Software 1 12-07-2010 10:58 AM
Firefox terminates if multiple instances of flash player running mutav Slackware 2 02-17-2010 01:55 PM
Running multiple instances of apache2 jordankoppole Linux - Software 8 04-23-2008 04:55 PM
Preventing multiple instances of a shell script from running concurrently Dave Lerner Programming 12 01-03-2007 09:27 PM
Why are multiple instances of mysqld running? philpq Linux - Newbie 2 02-17-2005 03:01 PM


All times are GMT -5. The time now is 10:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration