Open Litespeed: Tuning Server Settings Part 1

OpenLiteSpeed uses an GUI based Admin Console and under Server tab there are sub-tabs for Server, Tuning and External App sections. If you’re like me, you’ll eventually want to tweak and tune OpenLiteSpeed settings for better performance than what is available out of the box. Below, I’ll outline a few of the more commonly tweaked OpenLiteSpeed settings based on my experience using LiteSpeed Enterprise server.

The Admin Console has alot of tooltip help pop ups explaining in detail what the options are for as well. As such, for some of the settings below, check out the screenshot for full explanation.

Number of Workers

Sets number of worker processes OpenLiteSpeed will use. OpenLiteSpeed supports multi-cores but seems setting limits to 16 ? What about Dual Xeon E5-26xx Octa-Core based servers which would have a total of 16 cpu cores and 32 cpu threads ? By Default, the option is set to ‘Not set’ which defaults to using only 1 cpu core. You may want to set this value’s maximum to no more than the number of cpu cores/threads your server supports. But ideally you should leave some cpu threads to be available to server LSPHP PHP processes if PHP is served from same web server.

Memory I/O Buffer

Use Client IP in header

The equivalent of Apache mod_rpaf module’s purpose. You’ll want to enable this option if you run a proxy of any kind in front of OpenLiteSpeed i.e. Varnish Cache, Haproxy, Cloudflare, Incapsula or any Anti-DDOS cloud based proxy. This setting will allow your web server and web apps see the real user’s IP address instead of the IP address of the front end proxy server(s).

Index files

Equivalent to Apache DirectoryIndex. Seems out of box only sets up index.html. So you may want to add index.php to the list as well.

Smart Keep-Alive

I/O Event Dispatcher

Max Cached Small File Size and Total Small File Cache Size

Max MMAP File Size and Total MMAP Cache Size

External APP lsphp5 > Max Idle Time

Normally I leave it at -1 especially if using PHP opcode cachers like APC Cache or Xcache.

External APP lsphp5 > Memory Soft & Hard Limit

Note: These are PHP memory limits which also include PHP opcode cacher’s allocated memory into the equation. For instance, if you set APC Cache or Xcache to use 128MB of memory and have php.ini memory_limit set at 128MB or 256MB and constantly run into memory exhausted or out of memory php errors, you may need to raise Memory Soft and Hard limits here as well to take into account the php opcoder’s allocated memory. Otherwise, you may get 503 error messages and/or out of memory php errors.

Here’s a simple php script to test your real memory limit under OpenLiteSpeed. Just set $memlimit to what your php.ini memory_limit is configured (i.e. 256MB) for and run it to check if php can use upto to the memory limit amount of memory.

$memlimit = 256;
print 'Expected memory limit ' . $memlimit . 'MB <br />';
$memory_mb = round(memory_get_usage() /1024/1024 , 2);
print 'Base  -> ' . memory_get_usage() . ' (' . $memory_mb . ' MB)' . ' <br /> &ensp; <br />';
$pattern = str_repeat("0123456789", 1000);
$fill = str_repeat($pattern, 1);
$counter = 1000;
while ( $counter <= 27000 ) {
    $memory_mb = round(memory_get_usage() /1024/1024 , 2);
    print 'Clear -> ' . memory_get_usage() . ' (' . $memory_mb . ' MB) <br />';
    print $counter . ' x 10000 chars -> ' ;
    $fill = str_repeat($pattern, $counter);
    $memory_mb = round(memory_get_usage() /1024/1024 , 2);
    print  memory_get_usage() . ' (' . $memory_mb . ' MB)'. ' [' . $memory_pct = round($memory_mb /
$memlimit *100 , 1) . ' percent]<br />';
    $counter = $counter + 500;
print '<br />If you can see this, the server can allocate something close to 256mb';

Here’s sample output of the script in which php ran out of memory before php.ini set memory_imit of 256MB. This is due to OpenLiteSpeed’s External APP > Soft and Hard memory limits in place and fact I allocated 256MB alone for APC Cache which already ate into the Soft and Hard memory limits.

Expected memory limit 256MB
Base -> 93616 (0.09 MB)
Clear -> 103912 (0.1 MB)
1000 x 10000 chars -> 10104072 (9.64 MB) [15.1 percent]
Clear -> 104096 (0.1 MB)
1500 x 10000 chars -> 15104256 (14.4 MB) [22.5 percent]
Clear -> 104096 (0.1 MB)
2000 x 10000 chars -> 20104256 (19.17 MB) [30 percent]
Clear -> 104096 (0.1 MB)
2500 x 10000 chars -> 25104256 (23.94 MB) [37.4 percent]
Clear -> 104096 (0.1 MB)
3000 x 10000 chars -> 30104256 (28.71 MB) [44.9 percent]
Clear -> 104096 (0.1 MB)
3500 x 10000 chars -> 35104256 (33.48 MB) [52.3 percent]
Clear -> 104096 (0.1 MB)
4000 x 10000 chars ->
Fatal error: Out of memory (allocated 262144) (tried to allocate 40000001 bytes) in /home/username/public_html/phpmemory.php on line 19

External APP lsphp5 > Process Soft & Hard Limit


MaxCDN Site Acceleration

Get Cost Effective Content Delivery
Unbeatable speed, stats, & price

No Comments


  1. Open Litespeed: Tuning Server Settings Part 2 | - [...] OpenLiteSpeed Tuning Server Settings Part 1, I outlined some of the most common settings I usually tweak. Well in …
Add Comment Register

Leave a Comment