Java performance optimization to create a billion-level traffic spike system: 2. Performance pressure test

2. Performance pressure test

By determining the bottleneck or unacceptable performance points of a system, the test of the maximum service level that the system can provide is obtained.

1. Prepare the environment

  1. Install CentOS 7.4
  2. Install jdk 1.8
  3. Install mysql

yum install mysql*

  1. Install mariadb (on centos, mysql is replaced by mariadb?
  2. Start mariadb

systemctl start mariadb.service
can start mysql.
Check whether mysql is started: ps -ef | grep mysql
check port: netstat -anp | grep 3306

  1. Modify the root password of mysql

mysqladmin -u root password root

  1. Try to connect to the database

mysql -uroot -proot
show databases
use miaosha
show tables

  1. Import the sql file into the database

mysql -uroot -proot < //tmp/miaosha.sql

deploy:

  1. maven packaging
  2. Upload server, run

** Plug-in configuration file: ** The priority of the plug-in configuration file is higher.

  1. vim application.properties

Modify the plug-in configuration file
server.port=80

  1. java -jar miaosha.jar --spring.config.addiction-location=/var/www/miaosha/application.properties

Write startup script:

  1. vim deploy.sh

nohup java -Xms400m -Xmx400m -XX:NewSize=200m -XX:MaxNewSize=200m -jar miaosha.jar --spring.config.addition-location=/var/www/miaosha/application.properties
nohup: means even if the command is closed Do not stop the program running.

  1. chmod -R 777 *

  2. ./deploy.sh &

    Insert picture description here

  3. tail nohup.out View log

2. Performance pressure test

After the project is completed, proceed before going online. Many performance bottlenecks can be found.

  1. New thread group
  2. Add-sampler-http request
    Insert picture description here
    Insert picture description here

Use a long connection to directly pressure test the corresponding interface. Prevent performance bottlenecks from appearing on http establishment.

  1. View the result tree
  2. Aggregate report

image.png
image.png
The average response time, 90% of the requests are responded within 10ms.

Three, find concurrent capacity problems

  1. ps -ef | grep java find the java process number
  2. pstree -p 9890 View the threads of the 9890 process

pstree -p 9890 | wc -l

  1. top -H View machine performance

image.png image.png


image.png
image.png

The primary key is a clustered index by default, so the query speed is the fastest.

image.png

Guess you like

Origin blog.csdn.net/xiaohaigary/article/details/108010734