Modifying the Gazelle Configuration File
To enable Gazelle in subsequent operations, you need to modify the configuration parameters in the Gazelle configuration file lstack.conf. This file specifies lstack startup parameters.
- Open the lstack.conf file.
1vi /etc/gazelle/lstack.conf - Press i to enter the insert mode and modify the configuration items as follows:
dpdk_args=["--socket-mem", "0,2048,0,0", "--huge-dir", "/data/hugepages", "--proc-type", "primary"] use_ltran=0 flow_bifurcation=0 kni_switch=0 low_power_mode=0 mbuf_count_per_conn=170 listen_shadow=1 num_cpus="23,47,71,95" num_wakeup="22,46,70,94" host_addr="192.168.200.8" mask_addr="255.255.255.0" gateway_addr="192.168.200.1" devices="08:4f:0a:01:ec:d3" app_bind_numa=1 stack_interrupt=0
Modify the parameters listed in Table 1 based on the actual requirements.
Table 1 Parameter description Parameter
Configuration Scope
Default Value
Description
dpdk_args
-
-
Sets DPDK initialization parameters.
If the CX4 NIC is used, add the -d and librte_net_mlx5.so parameters as follows:dpdk_args=["--socket-mem", "0,2048,0,0", "--huge-dir", "/data/hugepages", "--proc-type", "primary", "-d", "librte_net_mlx5.so"]
--socket-mem
-
-
Allocates memory space according to the huge page configurations. 0,2048,0,0 indicates that 2,048 MB (2 GB) memory is allocated to NUMA Node1, which is the huge page size configured in 7.
NOTE:You are advised to configure Gazelle on the NUMA node where the NIC is located. Gazelle supports only four NUMA nodes. If there are more than four NUMA nodes, Gazelle should be allocated to the first four NUMA nodes.
The required memory capacity is related to the settings of other parameters such as tcp_conn_count, mbuf_count_per_conn and rpc_msg_max.
- In the MySQL service, the memory is calculated as follows: When rpc_msg_max is set to 32, the occupied memory is about 90 MB. 20 MB is added for every 500 connections. The memory required for every 4,000 mbufs is about 10 MB. In addition, you are advised to configure 100 MB more to improve fault tolerance. Quantity of mbufs = tcp_conn_count × mbuf_count_per_conn.
Therefore, you are advised to set the memory capacity to 204 MB (90 MB + 4 MB + 10 MB + 100 MB) for a maximum of 100 connections, to 260 MB (90 MB + 20 MB + 50 MB + 100 MB) for a maximum of 500 connections, and to 330 MB (90 MB + 40 MB + 100 MB + 100 MB) for a maximum of 1,000 connections.
- In the Redis service, the memory is calculated as follows: The fixed memory usage is about 90 MB. 350 MB is added for every 10,000 connections. The memory required for every 4,000 mbufs is about 10 MB. In addition, you are advised to configure 100 MB more to improve fault tolerance. Quantity of mbufs = tcp_conn_count × mbuf_count_per_conn.
Therefore, you are advised to set the memory capacity to 1540 MB (90 MB + 350 MB + 1000 MB + 100 MB) for a maximum of 10,000 connections and to 2890 MB (90 MB + 700 MB + 2000 MB + 100 MB) for a maximum of 20,000 connections.
--huge-dir
-
-
Sets the huge page directory as created in 5.
flow_bifurcation
0 and 1
0
Enables or disables NIC normalization. This function applies only to Docker and KVM scenarios. The value defaults to 0 (disabled), and can be set to 1 (enabled).
NOTE:This parameter is supported in Gazelle 1.0.2-56 and later versions.
tcp_conn_count
1 to 20000
1500
Indicates the number of connections. The default value is 1500. The value must be greater than or equal to the maximum number of connections plus 10. For example, if the maximum number of connections is 1,000, the value must be greater than or equal to 1010.
NOTE:The maximum value is 20000. If the maximum number of connections exceeds 20,000, set the value to 20000 and set mbuf_count_per_conn to a larger value, as long as the product of tcp_conn_count and mbuf_count_per_conn is greater than or equal to the maximum number of connections multiplied by 40.
mbuf_count_per_conn
1 to INT32_MAX
170
- Indicates number of mbufs used in each connection. The default value is 170. You can adjust the value based on the service resource usage. Set this parameter to 40 for the MySQL and Redis services if num_cpus is configured with one thread.
- Set this parameter to 80 or a larger value if num_cpus is configured with multiple threads. In this case, set a larger value of --socket-mem accordingly.
nic_rxqueue_size
512 to 8192
4096
Indicates the depth of the NIC receiving queue. The value must be a power of 2.
nic_txqueue_size
512 to 8192
2048
Indicates the depth of the NIC sending queue. The value must be a power of 2.
num_cpus
-
-
Indicates the IDs of the CPU cores bound to the lstack threads. The number of IDs is the number of lstack threads (less than or equal to the number of NIC queues). Set the parameter based on the network pressure of specific services. You are advised to set this parameter to the ID of the last core on the NUMA node with NIC affinity.
NOTE:Query the NUMA node with NIC affinity by running cat /sys/class/net/NIC_Name/device/numa_node.
num_wakeup
-
-
You are advised to set this parameter to the ID of the penultimate core on the NUMA node with NIC affinity. This parameter is not supported in Gazelle-1.0.1-53 and later versions.
host_addr
-
-
Sets to the service IP address.
mask_addr
-
-
Sets to the mask of the service network segment.
gateway_addr
-
-
Sets to the service gateway.
devices
-
-
Sets to the MAC address of the service network interface, that is, the MAC address recorded in 6.
app_bind_numa
0 and 1
0
The value can be 0 or 1 (default). 1 indicates that the epoll and poll threads of the application are bound to the NUMA where the protocol stack resides. If the application needs to be started with the core binding mode configured via numactl, set this parameter to 0.
stack_interrupt
0 and 1
0
The value can be 0 (default) or 1. 0 indicates that Gazelle exclusively occupies cores. 1 indicates that the interrupt mode is enabled. When no data packet is processed, the Gazelle protocol stack thread releases the CPU resources and enters the sleep state. When a data packet arrives, the hardware triggers an interrupt signal to wake up the protocol stack thread and instructs the thread to respond to and process new data immediately. This setting can significantly reduce unnecessary CPU usage in the idle state. This parameter is added in Gazelle-1.0.2-67 and later versions.
NOTE:This parameter is supported in Gazelle 1.0.2-67 and later versions.
listen_shadow
0 and 1
0
TCP port for listening. The value 0 indicates that one lstack thread is used to listen to the port, and the value 1 indicates that multiple lstack threads are used to listen to the port. If the value of num_cpus is greater than 1, set this parameter to 1.
rpc_msg_max
1 to 8192
4096
Number of elements (rte_mbuf structures) in the RPC memory pool. The default value is 4096. When Redis is started, the default setting can be used for a maximum of 10,000 connections, and the value can be changed to 8192 for a maximum of 20,000 connections. When MySQL is started, set the parameter to 32.
Run the following command to query the Gazelle version:
1rpm -qa | grep gazelle
- In the MySQL service, the memory is calculated as follows: When rpc_msg_max is set to 32, the occupied memory is about 90 MB. 20 MB is added for every 500 connections. The memory required for every 4,000 mbufs is about 10 MB. In addition, you are advised to configure 100 MB more to improve fault tolerance. Quantity of mbufs = tcp_conn_count × mbuf_count_per_conn.
- Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.