Understanding LVE

Navigation:  Limits >

Understanding LVE

Previous pageReturn to chapter overviewNext page

LVE is a kernel level technology developed by the CloudLinux team. The technology has common roots with container based virtualization and uses cgroups in its latest incarnation. It is lightweight and transparent. The goal of LVE is to make sure that no single web site can bring down your web server.

 

Today, a single site can consume all CPU, IO, Memory resources or Apache processes - and bring the server to a halt. LVE prevents that. It is done via collaboration of Apache module, PAM module and kernel.

 

mod_hostinglimits is Apache module that:

 

detects VirtualHost from which the request came;
detects if it was meant for CGI or PHP script;
puts Apache process used to serve that request into LVE for the user determined via SuexecUserGroup directive for that virtual host;
lets Apache to serve the request;
removes Apache process from user's LVE.

 

The kernel makes sure that all LVEs get fair share of the server's resources, and that no customer can use more then the limits set for that customer.

Today we can limit CPU, Memory (virtual and physical), IO, number of processes as well as the number of entry processes (concurrent connections to apache).

 

Each LVE limits amount of entry processes (Apache processes entering into LVE) to prevent single site exhausting all Apache processes. If the limit is reached, then mod_hostinglimits will not be able to place Apache process into LVE, and will return error code 508. This way very heavy site would slow down and start returning 508 errors, without affecting other users.

 

If the site is limited by CPU or IO, then the site will start responding slower.

If the site is limited by memory or number of processes limits, then the user will recieve 500 or 503 errors that server cannot execute the script.

 

Checking if LVE is installed

 

To use LVE you should have CloudLinux kernel installed, and LVE module loaded. You can check the kernel by running the following command:

 

$ uname -r

 

You should see something like 2.6.18-294.8.1.el5.lve0.8.60. The kernel should have lve in its name. To see if lve kernel module is loaded run:

 

$ lsmod|grep lve
lve                    46496  0

 

Starting from kernels lve1.4.x iolimits module is a part of kmod-lve and could not be used separately.

 

You can toggle LVE on/ff by editing /etc/sysconfig/lve and setting LVE_ENABLE variable to yes or no.

 

Setting it to yes will enable LVE, setting it to no will disable LVE.    

 

You can toggle IO limits by editing /etc/sysconfig/iolimits and setting IO_LIMITS_ENABLED variable to yes or no.

 

You need to reboot the server, after you set this option to make the changes live.

 

Controlling LVE Limits

 

The best way to control LVE limits is using LVE Manager in your favorite control panel. Alternatively, you can use command line tool lvectl to control limits.

The limits are saved in /etc/container/ve.cfg

 

Example:

 

<?xml version="1.0" ?>
<lveconfig>
 <defaults>
         <cpu limit="25"/>
         <ncpu limit="1"/>
         <io limit="1024"/>
         <mem limit="262144"/>
         <other maxentryprocs="200"/>
         <pmem limit="262144"/>
         <nproc limit="0"/>
 </defaults>
 <lve id="532">
         <cpu limit="30"/>
         <ncpu limit="5"/>
 </lve>
</lveconfig>

 

Sets CPU limit to 25%, IO limit to 1024KB/s, virtual memory limit to 1GB (memory limit is set as a number of 4096 bytes pages), physical memory limit to 1GB, CPU cores per LVE to 1, maximum entry processes to 200 and no limit for number of processes for all LVEs. It also sets the limit of 30% and number of processes limit to 5 for LVE with ID 532.

 

 

Checking LVE Usage

 

One of the best way to monitor current usage is lvetop:

 

$ lvetop
         ID     EP    PNO    TNO    CPU    MEM    I/O
         test    1      2         2     2%    728      0  

 

You can also check the content of /proc/lve/list file that has all the data about LVE usage for all LVEs:

 

[[email protected] tests]$ cat /proc/lve/list
4:LVE        EP        lCPU        lIO        CPU        MEM        IO        lMEM        lEP        nCPU        fMEM        fEP
0        0        75        25        0        0        0        262144        20        2        0        0
500        0        75        25        0        0        0        4294967 20        3        2        1        
700        1        75        25        1403247        202        0        262144        20        2        0        0

 

Additionally you can use tool lveps to see CPU usage, and processes within LVE.