How to Optimize OpenLiteSpeed Configuration in httpd_config.conf

OpenLiteSpeed is a lightweight and efficient web server, but its default configuration may not be optimized for high-performance environments. Properly tuning httpd_config.conf can improve speed, reduce latency, and optimize resource usage.


1. Adjusting the Number of HTTP Workers

The httpdWorkers parameter defines how many processes will handle simultaneous requests. By default, it is usually set to 1, which is insufficient for multi-core servers.

Recommendation

Set httpdWorkers to a value equal to half the available processor cores.

Example in httpd_config.conf

httpdWorkers 4

If the server has 8 cores, the recommended value would be 4. However, we can generally set it to match the number of cores (vCPUs or cores) or even double (16), though this may slightly increase the server load.

Via WebAdmin Console

  1. Go to Server Configuration → General Settings
  2. Modify Number of HTTP Workers and restart the server.

2. Optimizing Connection Management

Connection performance affects the server’s ability to handle simultaneous traffic without degradation.

Recommendations

  • Enable Keep-Alive to reduce the overhead of repeated connections.
  • Set maxKeepAliveReq to 10,000 to allow more requests before closing the connection.
  • Set keepAliveTimeout to 5 seconds to avoid unnecessary connections.

Example in httpd_config.conf

smartKeepAlive 1
maxKeepAliveReq 10000
keepAliveTimeout 5

Via WebAdmin Console

  1. Go to Server Configuration → Tuning
  2. Adjust the recommended values.

3. Enhancing Memory Cache Usage

Cache settings impact response speed by reducing disk access.

Recommendations

  • Increase inMemBufSize to 120M to improve in-memory storage.
  • Raise maxCachedFileSize to 16,384 KB to allow caching larger files.
  • Double totalInMemCacheSize to 40M to expand memory cache.
  • Increase maxMMapFileSize to 512K and totalMMapCacheSize to 80M for better memory-mapped file handling.

Example in httpd_config.conf

inMemBufSize 120M
maxCachedFileSize 16384
totalInMemCacheSize 40M
maxMMapFileSize 512K
totalMMapCacheSize 80M

Via WebAdmin Console

  1. Go to Server Configuration → Cache
  2. Apply the recommended settings and save changes.

4. Optimizing PHP with LSAPI

OpenLiteSpeed uses LSAPI to handle PHP scripts more efficiently than FastCGI.

Recommendations

  • Increase maxConns to 50 to support more simultaneous PHP connections.
  • Raise PHP_LSAPI_CHILDREN to 50 to allow more concurrent PHP processes.
  • Adjust memory and process limits for better performance.

Example in httpd_config.conf

extProcessor lsphp {
  type lsapi
  maxConns 50
  env PHP_LSAPI_CHILDREN=50
  memSoftLimit 900M
  memHardLimit 1.000M
  procSoftLimit 1.000
  procHardLimit 1.200
}

Via WebAdmin Console

  1. Go to Server Configuration → External App
  2. Edit lsphp and adjust the recommended values.

5. Improving Network Performance

Optimizing data transfer can speed up site load times.

Recommendations

  • Increase sndBufSize and rcvBufSize to 65,535 bytes to enhance data transmission.
  • Enable Sendfile (useSendfile) to improve static file performance.

Example in httpd_config.conf

sndBufSize 65535
rcvBufSize 65535
useSendfile 1

Via WebAdmin Console

  1. Go to Server Configuration → Tuning
  2. Adjust the recommended values.

6. Enabling and Configuring GZIP Compression

GZIP compression reduces file sizes sent to clients, speeding up page loads.

Recommendations

  • Enable enableGzipCompress and enableDynGzipCompress to compress both static and dynamic content.
  • Set gzipCompressLevel to 6 for a balance between compression and speed.
  • Define compressibleTypes to include HTML, CSS, and JavaScript files.

Example in httpd_config.conf

enableGzipCompress 1
enableDynGzipCompress 1
gzipCompressLevel 6
compressibleTypes text/html text/css application/javascript

Via WebAdmin Console

  1. Go to Server Configuration → GZIP
  2. Enable and configure the recommended settings.

7. Configuring Caching for WordPress or CMS

If using WordPress, Joomla, or Drupal, enabling dynamic caching can reduce server load.

Steps in OpenLiteSpeed

  1. Install the LiteSpeed Cache Plugin in the CMS.
  2. In WebAdmin Console, go to Cache → Server Cache and enable it.
  3. Configure cache settings for pages, images, and CSS/JS files.

Conclusion

With these optimizations in httpd_config.conf, OpenLiteSpeed will handle more traffic, reduce response times, and improve server efficiency. It is advisable to test each change and monitor performance using tools like GTmetrix, PageSpeed Insights, or HTOP.

Every server is different, so testing before deploying changes in production is essential.

Scroll to Top