slow result

#1
Hi,

My issue will be long to explain but I will try to put as much information as it is possible.

Here are my system :

CPU 3 Ghz (no HT no dual core) 32 bit
2G ram

@@ OS and Web Server @@
I'm running FreeBSD 6.1 with Litespeed 2.2.1 (the latest for FreeBSD)


@@ PHP @@
php -v
PHP 5.1.6 (cli) (built: Nov 2 2006 23:10:09)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies


@@ MySQL @@
mysql Ver 14.12 Distrib 5.0.24a, for portbld-freebsd6.1 (i386) using 5.0

@@ Litespeed @@
I have the latest version for FreeBSD of enterprise litespeed 1 CPU lease 1 Year. Currently running on the temp license the time to receive my full license.

@@ LiteSpeed Config file @@
<?xml version="1.0" encoding="UTF-8"?>
<httpServerConfig>
<serverName>xxxx:80</serverName>
<user>www</user>
<group>www</group>
<priority>-5</priority>
<chrootPath>/</chrootPath>
<enableChroot>0</enableChroot>
<inMemBufSize>300M</inMemBufSize>
<swappingDir>/tmp/lshttpd/swap</swappingDir>
<autoRestart>1</autoRestart>
<autoFix503>1</autoFix503>
<mime>$SERVER_ROOT/conf/mime.properties</mime>
<showVersionNumber>0</showVersionNumber>
<adminEmails>xxxxxx</adminEmails>
<adminRoot>$SERVER_ROOT/admin/</adminRoot>
<logging>
<log>
<fileName>$SERVER_ROOT/logs/error.log</fileName>
<logLevel>DEBUG</logLevel>
<debugLevel>0</debugLevel>
<rollingSize>10M</rollingSize>
<enableStderrLog>1</enableStderrLog>
</log>
<accessLog>
<fileName>$SERVER_ROOT/logs/access.log</fileName>
<rollingSize>10M</rollingSize>
<keepDays>30</keepDays>
<compressArchive>0</compressArchive>
</accessLog>
</logging>
<indexFiles>index.html,index.html.var,index.php,index.php3,index.phps</indexFiles>
<htAccess>
<allowOverride>2</allowOverride>
<accessFileName>.htaccess</accessFileName>
</htAccess>
<expires>
<enableExpires>1</enableExpires>
<expiresDefault></expiresDefault>
<expiresByType>image/*=A604800, text/css=A604800, application/x-javascript=A604800</expiresByType>
</expires>
<tuning>
<maxConnections>1024</maxConnections>
<maxSSLConnections>200</maxSSLConnections>
<connTimeout>75</connTimeout>
<maxKeepAliveReq>1000</maxKeepAliveReq>
<smartKeepAlive>1</smartKeepAlive>
<keepAliveTimeout>5</keepAliveTimeout>
<sndBufSize>0</sndBufSize>
<rcvBufSize>0</rcvBufSize>
<eventDispatcher>kqueue</eventDispatcher>
<maxCachedFileSize>4096</maxCachedFileSize>
<totalInMemCacheSize>20M</totalInMemCacheSize>
<maxMMapFileSize>256K</maxMMapFileSize>
<totalMMapCacheSize>40M</totalMMapCacheSize>
<useSendfile>1</useSendfile>
<SSLCryptoDevice>null</SSLCryptoDevice>
<maxReqURLLen>4096</maxReqURLLen>
<maxReqHeaderSize>8192</maxReqHeaderSize>
<maxReqBodySize>10M</maxReqBodySize>
<maxDynRespHeaderSize>4K</maxDynRespHeaderSize>
<maxDynRespSize>1M</maxDynRespSize>
<enableGzipCompress>1</enableGzipCompress>
<enableDynGzipCompress>1</enableDynGzipCompress>
<gzipCompressLevel>5</gzipCompressLevel>
<compressibleTypes>text/html</compressibleTypes>
<gzipAutoUpdateStatic>1</gzipAutoUpdateStatic>
<gzipStaticCompressLevel>6</gzipStaticCompressLevel>
<gzipMaxFileSize>1M</gzipMaxFileSize>
<gzipMinFileSize>300</gzipMinFileSize>
</tuning>
<security>
<fileAccessControl>
<followSymbolLink>1</followSymbolLink>
<checkSymbolLink>0</checkSymbolLink>
<requiredPermissionMask>000</requiredPermissionMask>
<restrictedPermissionMask>000</restrictedPermissionMask>
</fileAccessControl>
<perClientConnLimit>
<staticReqPerSec>0</staticReqPerSec>
<dynReqPerSec>0</dynReqPerSec>
<outBandwidth>0</outBandwidth>
<inBandwidth>0</inBandwidth>
<softLimit>10</softLimit>
<hardLimit>1000</hardLimit>
<gracePeriod>15</gracePeriod>
<banPeriod>300</banPeriod>
</perClientConnLimit>
<CGIRLimit>
<maxCGIInstances>20</maxCGIInstances>
<minUID>11</minUID>
<minGID>10</minGID>
<priority>0</priority>
<CPUSoftLimit>10</CPUSoftLimit>
<CPUHardLimit>50</CPUHardLimit>
<memSoftLimit>60M</memSoftLimit>
<memHardLimit>70M</memHardLimit>
<procSoftLimit>400</procSoftLimit>
<procHardLimit>450</procHardLimit>
</CGIRLimit>
<accessDenyDir>
<dir>/</dir>
<dir>/etc/*</dir>
<dir>/dev/*</dir>
<dir>$SERVER_ROOT/conf/*</dir>
<dir>$SERVER_ROOT/admin/conf/*</dir>
</accessDenyDir>
<accessControl>
<allow>ALL</allow>
<deny></deny>
</accessControl>
</security>
<extProcessorList>
<extProcessor>
<type>lsapi</type>
<name>phpLsapi</name>
<address>uds://tmp/lshttpd/lsphp.sock</address>
<maxConns>20</maxConns>
<env>PHP_LSAPI_MAX_REQUESTS=500</env>
<initTimeout>60</initTimeout>
<retryTimeout>0</retryTimeout>
<respBuffer>0</respBuffer>
<autoStart>1</autoStart>
<path>$SERVER_ROOT/fcgi-bin/lsphp</path>
<backlog>100</backlog>
<instances>20</instances>
<priority>0</priority>
</extProcessor>
</extProcessorList>
<scriptHandlerList>
<scriptHandler>
<suffix>php,php3,php4,php5,phps</suffix>
<type>lsapi</type>
<handler>phpLsapi</handler>
</scriptHandler>
</scriptHandlerList>
<virtualHostList>
<virtualHost>
<name>ApacheMain</name>
<vhRoot>/usr/home/www/default/html/</vhRoot>
<configFile>$SERVER_ROOT/conf/ApacheMain.xml</configFile>
</virtualHost>
<virtualHost>
<name>xxxxxx</name>
<vhRoot>/usr/home/www/xxxxx/html/</vhRoot>
<configFile>$SERVER_ROOT/conf/xxxxxx.xml</configFile>
</virtualHost>
</virtualHostList>
<listenerList>
<listener>
<name>*:443</name>
<address>*:443</address>
<binding></binding>
<secure>1</secure>
<vhostMapList>
<vhostMap>
<vhost>www.example.com:443</vhost>
<domain>www.example.com:443, *</domain>
</vhostMap>
</vhostMapList>
<keyFile>/usr/local/etc/apache2/ssl.key/server.key</keyFile>
<certFile>/usr/local/etc/apache2/ssl.crt/server.crt</certFile>
<ciphers>ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL</ciphers>
</listener>
<listener>
<name>xxxxxx:80</name>
<address>xxxxxx:80</address>
<binding></binding>
<secure></secure>
<vhostMapList>
<vhostMap>
<vhost>xxxxxxxx</vhost>
<domain>xxxxxx, *</domain>
</vhostMap>
</vhostMapList>
<keyFile></keyFile>
<certFile></certFile>
<ciphers></ciphers>
</listener>
<listener>
<name>Default</name>
<address>*:80</address>
<binding></binding>
<secure>0</secure>
<vhostMapList>
<vhostMap>
<vhost>Example</vhost>
<domain>*</domain>
</vhostMap>
</vhostMapList>
<keyFile></keyFile>
<certFile></certFile>
<ciphers></ciphers>
</listener>
</listenerList>
</httpServerConfig>


@@ Vhost config file @@

<?xml version="1.0" encoding="UTF-8"?>
<virtualHostConfig>
<docRoot>/usr/home/www/xxxxxx/html/</docRoot>
<enableGzip>1</enableGzip>
<adminEmails></adminEmails>
<logging>
<log>
<useServer>0</useServer>
<fileName>/usr/home/www/xxxxx/logs/error_log</fileName>
<logLevel>INFO</logLevel>
<rollingSize>20</rollingSize>
</log>
<accessLog>
<useServer>0</useServer>
<fileName>/home/www/xxxxxx/logs/access.log</fileName>
<pipedLogger></pipedLogger>
<logHeaders>7</logHeaders>
<rollingSize>20</rollingSize>
<keepDays>10</keepDays>
<bytesLog></bytesLog>
<compressArchive>1</compressArchive>
</accessLog>
</logging>
<expires>
<enableExpires></enableExpires>
<expiresDefault></expiresDefault>
</expires>
<contextList>
<context>
<type>cgi</type>
<uri>/cgi-bin/</uri>
<location>/usr/home/www/xxxxx/cgi-bin/</location>
<accessControl>
</accessControl>
<rewrite>
</rewrite>
</context>
</contextList>
<rewrite>
<rules></rules>
</rewrite>
<awstats>
<updateMode>2</updateMode>
<workingDir>/home/www/xxxxxx/html/xxxxx/stats</workingDir>
<awstatsURI>/xxxxx/stats/</awstatsURI>
<siteDomain>xxxxxxx</siteDomain>
<siteAliases>xxxxxxx</siteAliases>
<updateInterval>3600</updateInterval>
<updateOffset></updateOffset>
<securedConn>0</securedConn>
<realm></realm>
</awstats>
</virtualHostConfig>
 
#2
@@ System logs /var/log/messages @@

Nov 2 21:11:57 Navy4 kernel: pid 50032 (httpd), uid 80: exited on signal 6
Nov 2 21:11:57 Navy4 kernel: pid 49997 (httpd), uid 80: exited on signal 6
Nov 2 21:11:57 Navy4 kernel: pid 50067 (httpd), uid 80: exited on signal 6
Nov 2 21:11:57 Navy4 kernel: pid 50235 (httpd), uid 80: exited on signal 6
Nov 2 21:11:57 Navy4 kernel: pid 50060 (httpd), uid 80: exited on signal 6
Nov 2 22:11:09 Navy4 kernel: pid 69743 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 22:12:01 Navy4 kernel: pid 79646 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 22:18:49 Navy4 kernel: pid 13817 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 22:19:55 Navy4 kernel: pid 23858 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 22:22:59 Navy4 kernel: pid 60002 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 23:33:33 Navy4 kernel: pid 65316 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 2 23:50:33 Navy4 last message repeated 5 times
Nov 3 00:07:20 Navy4 kernel: pid 4515 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 3 00:13:51 Navy4 last message repeated 5 times
Nov 3 00:58:10 Navy4 kernel: pid 23588 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)
Nov 3 01:30:07 Navy4 kernel: pid 23866 (lshttpd.2.2.2), uid 80: exited on signal 11 (core dumped)


I compiled fscgi/lsphp from /usr/ports/lang/php5/work/php-5.1.6/sapi/litespeed as per the doc.

copy the litespeed php sapi source and copy it to the php source/sapi folder.
cd phpsource/ && ./configure --with-litespeed && make
cp phpsource/sapi/php litespeedroot/fscgi/lsphp



Symptom :

PHP is working but it is slow. I changed the timeout value to 25 instead of 75 but i had to put it back to 75 since i received timeout error.

I can see in my process list more than 20 lsphp process and 3-4 lshttpd

When I start lshttpd from litespeedroot/bin/lshttpd start or lshttpd.2.2.2 start it works fine.

When i stop lshttpd from litespeedroot/lshttpd stop or lshttpd.2.2.2 stop it return an error.
./lshttpd stop
[OK] Your trial license key will expire in 30 days!
[ERROR] LiteSpeed Web Server is running!

PHP has been installed from the ports.

php -m
[PHP Modules]
bcmath
bz2
ctype
curl
date
dom
exif
fileinfo
ftp
gd
gettext
iconv
libxml
mcrypt
mhash
mysql
openssl
pcre
PDO
posix
Reflection
session
SimpleXML
sockets
SPL
SQLite
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

I use the kqueue module and litespeed accelerator (i think not sure)
I activate sendfile () module too.
Currently while testing I put the exact same concurrent connection as our apache setup. While apache were using all the RAM with 1024, litespeed used only 1.1G of Ram keeping 900M for more client. (this include mysql, php, webserver).

The Site has 50 000 member registered (will grow up to 150 000) and concurrent user were between 400-1024 (limit of apache for our server with 2G of ram before it swap too much)

We would like to reach 10 000 concurrent member with php and litespeed and mysql. (AT a minimum much more than 1024).


Right now since it is really slow, we are really deceived. But I think it's probably something i did or didn't who make it slow. I would greatly appreciate all help to get this server running and optimized. Since we paid for the license we would greatly appreciate to beat our apache setup.
 
#4
Hi,

Yes this is what I have.


By the way, I found why it was slow.

the php module was cap with 20 connections. I grow it to 100 and now it cans handle the load. I will test tomorrow on a busy hour to find out what it cans handle :)

If you have any suggest following my spec to optimized my setup, feel free to guide me.


Thank you,
 
#6
Hi,

Yesterday night, we had a load of about 70 request second and the server fall on his knee. It used all the ram and swap, Our apache setup did better at this time. I just shutdown litespeed and put apache back.

Any help is welcome. In fact, we would really need a quick start guide with someone experienced.


Thank you,
 

mistwang

LiteSpeed Staff
#7
The command to stop lshttpd is "lswsctrl stop" not "lshttpd stop".

Is that for a vbulletin board?
You probably set "max connection" for lsphp module too high. usually, 20 is enough for most setup, unless your php scripts take long time to process.

First thing first is to make sure a php opcode cache work properly in your setup, usually, something will be added to a phpinfo page when it works, like APC or eaccelerator.

Usually, php 4.4.4 has better performance than php 5, so if your PHP code work with php 4, use php 4 instead. Make sure all required php modules has been compile into the binary.

We will help you here to tune the web server as much as we can. Also we have one-time installation service $149 to help people setup and tune their LSWS installation for their web site, if you really need help, please that a consideration if you have a hard time to tune it by yourself. :)
 
#8
Hi,

swsctrl stop give me the same error.


The one-time installation service $149 would be welcome, but I will give myself 7 days to try tuning it.


I will install php4 and will diminish the number of lsphp max connect. I will give the url for phpinfo in my next post.


Thank you,
 
#11
Hi,

eaccelerator is install now.

I will create you an admin account as you can review my setting and maybe optimise it a little more.


Our goal like i said is to provide 150 000 customers nearly. We currently have 50 000 customers. We are constantly with 1000 user at the same time with average of 80 request seconds.


Let me know how i can communicate with you for the admin account.


Thank you,
 
#12
Hi,

I found that i have as much request processing as I have php process.


Plain SSL Max Idle Plain SSL
In Out In Out Used Avail Used Avail
22 94 0 0 2,000 14 77 1,923 0 400

Request Rate
Scope Requests in Processing Request/Second
Server 63 55
www.ixxxxxx 63 54
ApacheMain 0 0
_AdminVHost 0 1

External Apps
Scope Type Name Max CONN Eff Max Pool In Use Idle WaitQ Req/Sec
Server LSAPI phpLsapi 200 200 200 60 140 0 50


Does it means, each connect will use one phpLsapi connector ?



Thank you,
 
Last edited:

mistwang

LiteSpeed Staff
#13
Do not over-tune phpLsapi to start too many php processes, LSWS can pipe-line requests to PHP backend when there are more concurrent requests than number of PHP process. 200 should be the maximum, I recommend you try 50-100 first. Running too many PHP process may use too much memory and slow down the whole server.
 

xing

LiteSpeed Staff
#14
For some perspective, PHP process/children value of 20-40 is more than enough to handle millions of php pages per day provided your code is properly tuned. Setting PHP processes to a high value only if your backend/database can support that many concurrent connections and still be fast. There is no point setting PHP process pool to 100 if your mysql server will die at 50 concurrent connections.
 
#15
Currently, my MySQL database is running on the same server as my litespeed daemon. With apache, i setuped my mysql to 500 connections up to 1024. it were working but I had few error about mysql cannot connect. with 100 as value for lsapiphp i had no error of this kind. Than it should be fine for now.
 

xing

LiteSpeed Staff
#16
For performance reasons, you need to increase "thread_cache" entry for mysql config, my.cnf, and decrease mysql's max_connection item. Unless you have a super fast disk i/o on quad core server with no table/db locking, 500 mysql connections will instantly bring your server to its knees.
 
Top