2008-12-30

Sizing Apache in front of WebLogic

Apache is a very used HTTP WebServer.

And I can't count the number of times I have been working with clients using it in their architectures.

But often, it is used with the default configuration or slightly tuned.

Even if this is normally not part of my job, I guess it's important to know how to use it properly.

You may also take a look at the post I wrote about SSL between Apache & WLS.

 

First of all : monitoring your workers

 

Well, first of all, I think it's essential to know how your Apache WS reacts.

Indeed, when load-testing your application, it's good to know how your application server behaves,

(hoping it's WebLogic ;) ) but it's also good to know if the webserver (or a load balancer hardware) is not a potential bottleneck.

 

Configuration

 

To do so, it's quite easy : just activate the webserver status like shown below :

 

LoadModule status_module modules/mod_status.so

ExtendedStatus On

[...]

<Location /server-status>
    SetHandler server-status
    Order Deny,Allow
    Deny from all
    Allow from .foo.com
</Location>

<LocationMatch "/(?!server-status)">
    SetHandler weblogic-handler
    # Conf WLS ...

</LocationMatch>

 

Let me explain that configuration.

  1. => LoadModule [...]/mod_status.so  : mandatory if we want to monitor Apache (more info)
  2. => ExtendedStatus : allows to see some additional configuration, like CPU, memory ... Essential then. Beware of the performance !
  3. => Location /server-status : all incoming requests on this URI will be handled by the server-status
  4. => LocationMatch "/(?!server-status)" : requests on all the other URIs will be handled by WebLogic



Note : LocationMatch allows you to use regular expressions. I personnaly refer to python doc when needed.

 

Result : what does it display ?

 

image

 

What's important here is: 1 requests currently being processed, 249 idle workers

And if you look at your default configuration, you'll see that the number of requests "currently being processed" added

to the number of idle workers is the number set in the httpd.conf : ThreadsPerChild 250

Considering the scoreboard :

 

Scoreboard Key: 
  • "_" Waiting for Connection
  • "S" Starting up
  • "R" Reading Request
  • "W" Sending Reply
  • "K" Keepalive (read)
  • "D" DNS Lookup
  • "C" Closing connection
  • "L" Logging
  • "G" Gracefully finishing
  • "I" Idle cleanup of worker
  • "." Open slot with no current process
 

We then have one working thread 'W', 249 idle '_' and a big number that do nothing.

 

Sizing your Apache

 

Let's take a number of ThreadsPerChild equal to 1920.

If we set that value, what's displayed is different :

 

image

 

I've reached the maximum number of workers for my configuration.

That way, Apache will reserve all the possible workers to serve requests.

This configuration implies a higher CPU activity. That's why you've got to adjust the number of workers, following your

capacity planning, in order to have a good compromise.

 

Note : It's not the only parameter you can play with to tune your webserver, but this one is quite important.