This is an old revision of the document!


How to enable CRIU

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 for 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. Running as the root user to use CRIU Litespeed or Apache. The CRIU facility requires Litespeed run as the root user to perform the snapshot and recovery. Running as a non-root user automatically disables CRIU.
  2. CloudLinux System

1. CRIU enabled from System

Login your Linux system. Check CRIU service is running or not.
If not, enable by following method

systemctl enable criu
systemctl start criu
systemctl status criu

Output Active: active (running)

2. CRIU parameter check

Generally PHP should be compiled with criu already.
Through phpinfo() to check LSPHP build with parameter: -DWITH_CRIU.

If you want to manually compile, please download LSAPI from here

3. php env config

Add 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 image dump generated, you should see an image folder under /var/run/lsws/cl_criu/

Step 3

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

Step 4

  1. To restore the PHP by refreshing the WordPress page to regenerate it
  2. Verify the process number is same as before
    ps -ef | grep php
    user 868577 … 10:55 0:00 lsphp
    Process is back!!
  3. You can also check standard error log
    LSCRIU: Successful CloudLinux dump of PID: 868577
    LSCRIU: Successful CloudLinux restore of PID: 868577, parent: 1.
  1. Error log default locate at Apache standard error log
  2. dump.log is in the images directory
  3. restore.log is in the images directory
  • restore.log will gets generated even though there is no dump, so it's expected to see some related fail logs
  • Admin
  • Last modified: 2018/05/11 00:16
  • by Eric Leu