一、程序测试时的相关辅助命令保存
压力测试 :root@med-1:~# ab -n 1000 -c 100 -p post1.txt -T application/json http://123.103.117.96:8001/api/v1/cmdpc/exec/wait
root@med-1:~# ab -n 100 -c 10 -p post1.txt -T application/json http://123.103.117.96:8002/api/v1/up/pc/abnormal
root@med-1:~# ab -n 100 -c 10 http://123.103.117.96:8001/docs/swagger-ui-bundle.js
ab -n 10000 -c 100 -p post1.txt -T application/json http://123.103.117.96:8001/api/v1/cmdpc/exec/wait
ab -n 1000 -c 10 -p post1.txt -T application/json http://123.103.117.96:8001/api/v1/cmdpc/exec/wait
root@med-1:~# ab -n 1000 -c 10 http://123.103.117.96:8001/api/v1/cmdpc/exec/test-no-db
无数据库操作达到:1500 之后:Requests per second: 3563.70 [#/sec] (mean)
root@med-1:~# ab -n 1000 -c 10 http://123.103.117.96:8001/api/v1/cmdpc/exec/test-has-db
数据库读达到1300 之后: Requests per second: 2443.36 [#/sec] (mean)
root@med-1:~# ab -n 1000 -c 10 http://123.103.117.96:8001/api/v1/cmdpc/exec/test-db-write
数据库读+写:Requests per second: 24.88 [#/sec] (mean)
从30左右 增长到 80左右。 Requests per second: 75.46 [#/sec] (mean)
压测登录接口:
ab -n 10000 -c 1000 -p post.txt -T application/json http://10.18.230.204/api_admin/v1/auth/login/access-token
压测用户详情接口:
ab -n 10000 -c 1000 -p post-user.txt -T application/json -H 'x-token: MTYyMjExMTU5MS4zMTY0ODMzfDUxNWIzZjU2NzlhMjViY2Q2ZDQyZWMxNGE3OWY1NTg2NmRmOTNkYzg=' http://10.18.230.204/api_admin/v1/users/detail
1:查询token
2021-05-25 03:01:00,930 |INFO| sqlhelper.py 166 [sql]:SELECT id,username,password,token,name,avatar,role_id,grp_id,state_id,phone,email,status,del_flag FROM m01_user WHERE token = %s limit 1 [param]:['MTYyMjExMTU5MS4zMTY0ODMzfDUxNWIzZjU2NzlhMjViY2Q2ZDQyZWMxNGE3OWY1NTg2NmRmOTNkYzg=']
2:查询目标用户
2021-05-25 03:01:00,931 |INFO| sqlhelper.py 166 [sql]:SELECT id,username,password,token,name,avatar,role_id,grp_id,state_id,phone,email,status,del_flag FROM m01_user WHERE id = %s [param]:1
3:查询用户组织机构
2021-05-25 03:01:00,931 |INFO| sqlhelper.py 166 [sql]:SELECT * FROM c01_group WHERE id = %s [param]:3
4:查询用户状态
2021-05-25 03:01:00,931 |INFO| sqlhelper.py 166 [sql]:SELECT * FROM c02_user_state WHERE id = %s [param]:2
5:查询用户角色
2021-05-25 03:01:00,932 |INFO| sqlhelper.py 166 [sql]:SELECT * FROM c05_role WHERE id = %s [param]:9
6:记录操作记录
#持续压测
*/1 * * * * ab -n 30000 -c 2000 -p /root/yccs/test/post-user.txt -T application/json -H 'x-token: MTYyMjExMTU5MS4zMTY0ODMzfDUxNWIzZjU2NzlhMjViY2Q2ZDQyZWMxNGE3OWY1NTg2NmRmOTNkYzg=' http:
//10.18.230.204/api_admin/v1/users/detail >> /root/yccs/test/ab.log 2>&1
压测综管后台用户详情接口:
ab -n 10000 -c 1000 -p post-user.txt -T application/json -H 'x-token: MTYyMzIwMTY5MC4wNzAyNzN8YzNiZDM4MWNmZWZjZmM3MzQ3Mzg1OGUwZTcxODJiOTRhZTk3MmQ1Ng==' http://123.103.117.96:9012/api_admin/v1/users/detail
INSERT INTO d07_user_record SET uid = 5 ,PATH = '/api/v1/messages/latest-contacts' ,module = 'test' ,ACTION = 'AA' ,ip = '219.147.31.2' ,detail = '219.147.31.2'
=============================线上MYSQL压测测试===================
set @st = REPLACE(unix_timestamp(current_timestamp(3)),'.','');
INSERT INTO d07_user_record SET uid = 5 ,PATH = '/api/v1/messages/latest-contacts' ,module = 'test' ,ACTION = 'AA' ,ip = '219.147.31.2' ,detail = '219.147.31.2';
set @en = REPLACE(unix_timestamp(current_timestamp(3)),'.','');
select round((@en - @st)/3000,3) as avg_time;
### 快捷命令
## linux服务器快捷命令:
重启python容器:
docker exec -it server_8002 /bin/bash -c 'kill -HUP `cat /tmp/gunicorn.pid`'
docker exec -it server_8001 /bin/bash -c 'kill -HUP `cat /tmp/gunicorn.pid`'
执行MQTT请求:
curl -i --basic -u admin:public -X GET "http://192.168.10.18:8081/api/v4/topic-metrics
curl -i --basic -u admin:public -X GET "http://192.168.10.18:8081/api/v4/clients"
curl -i --basic -u admin:public -X GET "http://192.168.10.18:8081/api/v4/subscriptions"
重启nginx容器: docker exec -it 容器 /bin/bash service nginx reload
云服务器上查看已经启动的服务:systemctl| grep -E "redis|mysql|minio|emq"
查看线上数据库行数:
SELECT table_name,table_rows,DATA_LENGTH/1024/1024 "DATA_LENGTH",CREATE_TIME,TABLE_COLLATION FROM information_schema.tables WHERE TABLE_SCHEMA = 'ipms' ORDER BY table_rows DESC;
##### 服务器端日志分析:
提取日志:docker logs 5422768341e0 | grep ^2021-08-16 | grep "/api/v1/" > 0816.log
统计响应请求:awk '{print $14}' 0816.log | sort -n | uniq -c本文地址:http://47.93.183.36/article/1301.html,未经许可,不得转载.
二、待了解的技术内容保存记录
nps/npc服务了解:
frp升级。[fatedier/frp] Release v0.36.2 - v0.36.2 https://blog.csdn.net/qq_20497199/article/details/115606052
DD命令详解:https://blog.csdn.net/qq_33160790/article/details/77488160
MYSQL8的复制特性改进: http://blog.itpub.net/31547898/viewspace-2200045/
Linux性能瓶颈阈值分析:
B站小程序观看:https://www.bilibili.com/video/BV1834y1676P?p=55&spm_id_from=pageDriver&vd_source=07d8cecbacbf5484e67de215e1835e9b
*********************************************************************************
安装graphviz
python311 -m pip install graphviz
https://blog.csdn.net/qq_24166417/article/details/106614196
pycallgraph 类调用图
https://www.jb51.net/article/207000.htm
服务器的抓包命令 tcpdump 命令的使用
推荐使用 Git 的可视化操作工具 Git Extensions
可视化工具,Git Extensions
使用Git
https://www.lodashjs.com/
线程问题:
https://blog.csdn.net/wuyy0224/article/details/128261312
页面加载:
https://m.xp.cn/b.php/93573.html
docker-compose安装 Mysql
log-error = logs/var/log/mysql
会出现报错:Could not open file '/var/log/mysql/error.log' for error logging: Permission denied
https://blog.csdn.net/renfng/article/details/128974138
https://blog.csdn.net/qq_63701832/article/details/129721857
yield 代替return
Parameters: reconnect – If the connection is closed, reconnect.
Raises: Error – If the connection is closed and reconnect=False.本文地址:http://47.93.183.36/article/1301.html,未经许可,不得转载.
本文地址:http://47.93.183.36/article/1301.html 未经许可,不得转载. 手机访问本页请扫描右下方二维码.
手机扫码直接打开本页面 |