How can we maintain the counters for each process of apache without using getmypid()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sectrait
    New Member
    • Feb 2013
    • 2

    How can we maintain the counters for each process of apache without using getmypid()

    Suppose I have a php script. Now i am benchmarking that script using apache benchmark tool. Let us say with the command. ab -n 10 -c 4 filename.php Many different apache processes will be created so as to fulfill the requests.

    Suppose total 4 processes are created to fulfill this request. Now, Let us say that the processes have ids p1,p2,p3,p4 and requests are r1,r2,.....r10.

    As an example assume how requests are completed.

    p1 p2 p3 p4 r1 r2 r3 r4

    Suppose r2 got completed. So, r5 assigned to p2.

    p1 p2 p3 p4 r1 r5 r3 r4

    Suppose r4 got completed. So, r6 assigned to p4.

    p1 p2 p3 p4 r1 r5 r3 r6

    Suppose r3 got completed. So, r7 assigned to p3.

    p1 p2 p3 p4 r1 r5 r7 r6

    Suppose r1 got completed. So, r8 assigned to p1.

    p1 p2 p3 p4 r8 r5 r7 r6

    Suppose r7 got completed. So, r9 assigned to p3.

    p1 p2 p3 p4 r8 r5 r9 r6

    Suppose r5 got completed. So, r10 assigned to p2.

    p1 p2 p3 p4 r8 r10 r9 r6

    Now, at some point r6,r9,r8,10 also got completed.

    Now we can see that which process has completed which requests.

    process p1 p2 p3 p4 requests r1,r8 r2,r5,r10 r3,r7,r9 r4,r6 counter 2 3 3 2

    p1,p2,p3,p4 exists the pids of the process. Also, the counter that which process has fulfilled which request exists. Now, in php i can get the pid of which process has called it by getmypid() function and maintain a counter to store how many requests are fulfilled by the process. So, i can know for all the requests fulfilled.

    Please provide me some good way where i can get the same knowledge but without relying on the getmypid function.

    Thanks a lot.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    I dont know if its a good way,
    But you can add '%P' to your LogFormat
    see: http://httpd.apache.org/docs/2.0/mod...og_config.html

    The information about pids will be added to your logfile, and can be counted....

    Comment

    Working...