Optimising LiteSpeed Web Server: 30 seconds to less than 1 second
I chose to use the LiteSpeed Web Server over Apache HTTP Server because of the low memory footprint, as well as better performance for PHP. The GUI admin interface is also a big plus point, making it easy to administer the server.
As I was adding sites and working to bring them online, I realised that my sites were loading very slowly. I installed WP Tuner, a WordPress plugin, to try and see if the bottleneck was on LiteSpeed or MySQL. From the statistics, the delay occurred at the very first “Start” marker, taking 30 seconds, or even as long as 60 seconds. This wasn’t a problem with MySQL then. Next, I used top to monitor CPU and memory usage. It turns out that each PHP process took up 20MB of memory. With a VPS of only 128MB memory, and each site load using multiple processes, this was a huge problem. I was quickly running out of memory, and there was a lot of swapping. A quick search on Google, and I found this page of documentation, which states:
There are two ways to let PHP handle multiple requests concurrently, Server Managed Mode and Self Managed Mode. In Server Managed Mode, LiteSpeed web server dynamically spawn/stop PHP processes, in this mode “Instances” should match “Max Connections” configuration for PHP external application. To start PHP in Self Managed Mode, “Instances” should be set to “1″, while “LSAPI_CHILDREN” environment variable should be set to match the value of “Max Connections” and >1. Web Server will start one PHP process, this process will start/stop children PHP processes dynamically based on on demand. If “LSAPI_CHILDREN” <=1, PHP will be started in server managed mode.
Self Managed Mode is preferred because all PHP processes can share one shared memory block for the opcode cache.
are you using the free version of litespeed? If yes, is the “max connections” limited to 150 a problem for your site?
Sandro
9 Mar 10 at 9:41 am
@Sandro: Yes I’m using the free version of Litespeed. My sites are low traffic, and typically at most 10 to 20 connections are used simultaneously, so the 150 limit is not a problem for me.
Jon G
27 Apr 10 at 11:48 pm
Hi, I’m very interested in Linux but Im a Super Newbie and I’m having trouble deciding on the right distribution for me (Havent you heard this a million times?) anyway here is my problem, I need a distribution that can switch between reading and writing in English and Japanese (Japanese Language Support) with out restarting the operating system.
Emily N.
9 Jun 10 at 3:29 pm