This is an old revision of the document!


How to Enable LSPHP CRIU on CloudLinux

Checkpoint/Restore In Userspace, or CRIU, is an open source project which dumps all of the information of a running process to disk and restores it at the point of the dump. The LiteSpeed Enterprise Edition Web Server now supports CRIU both natively, and for the CloudLinux/Apache-specific implementation of the PHP processor. This will improve the performance of LiteSpeed for transactions which are commonly used, and reduce the memory overhead on the server.

  1. CloudLinux System
  2. LiteSpeed Web Server 5.3 or above.

1. Verify CRIU is enabled on your system

Log into your Linux system. Check CRIU whether the service is running or not.
If not, enable by following method:

systemctl enable criu
systemctl start criu
systemctl status criu

Output should be Active: active (running).

2. Check CRIU parameters

In CloudLinux, LSPHP have been compiled with CRIU already. Please check here
Use phpinfo() with parameter -DWITH_CRIU to check the LSPHP build.

3. Configure the PHP environment

Add the following necessary parameter to the PHPx.x External App > Environment

LSAPI_CRIU=1

Example for PHP56 + Enable CRUI + Set INITIAL

Important Syntax

VariableValuesDefaultDescription
LSAPI_CRIU1/On/OffOffIf set to On, CRIU will be performed. 1=On
LSAPI_INITIAL_STARTA number from 1 upwards.15The number of consecutive calls which must be made within a single PHP instance before a dump of the instance will be made. If there’s no PHP instance running and there’s a dump on disk it will be restored on the first use.
LSAPI_CRIU_IMGS_DIR_PATHAny valid, existing directory/var/run/lsws/cl_criu/CRIU images will start from this directory; a subdirectory named “images” will be created below and then a directory for each user's type of request. There needs to be lots of free space in this file system.
LSAPI_CRIU_DEBUGOn/OffOffIf set to On, messages concerning CRIU processing will be written to the stderr.log file (usually in /usr/local/apache2/logs/stderr.log)

Step 1

  1. Prepare any PHP site, e.g. WordPress

Step 2

  1. Generate the dump by hitting the WordPress site
  2. Hit more than INITIAL_START number, e.g. 20 times
  3. If an image dump is generated, you should see an image folder under /var/run/lsws/cl_criu/

Step 3

  1. Check the PHP process number by
    ps -ef | grep php
    >>> user      868577  ...   10:54   0:00 lsphpL
  2. Kill the lsphp process via
    kill -9  868577

Step 4

  1. Restore the PHP by refreshing the WordPress page to regenerate it
  2. Verify the process number is the same as before:
    ps -ef | grep php
    >>> user      868577  ...   10:55   0:00 lsphp

    The process is back!!

  3. You can also check standard error log for something like
    LSCRIU: Successful CloudLinux dump of PID: 868577
    LSCRIU: Successful CloudLinux restore of PID: 868577, parent: 1.
  1. Error log default located at Apache standard error log
  2. dump.log is in the images directory
  3. restore.log is in the images directory

NOTE: restore.log is generated even when there is no dump, so it's expected to see some related fail logs

  • Admin
  • Last modified: 2018/08/16 18:23
  • by Jackson Zhang