Binding Tomcat Processes to Cores
Purpose
Bind the Tomcat process to cores to reduce context switching and improve the overall performance of the server.
Procedure
Bind the Tomcat process to specified CPU cores. The implementation varies according to how Tomcat is deployed.
- If Tomcat is independently installed, run the following command to bind the Tomcat process to cores:
1 2
cd /home/apache-tomcat-9.0.69 taskset -c N ./bin/startup.sh
- If the built-in Tomcat of Spring Boot is used, run the following command to bind the Tomcat process to cores:
1 2
cd /home/tomcat-test-01 taskset -c N java -jar target/tomcat-test-01-0.0.1-SNAPSHOT.jar
In the preceding command, N indicates the indexes of the specified CPU cores. For example, 0–3 indicates that the process is bound to CPU cores 0, 1, 2, and 3. During actual operations, adjust the core binding range to match the actual CPU configuration of the server.
1 | taskset -c 0-3 ./bin/startup.sh |
Parent topic: Tomcat Tuning