Apache and Tux running together

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I'm wondering if anyone has tried a scenario that I'm thinking of. At
my job we've got a web based product provided by Apache running PHP
that accesses MySQL. This web application is hosted by multiple servers
behind a load balancer because of the user load on the system. However,
we've still had times when the servers got over run and Apache maxes
out on the number of httpd processes (257) and falls behind to the
point of timing out. When this happens and I look at the servers with
top, they aren't particulary busy, but with 257 big httpd process (PHP
and MySQL totalling 15 Megs of ram), the server is bound up.

So here's my question; has anyone tried running the tux kernel based
web server alongside Apache with the goal of freeing Apache from
serving up static files and increasing it's capacity to handle dynamic
requests? I had one of the guys on our team try to set this up.
Essentially configuring tux so it would serve all static content and
pass on other requests (php pages) to Apache. Both processes are
running on the same server. We got this working, but didn't see much of
an improvement in the capacity of the server.

If anyone has tried this, or had any experience with this, I'd
appreciate knowing.

Thanks in advance,

Re: Apache and Tux running together


    I am new to PHP but I think that you need to play around with Apache  
source code and recompile to do what you needed done. I might be wrong, but,  
for some reason, it was the first answer on my brain-- maybe long lost  

Quoted text here. Click to load it

Re: Apache and Tux running together

On Fri, 14 Jul 2006 11:51:24 -0700, writeson wrote:

Quoted text here. Click to load it

I'm pretty sure that the desired setup that you describe was the impetus
behind creating Tux in the first place.  I'd be surprised if you didn't
find information about this in a Google search.

I think you'll havta run the two servers on different ports, though.


Re: Apache and Tux running together

JDS wrote:
Quoted text here. Click to load it


Thanks for the reply. We did in fact set this up on two different
ports: TUX is running on port 80 and Apache is on port 8080. TUX just
passes requests for things that aren't static files onto Apache at port
8080. Just to be compulsive, both TUX and Apache are running on the
same server.


Re: Apache and Tux running together

writeson@charter.net wrote:

Quoted text here. Click to load it

Whoa, you're rather jumping the gun aren't you? Picking a solution before
you really know what the problem is.

Using an LAMP stack, when it reaches a performance limit at any point in the
stack, the system rapidly saturates and throughput takes a nosedive. Now,
this can happen because of multiple reasons.  

I would recommend that you start monitorning the system at all times and
chart the number of httpd processes (if possible the number of active httpd
processes) vs memory used to check that you've got max processes at its
optimal value (i.e. not resulting in lots of paging).  

You should also be logging mysql slow queries, along with counting the
number of connections to the mysqld server and the length of the mysql
processlist. Slow queries should be fixable. A long processlist can be more
tricky but could still point to saturation on the DB as the problem.
Generally getting the schema right gives far greater performance benefits
than tinkering with the hardware - but the latter can be an issue on some

Also watch out for plain bad php - unfortunately I don't know any way of
measuring this other than going through the most popular and the slowest
urls by hand to see if they can be made faster. You are using a PHP
accelerator aren't you?

Note that a lot of your memory is probably being used up by apache processes
just hanging around while data gets fed down a slow socket. While you can't
speed up somebody elses network connection you can reduce the load by
moving it away from the httpd processes. It is this where using Tux would
be of benefit - it would use less memory per connection. However splitting
the traffic might not be that simple. More conventionally one would put a
reverse proxy in front of the webservers - squid is a good choice. There's
also an apache module designed specifically for handing over the datafeed
to a less memory hungry process - the name escapes me for now but its
probably easy to find on google.

Quoted text here. Click to load it

Oh dear. This always sets the alarm bells ringing for me. It usually means
that somebody has got a vendor certificate and somebody got some lunches
bought for them.

I could go on for hours. But I'd have to charge you for it.

Try to work out where your problem is first.


Re: Apache and Tux running together


Thanks for your reply. Since you had lots of good information, I'll
inject my comments in the body of your reply. :)

Colin McKinnon wrote:
Quoted text here. Click to load it

I think I know what the problem is, I'm not sure what's causing it or
how to address it at the moment. When one of our servers gets locked up
I look at it and see that it has 257 httpd processes running, each of
which is big in terms of memory space. The processors themselves don't
seem all that busy, so I'm thinking I'm memory bound. I think this
because if I increase the number of max_clients in the Apache config it
doesn't improve things, and looks like those additional httpd processes
are being paged to disk. Because this one server is serving up both
dynamic pages, and the multiple static files (graphics) that are on
those pages, I think each httpd process is growing to capacity to do
the PHP and MySQL work, but then remaining in memory for many, many
requests that are just static files.
Quoted text here. Click to load it

What you're suggesting sounds very good, I'm still kind of new to
linux, so can you recommend a good way to get the actual memory size of
a process/total size of all like processes (httpd)?

Quoted text here. Click to load it

We have the Zend Studio so we can profile the PHP, which would help us
find the bottlenecks there and in the MySQL queries. I'll take a look
at the docs to figure out how to look for slow queries in the system
other than using Zend Studio. We have had problems in the past where my
DBA guy hasn't indexed database tables, which has really slowed things

Quoted text here. Click to load it

We aren't using a PHP accelerator unfortunately, though I'd like to. Do
you recommend one? We are caching the output of the PHP code so that
what gets delivered to the customer is mostly static content, except
for a few runtime things that have to be performed by PHP every page

Quoted text here. Click to load it

The load balancer seems to have very good performance, my testing
revealed nearly linear capacity increases with additional identical
servers. This showed me that the load balancer introduced very little
processing overhead. We're using the Piranha load balancer from RedHat,
which is an offshoot of the Linux Virtual Server project. We didn't buy
a Cisco or Microsoft load balancer thing. :)

Quoted text here. Click to load it

Again, thanks for your feedback, I really appreciate it. I'd also like
to see what you might have to say about what I've written above.


Site Timeline