Link to home
Start Free TrialLog in
Avatar of fosiul01
fosiul01Flag for United Kingdom of Great Britain and Northern Ireland

asked on

idle worker Or Child process is that Same(apache2 ,Prefork.c) ??

HI
I was trying to understand how prefork  work ( I am not involving Worker.c)


Since mY server is prefork MpM base, lets try to undertand that one

to perform someo test, i have this setup ( which i know its not that practical but just trying to understnad some theory)

StartServer 2
MinSpareServer 2
Max SpareServer 2

so, according to this, there should be one parent process and 2 child process ,

-bash-3.2# ps aux | grep -v grep | grep httpd
root     24858  0.0  2.9  23188  7632 ?        Ss   10:16   0:00 /usr/sbin/httpd
apache   26748  0.0  1.7  23324  4660 ?        S    11:19   0:00 /usr/sbin/httpd
apache   26758  0.0  1.7  23324  4656 ?        S    11:19   0:00 /usr/sbin/httpd

And server-staus will show, 2 idle worker which is this
BusyWorkers: 1
IdleWorkers: 1

Now I have 2 question which i need to understand..

1. is Idle workers is Same as Child proces ??( Because MinSpareServer 2 , so there is 2 worker process )

2. Since i have setup MinSapre server value 2 ,  there would be always 2 Idle worker process( If idle worker and child process is same)
(if yes then i will have to ask few other question here)

2. How many simultanous requst can be handled by 1 idle worker process ??

Thanks for your response

Avatar of caterham_www
caterham_www
Flag of Germany image

A child process can have three states: listener, worker and idle worker depending upon if the child waits/processes a request or waits to become the listener.

> 2. Since i have setup MinSapre server value 2 ,  there would be always 2 Idle worker process

Yes, two idle. I.e. if one isn't idle anymore a new idle one should be created. That's why if MinSpareServers == MaxSpareServers (both set to the same value) becomes MaxSpareServers = MinSpareServers + 1 as documented.
Avatar of fosiul01

ASKER

Thanks
So basicaly, Idler process = child process = idle worker ( all are Same concept )  is not it ?

Now, there is little bit of confusion

with Minspare server and Max spare server 2  setup

if i do a ab test of my server

ab -n 1000 -c 10 http://www.domain.com/index.html

offcourse it will say  0 idle process after a while

but Before showing 0 idle process, its showing
 37 idle process , 40 idle process then going down to 10 to 0

Since i have specified 2 idle process, it should to go over 2 idle process is not it ??

they why its showing more then 2 idle process ??


> they why its showing more then 2 idle process ??

May be that's the time gap between the queue, creating child processes, processing requests and terminating child processes?
but my understanding was if you set minspareserver and max spare server 2 , it would not create any idle process more then 2

but its creating more then 2 idle process ( i saw upto 40)

why is that ?? here is my confusion ?

Initially i thought it would be related to child threading, but prefork does not support child threading..


have a look those 4 pictures , then you would of understand where is the confusion


what i am not understanding, Min and Max is setup to 2
then why its showing so much idle worker ??

it should not say more then 2 idle worker or busy worker  if idle worker and child process is Samething .


buyworker.GIF
first.GIF
idleworker.GIF
third.GIF
here its showing busyworker more then 40
4rth.GIF
just a  little add

with ab -n 1000 -c 1000 http://domain.com/index.html

if i count how many child process is creating  its 51

-bash-3.2# ps aux | grep -v grep | grep  httpd | wc -l
52


so, why its creating 51 , when it should only create 2 child process, its not ??
 
You're stressing your server, so new child processes need to be created. If they finished serving a request they become idle again and get the next request. The idle child stays until it got a request (or an internal dummy request) to be able to check the pipe of death.
> , when it should only create 2 child process,

That's not the number of max child processes, that's controlled by MaxClients.
hmmmm ok
i just tested ..

child process creating is controlled by Max Clients
if i set maxclient 2, it would not create any more child process

but this statement from apache is not it misleading ??

"The StartServers, MinSpareServers, MaxSpareServers, and MaxClients regulate how the parent process creates children to serve requests."
Ref:
http://httpd.apache.org/docs/2.0/mod/prefork.html


so whats Minspare , max spare server doing ??

What you wrote before it clear that, Child process and idle worker is not same

so whats this idle worker actually ??

Because as i said in my first post.  

StartServer 2
MinSpareServer 2
Max SpareServer 2

it creates initially 2 child process. but as time goes it creates more .. but by selecting Max client 2, it would not create any child process
and also  now i am seeing, its not creating any more idle worker more then 2

So, example, if i give MinSapreserver and maxspare server value 8 but if i give Maxclient 2,
so Maxclient will override everything(Minspare and max spare) right ??

so what exactly minspare server and maxspare server doing ?

sorry for complexing, but i need to understand ..
> so whats Minspare , max spare server doing ??

They're controlling how many idle childs are created (minimun)/kept (maximum)

> so whats this idle worker actually ??

It's a child process which has nothing to do at this second.

> but by selecting Max client 2, it would not create any child process

No, it's only max idle childs, not childs in total. There can be 250 busy childs and 2 idle ones (=252 childs). If the busy childs become idle (and not busy again caused by many requests), they'll die after they check the pipe of death (due to your max idle 2 setting).

> So, example, if i give MinSapreserver and maxspare server value 8 but if i give Maxclient 2,

Hopefully configtest fails because the condition min 8 idle, max 9 idle can't be met, but may be the values are downgraded to min 1 and max 2.

> so what exactly minspare server and maxspare server doing ?

they control how many childs should be idle. If you've 2 childs and both are busy, with minspare 2, maxspare 3 (that's automatically set if maxspare has the same value) apache will create 2 idle childs (=now 4 childs in total). If the two idle ones become busy (=4 busy, 4 in total), apache will create another 2 childs (=6 in total). If two busy ones become idle (=2 busy, 4 idle), apache will terminate 2 idle childs (maxspare setting; so we have 2 busy, 2 idle).

The mechanism of the _pre_fork mpm is to have preforked childs when a request comes in waiting in idle mode and not to fork a child at that point but before (=pre).
HI
Good Moring, Sorry due to night i could not able to reply
Thanks for nice explanation. so i will try to make a conclution about what i understand, please have a read and say if i am right.

Example 1:

StartServer 2
MinSpareServer 2
Max SpareServer 2
Max Client 50

what Apache will do :
Initiall it will  create 1 master process and 2 child process. Now if all child(2) process are busy then apache will create Another 2, if all busy(4) then it will create another 2 so every time it will create 2 child process (idle process)
So it will always Keep 2 idle process free.


EXample 2:

StartServer 2
MinSpareServer 2
Max SpareServer 2
Max Client 2

So Initially, Server will start with 2 child process, but when request will come, Since Maxclient setup 2, it would create any child process .


Please Edit if i am wrong



ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Really apprecited your explaination. its means a lot

I will take it from here

Thanks again,

about Maxclient 2, , i was testing this in to one of my personal web server which has less memory only 256 MB, and dont get too much hits. its just me and some familiy member. so
with Max client 2 or 3 , i am not having any problme, but i guess, i can utilized the RAM!! its not creating too much trafiq hence , My system is not using swap memory ...


but One thing i will just ask before closing this question

since i said, i have set MAX client 3,
now if any sort of DDOS attack happpend, and some one try to exeucte 1000 simultatious request , will it slow down the server ??

here by slow down mean, other services like sendmail and other ??

My understanding is, since Max client 3, so it would not create any more child hence no ram would be allocated even if some one test 1000 simultanous connections, Yes, WEb server would slow, but will it take resource like CPU power and other which might effect other Serivce which runnign on this sytem????

Promise its my last question!!!