LiteSpeed Unveils New Container Technology

NewsLiteSpeed Unveils New Container Technology

Introducing LiteSpeed Containers for Web Hosts

If you are in the business of hosting websites and use control panels like cPanel or Plesk but are not using CloudLinux, you might want to consider LiteSpeed Containers. This new feature from LiteSpeed Technologies can significantly enhance your ability to manage your customers efficiently.

LiteSpeed Containers harness the powerful new features of the Linux operating system, including:

  1. Control of Resources: Using cgroups, LiteSpeed Containers allow you to have full control over CPU, I/O, number of processes, and the amount of memory a user can utilize.
  2. User Isolation: Through namespaces, each user is placed in a sandbox or container that isolates them from affecting other users.

    If you are using Enterprise LiteSpeed along with one of the supported control panels (cPanel or Plesk), you can manage these settings directly through a control panel plugin. Even for those using OpenLiteSpeed or an unsupported control panel, the same functionalities are available via built-in APIs. This guide will walk you through various scenarios where LiteSpeed Containers can help you manage your web hosting environment more effectively.

    Turning on LiteSpeed Containers

    If you are running LiteSpeed Enterprise v6.3 or later with a supported control panel, enabling LiteSpeed Containers is straightforward. You can find the LiteSpeed Containers option in the Control Panel Plugin and execute the provided script to enable it. It is recommended to configure cgroups and namespaces at the virtual host level for optimal performance.

    For those using OpenLiteSpeed, an upgrade to v1.8 or later is necessary. Post-upgrade, you will need to enable cgroups and namespaces manually.

    Hogging the CPU

    One of the fundamental benefits of LiteSpeed Containers is the ability to prevent CPU hogging. In a typical Linux setup, any process could consume all available CPU resources, which can lead to performance issues for other users on the same server. LiteSpeed Containers allow you to allocate a defined amount of CPU to each user, effectively mitigating this problem.

    For instance, if a user inadvertently creates a CPU-intensive loop in a PHP script, it could consume all CPU resources, causing other users’ processes to hang. LiteSpeed Containers can prevent this by allocating a specific amount of CPU to each user package. For example, assigning 100 CPU units means one full CPU core, and this prevents context switching, ensuring smooth performance.

    To configure this, if you have one of the LiteSpeed Control Panel Plugins, open the plugin, select Containers Package Manager, highlight the package, and click Edit. Enter the desired CPU allocation value, such as 100 units, to ensure each user gets a maximum of one CPU core.

    For those without the LiteSpeed Control Panel, the same can be achieved via the command line interface (CLI) using the following command:

    bash<br /> sudo /usr/local/lsws/lsns/bin/lspkgctl --cpu 100 set new-package<br />

    To view the current settings, use:

    bash<br /> sudo /usr/local/lsws/lsns/bin/lspkgctl list new-package<br />

    The user settings are updated immediately upon execution of these commands.

    Selling a Variety of Access

    LiteSpeed Containers also enable you to offer different tiers of access to your customers. For instance, you could have a Basic tier with limited resources and an Advanced tier with more generous allocations. This allows you to cater to a broader range of customer needs and potentially increase your revenue.

    To set this up, create packages for each tier in your control panel and add users to these packages as appropriate. For example:

    • Basic Tier: Limits to 1 CPU, 1GB RAM, 1K IOPS (Input/Output Operations Per Second), 1M IO (Input/Output), and 100 tasks.
    • Advanced Tier: Limits to 2 CPUs, 4GB RAM, 4K IOPS, 4M IO, and 400 tasks.

      These values can be tailored to suit your specific hardware and regional market demands. Once the packages are created, you can manage them via the Containers Package Manager in the LiteSpeed Control Panel Plugin. Click Edit to modify the settings for each package.

      For those using the CLI, the following commands can be used:

      bash<br /> sudo /usr/local/lsws/lsns/bin/lspkgctl --cpu 100 --io 1m --iops 1k --mem 1g --tasks 100 set basic<br /> sudo /usr/local/lsws/lsns/bin/lspkgctl --cpu 200 --io 4m --iops 4k --mem 4g --tasks 400 set advanced<br />

      Making cgroups Exceptions

      There might be scenarios where you need to make exceptions for certain users. For example, if a user named "exception" is placed in the Advanced package but needs unlimited tasks, you can set this exception through the LiteSpeed Control Panel Plugin.

      Navigate to Containers User Manager, find the user, and click Edit in the Cgroups column. Set the task enforcement to unlimited by pressing the Unlimited button and then press Update.

      Using the CLI, the same can be achieved with:

      bash<br /> sudo /usr/local/lsws/lsns/bin/lscgctl --tasks -1 set exception<br />

      Making Namespace Exceptions

      LiteSpeed Containers also allow for namespace containment, where each user runs in their own isolated environment. If you need to exclude a user from namespace containers, this can be done through the LiteSpeed Control Panel Plugin.

      In Containers User Manager, find the user and click the Disable button in the Namespaces column. This will disable the namespace container for that user for future invocations, although existing ones will continue until completed. A manual graceful restart is required to apply this change without disrupting user traffic.

      To perform this action via the CLI:

      bash<br /> sudo /usr/local/lsws/lsns/bin/lsnsctl --uid exception disable-uid<br />

      Monitoring Users With Prometheus

      LiteSpeed Prometheus Exporter allows you to monitor cgroups statistics for each user. This can be integrated with Prometheus and tools like Grafana to provide detailed monitoring of your system.

      In the LiteSpeed Control Panel Plugin, navigate to Containers Stats Manager to get quick statistics. Set the Time Range to options like Last 10 minutes, Last 30 minutes, Last hour, etc., and press Refresh to see the results. Ensure that the Prometheus Address is configured to contact the same Prometheus server that the LiteSpeed Prometheus Exporter is using.

      Monitoring Users Without Prometheus

      If you prefer not to use Prometheus, you can still get real-time statistics through the LiteSpeed Control Panel Plugin. Select Time Range: Real-Time (without Prometheus) and press Refresh for the last 2 seconds of information.

      To get statistics for a specific user via the CLI, use:

      bash<br /> /usr/local/lsws/lsns/bin/lscgstats exception<br />

      This will return details for the system and the specific user, which can be used for further analysis.

      Conclusion

      LiteSpeed Containers provide a robust set of tools for web hosts to manage resources efficiently, offer tiered services, and monitor system performance. Whether you are using a supported control panel or relying on CLI commands, these features can significantly enhance your hosting capabilities. For more detailed information and updates, visit the LiteSpeed Technologies Blog.

For more Information, Refer to this article.

Neil S
Neil S
Neil is a highly qualified Technical Writer with an M.Sc(IT) degree and an impressive range of IT and Support certifications including MCSE, CCNA, ACA(Adobe Certified Associates), and PG Dip (IT). With over 10 years of hands-on experience as an IT support engineer across Windows, Mac, iOS, and Linux Server platforms, Neil possesses the expertise to create comprehensive and user-friendly documentation that simplifies complex technical concepts for a wide audience.
Watch & Subscribe Our YouTube Channel
YouTube Subscribe Button

Latest From Hawkdive

You May like these Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.