Performing Tuning on Physical Machines
Purpose
Set the affinity of the Memcached service. The following uses the physical server with one CPU as an example. Use numactl to set the affinity between the CPU and memory.
Procedure
- Install numactl in Yum mode.
1yum -y install numactl
- Open the memcached.service file.
1vim /usr/lib/systemd/system/memcached.service - Add the following content to the file:
ExecStart=/usr/bin/numactl --cpunodebind=0,1 --membind=0,1 /opt/memcached/bin/memcached -t 48 -p 11211 -u root -m 122880 -c 100000
Table 1 describes the command parameters.
Table 1 Command parameter description Parameter
Description
--cpunodebind=nodes
Specifies that a process is bound to the CPU. 0 and 1 indicate the cores that bind to node 0 and node 1.
--membind=nodes
Specifies the memory allocated to a process. 0 and 1 indicate that the allocated memory is on node 0 and node 1.
-t <num>
Specifies the number of used threads (48 indicates that 48 threads are used.)
-p <num>
Specifies the TCP listening port.
-u <username>
Specifies the user to which the process belongs. Only the root user can use this parameter.
-m <num>
Specifies the memory size allocated to Memcached instances. The unit is MB.
-c <num>
Specifies the maximum number of concurrent connections.
- Press Esc, type :wq!, and press Enter to save the file and exit.