- 25 Apr 2024
- 8 Minutes to read
- Print
- DarkLight
- PDF
Optimization
- Updated on 25 Apr 2024
- 8 Minutes to read
- Print
- DarkLight
- PDF
Web Protection Performance Tuning
Web Protection can be deployed on customer applications that may have different throughput and scale requirements. Various configuration knobs are provided to cater to these requirements.
The provided configuration knobs are:
- vIPC Queue Size
- Number of vRule Worker Thread
vIPC Queue Size Configuration
The vIPC queue is a shared memory queue that is used to exchange data plane messages. A queue is created as per application process requirements. In case the configured application creates many ephemeral processes, then it is optimal to reduce the vIPC data queue size.
- The default data queue size is set to 26 MB in one direction. This means that 10 application processes would consume 520 MB of RAM (including both directions)
- However, if the application creates hundreds of ephemeral processes, then the memory allocated for vIPC queues will exceed 520 MB. In these scenarios, it is optimal to reduce the value of the parameter dataQueueSizeto ensure a reasonable memory consumption. For example, if there are 100 application processes, this value must be modified to 5MB to keep the total memory consumed under 500MB.
- In cases of Apache/Ngnix servers where processes are spun up in large numbers, the default data queue size of 26 MB can be reduced to a lower value (Example: 5 MB). This configuration can be applied to all processes. Configuration of this parameter is required for PHP processes
- In cases where the maximum number of processes spun up by a web server is configured to be 100 or more, then the default data queue size of 26 MB can be reduced to a lower value like 5 MB
- Configure the vIPC queue size using the parameter dataQueueSize using the below command:
vsp-cli config vIPC-server edit dataQueueSize <desired_size_in_bytes>
- The command top provides the memory consumed by each process. If the resident memory of the vIPC-server goes beyond 512 MB during a load condition, then it is an indication that vIPC queue needs resizing. It is suggested to reduce it by 50% for each iteration. This procedure must be repeated as many times as necessary to limit the vIPC memory consumption to a reasonable amount
- Typically, vIPC queue size adjustment is done along with vRule worker thread adjustment
vRule Engine Worker Thread Configuration
- vRule Engine deploys a number of worker threads to handle Application data traffic. The default value is typically configured to two threads. Each worker thread requires 1 vCPU
- However, if an Application requires more throughput, then it is recommended to increase the number of worker threads in vRule.
- The number of worker threads and memory can be configured by executing the commands below:
vsp-cli config ae edit numWorker <1-16> --persist #To modify number of threads vsp-cli config ae edit autoscaling false #To disable autoscaling
- When the application throughput requirement is more than the supported value, it creates a congestion in the vRule Engine and as a result, packets are dropped by vRule’s flow controls. The number of packets dropped are logged in the vRule stats file
- The vRule stats are available in the file: /vspstats/vrule/vrule_stats. The below diagram depicts a part of the vRule stats file
- If the drop count increases continuously, then it is a clear indication that more worker threads are needed. There should be a continuous increase in the drop count
- Received M indicates the accumulated number of data plane messages. The rate of increase of these messages indicates the overall throughput rate at which the vRule Engine is processing data packets
- The average packet size and throughput can also be obtained from CMS dashboard
VSP Restart
A change in the vIPC queue size or the vRule Engine worker threads requires a restart
- Restart the vRule Engine using the below command:
vsp-cli restart ae
- Restart the vIPC server using the below command. This command restarts all the services as the vIPC-server cannot be restarted in isolation
vsp-cli restart vIPC-server
Memory Optimization for httpd Server
When the httpd server is instrumented by VSP Memory, decrease the VSP Memory overhead by configuring the below settings in the file httpd.conf:
- MinSpareServers 256
- MaxSpareServers 256
- MaxRequestsPerChild 0
In some configurations, httpd spawns multiple short-lived worker processes that handle only a single httpd request. VSP-Memory is non-optimal for short-lived processes. By applying these settings, httpd spawns a pool of worker processes that stay alive for the lifetime of httpd. This allows httpd under VSP-Memory to maintain near-native throughput.
Memory Compatibility for RTM (Linux)
In Linux systems, if the RTM feature is enabled, VSP-Memory may not function as expected. This is defined by the environment variable glibc.elision.enable. This is a global setting at the Operating System level. The setting is dependent on the below factors:
- Operating System and version
- glibc library version
Below table provides the VSP Memory Compatibility for RTM
OS Version | glibc Version | RTM used in Code | Enabled (By default) | Tunable |
---|---|---|---|---|
Cent OS | ||||
7.8 | 2.17 | Yes | No | Yes (RHEL_GLIBC_TUNABLES="glibc.elision.enable=1") |
Ubuntu | ||||
16.04 LTS | 2.23 | Yes | Yes | No |
18.04 LTS | 2.27 | Yes | No | Yes (GLIBC_TUNABLES="glibc.elision.enable=1") |
20.04 LTS | 2.31 | Yes | No | Yes (GLIBC_TUNABLES="glibc.elision.enable=1") |
20.1 | 2.32 | Yes | No | Yes (GLIBC_TUNABLES="glibc.elision.enable=1") |
21.04 | 2.33 | Yes | No | Yes (GLIBC_TUNABLES="glibc.elision.enable=1") |
Amazon Linux | ||||
1 | 2.17 | Yes | No | Yes (RHEL_GLIBC_TUNABLES="glibc.elision.enable=1") |
2 | 2.26 | Yes | No | Yes (RHEL_GLIBC_TUNABLES="glibc.elision.enable=1") |
CMS Configuration Limits
[Version 3.0.0 and Above]
This section provides the CMS configuration limits. The values provided below may not be hard limits in many cases, but exceeding them may lead to an unstable CMS in the deployed environment. Virsec highly recommends staying within these limits. Reach out to the Virsec technical team in case your setup/environment requires scaling beyond these numbers.
Configuration | Maximum/Recommended Limit |
---|---|
Number of probes registered with a single CMS instance (Host+Web/Mem) | 1500 |
Number of probes in CPM with a single CMS instance (Host+Web/Mem) | 1500 |
Number of Host Profiles per CMS instance | 50 |
Number of Probes per Host Profile | 50 |
Number of incidents CMS can store at any point | 500,000 |
Number of Users per CMS | 100 |
Number of Roles per CMS | 20 |
Number of probes installation via CPM in single batch | 50 |
Number of probes scan under host profiles in a single batch | 50 |
Incident rate (Per Sec) with a single CMS instance | 20 |
VSP Probe - Memory and CPU Monitoring (VMs only)
VSP-Manager monitors its resource usage to ensure that the VSP processes do not overuse a customer machine’s resources. The CPU and Memory Usage are monitored on both Linux and Windows VMs. If the maximum limit is crossed, the Probe is stopped.
- The resource utilization is monitored after the configured time interval elapses
- Modify the time frequency (Usage Sampling Time) between each check using the below command:
vsp-cli config vsp-manager edit usageCheckRate <time_in_seconds> --persist
- If the utilization exceeds for a configured threshold, the utilization is monitored again after the time frequency. The maximum number of times the utilization is allowed to exceed the threshold (Usage Sampling Rate) can be configured:
vsp-cli config vsp-manager edit usageThreshold <Maximum_Allowed_Attempts> --persist
- Once this count is reached, the VSP Probe is stopped and its status is Disconnected in CMS
- The configurations can be set dynamically at runtime
- If the values are set to zero (0), the monitoring is turned off
- The default values are:
- Time frequency – 60 seconds
- Consecutive attempts with utilization exceeding - 3
- By default, the values are NOT configured at VSP process level
General Configurations
Shutdown VSP Probe or a Single VSP Service
- VSP-Manager can be configured to shut down all the VSP Probe services OR just the problematic service. Configure the preference using the below command:
vsp-cli config vsp-manager edit singleServiceShutdown <true/false> --persist
- true – To shut down only the problematic VSP Service
- false – To shut down all VSP services
Shutdown of a single service is not possible if limit per service is not set
Auto-restart a VSP Service
- If the setting singleServiceShutdown is true, then an auto-restart for services that are killed by VSP-Manager can be configured using the below command:
vsp-cli edit-service <Service_Name> edit autorestartTime <Time_In_Seconds>
- Time_In_Seconds – Defines the wait time after which the VSP Service must be restarted
- The available services are: AE, AE-PROXY, vIPC-server, FSM, FSM-AGENT, HMM, RMP, VSP-manager, VSP-memory-assist, VSP-web-assist and VSP-APG
Ignore Initial Usage of VSP Service
- VSP-Manager supports a configuration that ignores resource usage for the first N seconds of a VSP service’s life. This is in cases the usage during this time might be higher than the usage during normal functioning of the service
vsp-cli edit-service <Service_Name> edit ignoreUsageTime <Time_In_Seconds>
- The available services are: AE, AE-PROXY, vIPC-server, FSM, FSM-AGENT, HMM, RMP, VSP-manager, VSP-memory-assist, VSP-web-assist and VSP-APG
CPU Monitoring
Total VSP Services CPU Capping
- The default limit is 40%
- The overall Probe limits are provided in the table below:
Usage Type Minimum Maximum Total CPU 5 100 Memory MB Limit 200MB <No limit> Memory Percent Limit >1 100 - The Probe limits per component are provided in the table below:
Usage Type Minimum Maximum Total CPU 5 100 Memory MB Limit 50MB <No limit> Memory Percent Limit >1 100 - Configure the total CPU usage of the VSP services using the below command:
vsp-cli config vsp-manager edit cpuLimit <Limit_In_Percentage> --persist
Individual VSP Service CPU Capping
- Execute the below command to set the CPU limit of an individual VSP service by executing:
vsp-cli edit-service <Service_Name> edit cpuLimit <Limit_In_Pertecntage>
- Configure the Usage Sampling Time using the below command:
vsp-cli config vsp-manager edit usageSamplingTime <time_in_seconds> --persist
- Configure Usage Sampling Rate using the below command:
vsp-cli config vsp-manager edit usageSamplingRate <Usage_Sampling_Rate> --persist
- The available services are: AE, AE-PROXY, vIPC-server, FSM, FSM-AGENT, HMM, RMP, VSP-manager, VSP-memory-assist, VSP-web-assist and VSP-APG
- Example:
- Consider the values: usageSamplingTime = 2.5 and usageSamplingRate = 2
- For each CPU usage reading, VSP-Manager collects 2 samples, 2.5 seconds apart. Their average value is then calculated to procure the most accurate value of the current CPU usage
- The average value is divided by the number of CPU cores on the system to get the overall CPU usage of a specific process
Memory Monitoring
Total VSP Service Memory Capping
- The default limit is 40%
- Configure the total CPU capping of the VSP services using the below command:
vsp-cli config vsp-manager edit memoryMBLimit <Limit_in_MB> --persist vsp-cli config vsp-manager edit memoryPercentLimit <Limit_In_Percentage> --persist
NOTEAE and AE-Proxy services are excluded from the total Memory capping. Utilize the Individual Service Memory capping feature if required
Individual VSP Service Memory Capping
- Configure the memory limits of an individual VSP service by executing:
ORvsp-cli edit-service <Service_Name> edit memoryMBLimit <Limit_in_MB>
vsp-cli edit-service <Service_Name> edit memoryPercentLimit <Limit_In_Percentage>
- The available services are: AE, AE-PROXY, vIPC-server, FSM, FSM-AGENT, HMM, RMP, VSP-manager, VSP-memory-assist, VSP-web-assist and VSP-APG
- VSP-Manager supports the capping of memory usage by the number of MBs and the percentage of total system usage
VSP-CLI Password (Windows)
- Password can be set during Probe Installation
- Starting VSP Service using services.msc is allowed but stopping is not allowed
- Starting/stopping VSP services using sc command is not allowed
- VSP-CLI has three options for password management. The options are
- check-password: returns true when the password is configured and false when the password is not configured for VSP-CLI during Probe Installation
- reset-password: To reset the password using the current password OR the reset token (generated during Probe Installation)
- set-password: To set the password (if not set already)
vsp-cli -h #To view help menu
- Password is required to modify or stop services, but not required to start any VSP service
- When the below options are used with VSP-CLI, the user is prompted for the password (if it is already set)
vsp-cli edit-service #(edit) vsp-cli update-service vsp-cli config #(edit, add and restore) vsp-cli reinit-cms