CRIU Support

Navigation:  Apache mod_lsapi >

CRIU Support

Previous pageReturn to chapter overviewNext page

[CloudLinux 7 only]

 

What is CRIU

 

CRIU is Checkpoint/Restore In Userspace, (pronounced kree-oo), is a software tool for Linux operating system. Using this tool, you can freeze a running application (or part of it) and checkpoint it as a collection of files on disk. You can then use the files to restore the application and run it exactly as it was during the time of freeze (more information on the link https://criu.org/Main_Page).

 

mod_lsapi-1.1-1 is the first beta version with freezing PHP implemented. mod_lsapi now supports the following parameters:

 

Option name

Description

Values

Default

lsapi_criu

Enable/disable CRIU for lsphp freezing

On/Off

Off

lsapi_criu_socket_path

Set path to socket for communication with criu service

[path to socket]

/var/run/criu/criu_service.socket

lsapi_backend_semtimedwait

Enable/disable flag for notification about lsphp started. This method avoid cycles of waiting for lsphp start

On/Off

Off

lsapi_backend_initial_start

Number of request when lsphp should be freezed

[number]

0 - no freezing

0

lsapi_criu_use_shm

Method of requests counting. Off - use shared memory. Signals - use signals from child processes to parent

Off/Signals

Off

lsapi_criu_imgs_dir_path

Path to folder where imgs of freezed PHP will be stored

[path]

/var/run/mod_lsapi/

 

Example:

 

lsapi_criu On

lsapi_criu_socket_path /var/run/criu/criu_service.socket

lsapi_backend_semtimedwait On

lsapi_backend_initial_start 15

lsapi_criu_use_shm Off

 

How it works

 

When Apache module mod_lsapi detects CRIU enabled (lsapi_criu On) it prepares a directory for images (on the first request of virtualhost) to store (lsapi_criu_imgs_dir_path /var/run/mod_lsapi/[dir_name]), and starts lsphp process. Lsphp increases counter (lsapi_criu_use_shm Off|Signals) via shared memory or signals, when counter reaches limit (lsapi_backend_initial_start 15), lsphp sends the request to CRIU for freezing. CRIU service makes images of requested processes. Lsphp will not be frozen if counter has not reached the limit. The next time when lsphp will be stopped, it will be unfrozen from the images.

 

The images of the processes will be saved even if Apache is restarted. But all images will be deleted after server restart by default configuration. This can be modified by setting the new path lsapi_criu_imgs_dir_path.

 

Important! If php.ini or configuration file from php.d is changed, the images must be deleted manually. We are working on automation of this action.

 

Note that CRIU can't correctly freeze lsphp with PrivateTmp enabled. For correct work, PrivateTmp should be false in httpd.service file. For example:

 

# cat httpd.service

[Unit]

Description=Apache web server managed by cPanel EasyApache

ConditionPathExists=!/etc/httpddisable

ConditionPathExists=!/etc/apachedisable

ConditionPathExists=!/etc/httpdisable

 

[Service]

Type=forking

ExecStart=/usr/local/cpanel/scripts/restartsrv_httpd --no-verbose

PIDFile=/var/run/apache2/httpd.pid

PrivateTmp=false

 

[Install]

WantedBy=multi-user.target

 

Criu is installed with dependency to mod_lsapi-1.1 package. To activate it:

 

1. Enable service and start it:

 

systemctl enable criu

systemctl start criu

 

2. Edit lsapi.conf file, turn CRIU On and set some defaults:

 

lsapi_criu On

 

lsapi_criu_socket_path /var/run/criu/criu_service.socket

 

lsapi_backend_semtimedwait On

 

lsapi_backend_initial_start 15

 

lsapi_criu_use_shm Off

 

3. Restart apache:

 

service httpd restart