Bobcares

CyberPanel-LiteSpeed Tuning | A Complete Guide

by | Oct 18, 2024

For optimal performance with LiteSpeed and CyberPanel, several tuning steps needed to be carried out related to caching, connection handling, PHP configurations, and other factors. As part of our CyberPanel Support, Bobcares provides answers to all of your questions.

Overview
  1. Tuning LiteSpeed within CyberPanel
  2. Main Areas in Tuning LiteSpeed within CyberPanel
  3. Monitoring and Benchmarking Tools
  4. Best Practices for Tuning
  5. Conclusion

Tuning LiteSpeed within CyberPanel

CyberPanel is a user-friendly control panel designed to manage LiteSpeed Web Server, streamlining tasks like website management, database handling, and server configurations. Tuning LiteSpeed within CyberPanel is crucial for enhancing server performance, speeding up page load times, and effectively managing traffic.

cyberpanel litespeed tuning

Main Areas in Tuning LiteSpeed within CyberPanel

A. LiteSpeed Cache Optimization

LiteSpeed Cache (LSCache) is a built-in feature of LiteSpeed Web Server designed to cache dynamic and static content efficiently. It is also vital for improving website performance and reducing load times. Here’s how to optimize it:

1. Enable LSCache Plugin for CMS:

  • Install and activate the LiteSpeed Cache Plugin for the CMS (like WordPress, Joomla, or Magento) directly from the application.
  • In CyberPanel, go to “Manage Website” > Select the domain > Enable LSCache.

2. Set Cache Rules:

  • Use the LSCache plugin or configure rules in the .htaccess file:
  • We must exclude specific URLs or user roles (e.g., admins) from caching.
  • Control Time to Live (TTL) settings for cached content.
  • Minify CSS, JS, and HTML files to reduce page load time.
  • Enable object caching with Redis or Memcached for faster database queries.

3. Browser Cache and Static File Optimization:

  • Enable browser cache to store static resources like CSS, JavaScript, and images locally for returning visitors.
  • Optimize static files using LSCache’s features or .htaccess rules:
  • Minification: Removes extra characters in CSS/JS.
  • Combination: Combines multiple CSS/JS files to reduce HTTP requests.
  • Lazy Load: Defers image loading until they are visible on the screen.
B. Adjust LiteSpeed Web Server Settings

Server settings play a crucial role in how efficiently the LiteSpeed server handles traffic. Access these settings through the LiteSpeed WebAdmin Console in CyberPanel.

1. Access LiteSpeed WebAdmin Console:

  • From CyberPanel, navigate to the dashboard and select the LiteSpeed WebAdmin Console.
  • Log in using the LiteSpeed credentials.

2. Tuning Server-Level Settings:

  • Max Connections: Set this to handle more simultaneous requests. For instance, a server with 2 GB RAM might set this to 500-800.
  • Memory Limit: Adjust based on the server’s needs. For resource-intensive apps, increase the limit.
  • CPU Affinity: Distribute load across multiple CPU cores if the server has more than one core.

3. Connection Handling:

  • Keep-Alive Timeout: Lower this to close idle connections faster, typically to 3-5 seconds.
  • Max Keep-Alive Requests: Set a limit (e.g., 100-150) to manage multiple requests per connection without overwhelming the server.
  • Max SSL Connections: Limit SSL connections to around 500 for a moderate-traffic site.

4. Enable GZIP Compression:

  • Under the Server > Tuning menu in the WebAdmin Console, enable GZIP compression to reduce file sizes for HTML, CSS, and JavaScript.
  • Adjust compression levels (4-6) to balance performance and server load.
C. PHP Optimization

PHP is a key component in LiteSpeed’s efficiency, and optimizing its settings can further enhance performance.

1. Switch to LiteSpeed’s LSPHP:

  • LSPHP is LiteSpeed’s optimized PHP processor. Ensure the sites are using it.
  • In CyberPanel, go to “Websites” > “Manage PHP” and select LSPHP for the domain.

2. Adjust PHP Settings:

  • Memory Limit: Increase to 256M or higher for WordPress or CMS-heavy sites.
  • Max Execution Time: Set this between 30-60 seconds to prevent long-running scripts from using too many resources.
  • Max Input Vars: Adjust to around 3000 for complex CMS setups that require large arrays of data.

3. OPcache:

  • Enable OPcache to store compiled PHP scripts in memory, speeding up performance.
  • Configure OPcache in the php.ini file or CyberPanel’s settings for best results.

4. PHP Workers:

  • Set the number of PHP workers to manage more concurrent requests efficiently. A starting point is 10-20 workers for high-traffic sites.
D. Database Tuning

For CMS-driven sites, database optimization is crucial:

1. Enable Database Query Caching:

  • Adjust query_cache_size and query_cache_limit in MySQL/MariaDB configuration to store frequently-run queries.

2. Connection Limits:

  • Set a reasonable limit for database connections using max_connections in the my.cnf file to prevent overload.

3. Database Indexing:

  • Regularly check and optimize database indexes to speed up query execution. Use SQL commands or tools like phpMyAdmin (accessible from CyberPanel).
E. Security Optimizations

Security settings also impact performance:

1. Firewall Settings:

  • Use LiteSpeed’s ModSecurity or CyberPanel’s CSF Firewall to secure the server with minimal performance impact.

2. SSL/TLS Settings:

  • Enable SSL/TLS and optimize settings for secure connections. Consider using HTTP/2 or HTTP/3 (QUIC) for faster secure connections.

Monitoring and Benchmarking Tools

Performance tuning is an ongoing process. CyberPanel and LiteSpeed offer tools for monitoring and benchmarking:

  • CyberPanel’s Tools: Use CyberPanel’s built-in tools for configuration and performance monitoring.
  • Benchmarking Tools: ApacheBench or Siege can measure performance improvements after tuning.
  • Resource Monitoring: Regularly check CPU, memory, and network usage to identify bottlenecks.

Best Practices for Tuning

  • Start Small: Make incremental changes to avoid major disruptions.
  • Test and Monitor: Always test changes and monitor the impact on performance.
  • Consider Workload: Tailor the settings to match the website’s traffic and application needs.
  • Document Changes: Keep a record of what has been modified for troubleshooting and future reference.

[Need to know more? We’re available 24/7.]

Conclusion

By carefully tuning LiteSpeed and CyberPanel, we can significantly enhance the server’s performance, reduce page load times, and provide a better user experience. This proactive approach also ensures the website is well-prepared to handle traffic efficiently, ultimately benefiting both users as well as server administrators.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.