log the cpu time of each request

Discussion in 'Apache' started by alluoshi, Jan 30, 2009.

  1. #1
    Hello, Apache logs information about each request. We can also log the process ID and the time taken to service this request. But is there any way to log the cpu time for each process as well?
     
    alluoshi, Jan 30, 2009 IP
  2. w0tan

    w0tan Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've been trying to find a solution to this problem for a while. Sadly, the closest thing Apache supports is the total time a request takes (which you mentioned you were already collecting).

    I think it would be possible to write an Apache module in C that would be able to get the cpu time used for each PID.
     
    w0tan, Jan 30, 2009 IP
  3. alluoshi

    alluoshi Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for your response. It is really hard but I was just wondering if some has done this before. You can see the cpu time of each process if you look at the server-status Extended page. But this is the total cpu time of each process since one process can serve many requests.
    I believe if we mix the 2 modules mod_log and mod_status, we might reach to a solution.
    I have a question about the time taken to serve a request which Apache logs. What is the difference between this time and the cpu time of the request?
     
    alluoshi, Jan 31, 2009 IP
  4. w0tan

    w0tan Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It looks like getting the total cpu time for each process is going to be as good as you can get. It may be worth finding an Apache programmer who can write a custom module. It looks like by combining the info from mod_status and mod_log wouldn't give you enough to accurately record the CPU time for each reqeust.

    Logging has very little overhead. I have heard that if your log files get very long it can slow things down a bit, but this is easily solved by rotating old logs out and then starting with a blank log.

    EDIT
    I found a page on O'Reilly OnLamp site that may prove to be helpful.

    onlamp.com/pub/a/apache/2000/04/21/wrangler.html

    (sorry, cant post links yet)

    Scroll down a bit for their example log file, and you'll see it looks like it's logging the cpu time per request. Maybe there's some info there you could use to solve the problem. :)
     
    w0tan, Jan 31, 2009 IP