Jump to content


Photo

First request slow, next fast.


  • Please log in to reply
7 replies to this topic

#1 TheUndefined

TheUndefined
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 October 2006 - 01:17 PM

Hi,
In summary: The first request i make to the server is slow, the next requests are fast.

Some context:
I'm running Apache2 on Debian.
There are a couple of Named VirtualHosts running on the server.
There is no Listener line in the conf, so it's listening on both (2 IP's) its interfaces on port 80.
HostnameLookups is off in the conf file.
There is a "NameVirtualHost [first-IP]" in the conf.
All the VirtualHosts are named with an IP address to prevent DNS problems.
All VirtuaHosts have a ServerName entry to prevent DNS problems.
Not using SSL.

What do i already know?
The problem gets worse (the initial wait time) when the server gets a heavyer load.
While the initial connection is waiting i can see the size of the header data in the Recv-Q field when doing netstat.
There is some reverse DNS resolving being done, but not with every request, don't know what's causing it.
There are no hostnames stored in the log files, only IP addresses.
There is no relevant information in the error log.

What i'd like to know
A way to make sure/exclude that it's a DNS problem.
Other hypotheses on what might be causing this.
Things i should look after and include here.

I'm already debugging this quite a while now, and any help is seriously welcome.
I'll be checking the forum regulary to give quick replies.

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 03 October 2006 - 02:08 PM

Have you scanned through this? It sounds like "Process Creation" may be your area of concern. Can you watch and see how many children you have waiting/spawning?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 TheUndefined

TheUndefined
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 October 2006 - 02:14 PM

Thx for the reply, i'll read the site now.

Some info already:
I'm using prefork.c and MaxClients is set to 20 and there are 20 apache processes running as www-data and one as root, so that seems ok.

I'll post what i find out with the link you gave.

#4 TheUndefined

TheUndefined
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 October 2006 - 02:56 PM

I've followed your link and started using mod_status.
I saw that the 20 processes had the status "K" Keepalive (read).
The keepalive timeout is set to 15 seconds, i suppose this is causing that.
I've now set MaxClients to 100 and my problem is solved. Since there are enough connections available for new visitors.

I'll toy around a bit more with the keepalive and the MaxClient setting.
For anyone reading this with similar problems use mod_status! http://httpd.apache....mod_status.html

Any comments on what's a normal reaction to deal with this are still welcome, or is setting MaxClients to 100 an OK sollution?

#5 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 03 October 2006 - 04:52 PM

I'll check my configuration when I get home--I think I use a longer keep alive. Can most of the visitors on your site do what they need within 15 seconds?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#6 TheUndefined

TheUndefined
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 04 October 2006 - 07:15 AM

Can most of the visitors on your site do what they need within 15 seconds?


They probebly can't, well or, many can't. But if the keepAlive is "hijacking" my connections i can only put it higher if i can affort to set MaxClients to a relatively equaly high number. I've been googling a bit and a MaxClients of 250/300 doesn't seem all that uncommon. I'll try getting a view on how long visitors are staying and ajust the keepalive/MaxClients accordingly.

Still interested in what you've got set tho, but after that i think i'm closing this thread, SOLVED! :P thx alot

#7 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 06 October 2006 - 02:31 AM

Sorry for the delay. My keepalive is actually 15 as well. Keep in mind that this is my small, personal server. I used to get more traffic when I had a site running, but I've emptied everything out for an eventual redesign. I'm sure I'll need to tweak these when that time comes :)

<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 15
MaxRequestsPerChild 10000
</IfModule>
Timeout 300
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 15

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#8 TheUndefined

TheUndefined
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 06 October 2006 - 08:02 AM

Ok, thx for checking
I found out that setting MaxClients to 256 (need to recompile to go higher) isn't all that uncommon.
Apache manages it anyway, if it doesn't need 256 it doesn't open them. I might still put it to 150 or something, since the CPU is usualy at its limit then.

It can take 700 plain html requests per second now and 70 requests/second to a rather demanding php scirpt.
It's just CPU holding me back now, and that's ok with me, i can upgrade when needed.

So, i'm not gonna be following this thread anymore, thx for the help,
cya




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users