CentOS LNMP性能测试工具与用法
一、工具分类与适用场景
二、快速上手命令示例
sudo yum install -y httpd-toolsab -n 10000 -c 200 http://your-domain.com/(-n 总请求数,-c 并发数)git clone https://github.com/wg/wrk.git && cd wrk && make && sudo cp wrk /usr/local/bin/wrk -t12 -c400 -d30s --latency http://your-domain.com/(12线程、400并发、30秒)sudo yum install -y siegesiege -c200 -t60s -b http://your-domain.com/jmeter -n -t test.jmx -l result.jtlsysbench cpu --threads=8 --time=60 runsysbench memory --threads=8 --time=60 runsysbench fileio prepare && sysbench fileio --file-total-size=10G --file-test-mode=rndrw runsysbench oltp_read_write --db-driver=mysql --mysql-host=127.0.0.1 --mysql-user=root --mysql-password=xxx --tables=10 --table-size=1000000 --threads=8 --time=300 runfio --name=randread --ioengine=libaio --rw=randread --bs=4k --size=1G --numjobs=4 --runtime=60 --time_based --filename=/tmp/fio.logsudo yum install -y netperfnetperf -H your_server_ip -t TCP_STREAM三、压测前后监控要点
location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; }top/htop(进程CPU/内存)、vmstat 1(系统负载/内存/IO)、iostat -x 1(磁盘IO等待)、ss -s(连接数)、dstat -ta(综合资源)、iftop(带宽占用)、nmon(资源总览)。SHOW STATUS LIKE 'Threads_connected';、SHOW STATUS LIKE 'Slow_queries';SELECT COUNT(*) as connections, state FROM information_schema.processlist GROUP BY state;pt-query-digest /var/log/mysql/slow.log。四、结果判读与常见瓶颈
iostat 的 await 高说明磁盘慢;iftop 显示带宽打满则网络成为瓶颈。五、测试流程与注意事项