Apache 2.2.3 + php5 + PostgreSQL 8.0.4
Teo Labsys
teo at labsys.biz
Tue Aug 22 08:44:09 UTC 2006
Hi everybody,
I hope it's the right place for problem ! Please let's me know if i'm
wring mainling list.
I installed Apache/2.2.3 + PHP5 (used in module with apache) on a
FreeBSD 5.4-RELEASE for an intranet website, and I don't know why my
server is sometimes very Slow.
At the beginning when i start Apache the top command give me :
last pid: 16280; load averages: 0.00, 0.01,
0.00 up 0+19:25:58 10:11:08
49 processes: 1 running, 47 sleeping, 1 zombie
CPU states: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt,
100% idle
Mem: 57M Active, 249M Inact, 111M Wired, 24K Cache, 112M Buf, 1586M
Free
Swap: 994M Total, 994M Free
PID UID PRI NICE SIZE RES STATE TIME WCPU CPU
COMMAND
16154 80 4 0 14652K 12008K accept 0:00 0.00% 0.00%
httpd
16155 80 4 0 14776K 12148K accept 0:00 0.00% 0.00%
httpd
16159 80 4 0 14812K 12144K accept 0:00 0.00% 0.00%
httpd
16157 80 4 0 14812K 12140K accept 0:00 0.00% 0.00%
httpd
16171 80 4 0 14752K 12104K accept 0:00 0.00% 0.00%
httpd
16158 80 4 0 14812K 12144K accept 0:00 0.00% 0.00%
httpd
16156 80 4 0 14812K 12120K accept 0:00 0.00% 0.00%
httpd
16163 80 4 0 14540K 11896K accept 0:00 0.00% 0.00%
httpd
16161 80 4 0 14784K 12116K accept 0:00 0.00% 0.00%
httpd
16162 80 4 0 14752K 12116K accept 0:00 0.00% 0.00%
httpd
16160 80 4 0 14804K 12116K accept 0:00 0.00% 0.00%
httpd
16229 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16230 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16231 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
and after 1 or 2 minutes using my website the result is
last pid: 16557; load averages: 0.16, 0.04,
0.01 up 0+19:29:05 10:14:15
64 processes: 1 running, 62 sleeping, 1 zombie
CPU states: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt,
100% idle
Mem: 68M Active, 249M Inact, 111M Wired, 24K Cache, 112M Buf, 1574M
Free
Swap: 994M Total, 994M Free
PID UID PRI NICE SIZE RES STATE TIME WCPU CPU
COMMAND
16158 80 20 0 14812K 12164K lockf 0:00 0.00% 0.00%
httpd
16154 80 20 0 14836K 12204K lockf 0:00 0.00% 0.00%
httpd
16157 80 20 0 14860K 12200K lockf 0:00 0.00% 0.00%
httpd
16155 80 20 0 14844K 12224K lockf 0:00 0.00% 0.00%
httpd
16171 80 20 0 14848K 12216K lockf 0:00 0.00% 0.00%
httpd
16159 80 20 0 14812K 12152K lockf 0:00 0.00% 0.00%
httpd
16161 80 20 0 14680K 12032K lockf 0:00 0.00% 0.00%
httpd
16163 80 20 0 14844K 12212K lockf 0:00 0.00% 0.00%
httpd
16162 80 20 0 14552K 11932K lockf 0:00 0.00% 0.00%
httpd
16156 80 20 0 14812K 12148K lockf 0:00 0.00% 0.00%
httpd
16231 80 20 0 14820K 12148K lockf 0:00 0.00% 0.00%
httpd
16229 80 20 0 14812K 12144K lockf 0:00 0.00% 0.00%
httpd
16230 80 20 0 14812K 12144K lockf 0:00 0.00% 0.00%
httpd
16160 80 96 0 14860K 12200K select 0:00 0.00% 0.00%
httpd
16543 80 20 0 13252K 10460K lockf 0:00 0.00% 0.00%
httpd
16545 80 20 0 13252K 10460K lockf 0:00 0.00% 0.00%
httpd
16547 80 20 0 13252K 10460K lockf 0:00 0.00% 0.00%
httpd
16544 80 4 0 13040K 10244K accept 0:00 0.00% 0.00%
httpd
16546 80 4 0 13040K 10244K accept 0:00 0.00% 0.00%
httpd
16550 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16552 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16551 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16554 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16549 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16548 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16556 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16553 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16557 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
16555 80 4 0 12952K 10188K accept 0:00 0.00% 0.00%
httpd
At the same time the command iostat give me :
tty ad4 ad6
ar0 cpu
tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy
in id
0 11 0.52 0 0.00 0.52 0 0.00 20.76 2 0.03 0 0 0
0 100
0 229 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 0
0 100
0 77 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 0
0 100
0 77 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 26 0 0
0 74
0 76 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 1
0 99
0 76 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 4 0 0
0 96
0 76 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 21 0 2
0 77
0 76 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 0
0 100
0 77 0.00 0 0.00 0.00 0 0.00 6.00 4 0.02 0 0 0
0 100
0 77 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 0
0 100
0 77 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 0 0 0
0 100
and netstat -m
91 mbufs in use
86/25600 mbuf clusters in use (current/max)
0/3/6656 sfbufs in use (current/peak/max)
194 KBytes allocated to network
0 requests for sfbufs denied
0 requests for sfbufs delayed
0 requests for I/O initiated by sendfile
0 calls to protocol drain routines
The server never crash and I have no timeout. It give me everytime the
answer for my query but it's very slow when State is Lockf.
So I've tried to install the webserver on a FreeBSD 6.0 or 6.1, on
different hardware server and different version of apache with the
same configuration but STATE is still lockf and very slow.
I've read this answer from google newsgroups but i think is an old on
:
" They're using a lockfile around the select() call on the
accept'ing
socket.
Basically, when apache is listening on multiple IPs/ports it
needs
to select() on several filedescriptors. The problem (under
FreeBSD
at least) is that whenever you have some process select()'ing
on
a descriptor and another process wants to do the same you get
a
"select collision", a collision requires that all processes
waiting
on the same select channel wake up then reassert thier desire
to
select. So... if you have 500 apache processes select()'ing
and
one wakes up to service a request, finished serving, then goes
to
select again, all the rest (499) have to wake up and reaffirm
thier
desire to select().
This doesn't scale very well at all.
What apache does to fix this, is only allow one process to
select()
at any given time by keeping a lockf lock on a file while
waiting
in select(). When select returns it releases the lock and
this
allows another process to enter the select() call.
It's still not as efficient because (under FreeBSD) I think
this
still can wakeup each process blocked on the lock, but it's
still
an order of magnitude better than having select() collisions.
If you want to get it the most optimal, try to not specify
individual
IPs for apache to bind to. If you can tell apache to bind to
only
port 80 on "*" (all IPs) you'll get much better performance
because
then apache no longer needs to select, it only needs to
accept()
on a single socket which is the most optimal thing to do.
You'll know if you've got the single select working if you see
the
majority of the apache processes in "accept" rather than
"lockf".
You might also want to check out using accept filters to get
even
more performance out of apache, see the accf_http manpage and
check
the apache docs for the compile time stuff you need to do to
enable
this."
Apache configuration
httpd-default.conf
HostnameLookups Off
KeepAlive Off
Timeout 300
httpd-mpm.conf
<IfModule !mpm_netware_module>
PidFile /var/run/httpd.pid
</IfModule>
<IfModule !mpm_winnt_module>
<IfModule !mpm_netware_module>
LockFile /var/log/accept.lock
</IfModule>
</IfModule>
<IfModule mpm_prefork_module>
StartServers 10
MinSpareServers 10
MaxSpareServers 50
MaxClients 150
MaxRequestsPerChild 5000
</IfModule>
httpd-vhosts.conf
I've tried with vhosts by name but like i use ssl I've changed for IP
ALIASING, But the result is the same.
NameVirtualHost *:443
<VirtualHost 192.168.253.21:443>
ServerName xxx
ServerAlias xxx
ServerAdmin xxx at xxx
DocumentRoot xxx
SSLEngine on
SSLCertificateFile xxx
SSLCertificateKeyFile xxx
ErrorLog xx
TransferLog xxxx
</VirtualHost>
<VirtualHost 192.168.253.22:443>
idem as below
</VirtualHost>
<VirtualHost 192.168.253.23:443>
idem as below
</VirtualHost>
Do you know what i could do ?
thanks,
--
teo
Gsm: +33 (0)6 29 79 74 64
Skype (FR): 0870 444 139
[1]teo at labsys.biz.com
[2]My status
References
1. mailto:teo at labsys.biz.com
2. skype:lacour_a?call
More information about the freebsd-apache
mailing list