Home WebServer PanelDirectAdmin How to enable LSCache on DirectAdmin

How to enable LSCache on DirectAdmin

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In today’s article, AZDIGI will show you enable LSCache on DirectAdmin to increase the performance of Litespeed Webserver.

I. What is LSCache?

LiteSpeed Cache (LSCache) is a high-performance dynamic content acceleration feature built into LiteSpeed server products.

LSCache accelerates dynamic content (not just PHP pages), with the same features as in Apache mod_cache, using a highly customizable, efficient native implementation in LiteSpeed server, greatly reducing load times page and server load.

LSCache removes the reverse proxy layers required by additional caching packages (such as Varnish), providing faster, more efficient handling of static content in addition to dynamic content processing.

Note: Many of you misunderstand LSCache and LiteSpeed Cache Plugin for WordPress as the same thing. And in this article, I only mentioned LSCache configured on the server.

II. How to enable LSCache on DirectAdmin

To enable LSCache on DirectAdmin, follow these 3 steps.

Step 1: SSH into your DirectAdmin system

To enable LSCache on DirectAdmin, we first need to SSH or access your VPS/server with root privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSHing we continue with step 2 to set the root cache storage area on the server.

Step 2: Set the cache storage area on the server

To do this, you need to edit the file /etc/httpd/conf/extra/httpd-includes.conf with the following command:

AZDIGI Tutorial
vi /etc/httpd/conf/extra/httpd-includes.conf
    

Then add the following content to this file:

AZDIGI Tutorial
CacheRoot /home/lscache/

    

By default, the directory /home/lscache/ will exist after installing Litespeed on DirectAdmin. However, if the check is not there, you can create this directory and assign valid permissions with the following commands:

AZDIGI Tutorial
cd /home/
mkdir lscache
chmod 751 lscache
chown apache:apache lscache
    

If you want to cache the LSCache in a different directory, you can still change it to your liking.

Step 3: Set cache on the server for all users

Similar to step 2, we also need to create a directory and a file with the following commands:

AZDIGI Tutorial
cd /usr/local/directadmin/data/templates/
mkdir custom
chown diradmin:diradmin custom
vi /usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.2.pre
    

Then add the following content to this file:

AZDIGI Tutorial
  CacheRoot lscache

    

This will create a lscache directory in the user’s root directory (/home/<user>/lscache

Apply these changes to all users by running the following command:

AZDIGI Tutorial
cd /usr/local/directadmin/custombuild
./build rewrite_confs
    
activate-lscache-on-directadmin
Apply the new configuration and restart Litespeed.

Then you can see, in the root directory of the existing users, added the lscache directory.

activate-lscache-on-directadmin

Finally, let’s restart lsws again.

AZDIGI Tutorial
service lsws restart
    
activate-lscache-on-directadmin
Restart LiteSpeed Webserver.

Here are the results I got when running with ApacheBench (100 connections from 10 different users) before enabling LSCache:

AZDIGI Tutorial
[root@sv lscache]# ab -n 100 -c 10 https://lscachebench.domain.com/
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking lscachebench.domain.com (be patient).....done


Server Software:        LiteSpeed
Server Hostname:        lscachebench.domain.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-ECDSA-AES128-GCM-SHA256,384,128
Server Temp Key:        ECDH P-256 256 bits
TLS Server Name:        lscachebench.domain.com

Document Path:          /
Document Length:        150032 bytes

Concurrency Level:      10
Time taken for tests:   30.011 seconds
Complete requests:      100
Failed requests:        0

Total transferred:      15035596 bytes
HTML transferred:       14991496 bytes
Requests per second:    3.33 [#/sec] (mean)
Time per request:       3001.057 [ms] (mean)
Time per request:       300.106 [ms] (mean, across all concurrent requests)
Transfer rate:          489.27 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        5   19  12.5     15      51
Processing:  1459 2825 445.3   2878    3823
Waiting:      888 2138 351.0   2149    2995
Total:       1466 2844 446.0   2895    3858

Percentage of the requests served within a certain time (ms)
  50%   2895
  66%   3079
  75%   3180
  80%   3230
  90%   3377
  95%   3486
  98%   3740
  99%   3858
 100%   3858 (longest request)
    

Here are the results I got when running with ApacheBench (100 connections from 10 different users) after enabling LSCache:

AZDIGI Tutorial
[root@sv lscache]# ab -n 100 -c 100 https://lscachebench.domain.com/
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking lscachebench.domain.com (be patient).....done


Server Software:        LiteSpeed
Server Hostname:        lscachebench.domain.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-ECDSA-AES128-GCM-SHA256,384,128
Server Temp Key:        ECDH P-256 256 bits
TLS Server Name:        lscachebench.domain.com

Document Path:          /
Document Length:        149938 bytes

Concurrency Level:      100
Time taken for tests:   0.569 seconds
Complete requests:      100
Failed requests:        0

Total transferred:      15045200 bytes
HTML transferred:       14993800 bytes
Requests per second:    175.75 [#/sec] (mean)
Time per request:       568.981 [ms] (mean)
Time per request:       5.690 [ms] (mean, across all concurrent requests)
Transfer rate:          25822.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        6  237  82.2    292     302
Processing:   192  278  60.7    254     437
Waiting:        1  101  57.9     91     172
Total:        443  515  28.6    523     558

Percentage of the requests served within a certain time (ms)
  50%    523
  66%    541
  75%    545
  80%    546
  90%    549
  95%    549
  98%    550
  99%    558
 100%    558 (longest request)
    

In the above two results, I changed my domain to domain.com. And I also have a complete WordPress sales website installed and fully configured SSL.

image 64

The above two results show that after having LSCache, the ability to handle the number of requests is almost 51 times higher. My VPS only has 1 Core 2GB RAM, so the new results are so low. If you use a VPS or a server with much larger resources, the results will likely differ.

You can check if LSCache is up and running by checking that the Header should be LiteSpeed server and the X-LiteSpeed-Cache should be hit.

activate-lscache-on-directadmin

III. Summary

Hopefully, through this article, you will expand the power of your LiteSpeed Webserver.

Hope this article will be of help to you. Wishing you success!

References: https://docs.litespeedtech.com/cp/directadmin/

See more useful articles about DirectAdmin at the following link:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign