ro-webgl-server/server/roserver/压力测试.todo

292 lines
18 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

登录压测(内网CPU不行)
2000人登录
- rsa加密后 CPU80%左右 不做rsa加密cpu20%左右 3-4倍左右
- 耗时
[num,time,totaltime]:2000 3319.813 6176
[num,time,totaltime]:3000 5972.598666666667 10779
[num,time,totaltime]:3000 5071.317 9597
[num,time,totaltime]:4000 7392.53225 13935
- 打包机
[num,time,totaltime]:4000 14318.12575 23254 //没有账号
[num,time,totaltime]:4000 6930.891 12357 //有账号无缓存
[num,time,totaltime]:4000 3374.57275 6686 //缓存的情况下
[num,time,totaltime]:4000 2966.5955 6041 //缓存的情况下
[num,time,totaltime]:4000 2915.534 6068 //缓存的情况下
[num,time,totaltime]:4000 2842.83625 6087 //缓存的情况下
去除rsalog编译时去除-race选项:
[num,time,totaltime]:4000 3817.8895 7367 //没有账号
[num,time,totaltime]:4000 1436.8795 3374 //缓存的情况下
[num,time,totaltime]:4000 1443.3105 3229 //缓存的情况下
[num,time,totaltime]:4000 1571.72775 3338 //缓存的情况下
优化后
[num,time,totaltime]:4000 2172.94375 5098 //有账号无缓存
[num,time,totaltime]:4000 2102.67025 5145 //有账号无缓存
[num,time,totaltime]:4000 1553.00075 3338 //缓存的情况下
[num,time,totaltime]:4000 3188.68775 7194 //没有账号
[num,time,totaltime]:4000 1474.4295 3270 //缓存的情况下
[num,time,totaltime]:4000 1943.8585 3266 //缓存的情况下
[num,time,totaltime]:4000 1523.90625 3256 //缓存的情况下
[num,time,totaltime]:4000 2083.5075 5064 //有账号无缓存
[num,time,totaltime]:2000 1078.1295 2562 //有账号无缓存
[num,time,totaltime]:4000 1659.317 3301 //缓存的情况下
缓存 :db-on CPU-50% db-down CPU-80%
无缓存 :db-on CPU-100% db-down CPU-100%
添加log:
[num,time,totaltime]:4000 2280.73775 5365 //有账号无缓存
[num,time,totaltime]:4000 4374.42875 7922 //没有账号
[num,time,totaltime]:4000 1697.66425 3307 //缓存的情况下 gate-down-cpu=250
[num,time,totaltime]:4000 1546.67725 3229 //缓存的情况下 gate-down-cpu=150
添加rsalog:
[num,time,totaltime]:4000 2313.7925 3350 //缓存的情况下
[num,time,totaltime]:4000 2466.58375 5507 //有账号无缓存
[num,time,totaltime]:4000 1429.78175 3279 //缓存的情况下
[num,time,totaltime]:4000 1443.2815 3230 //缓存的情况下
[num,time,totaltime]:4000 1533.7545 3322 //缓存的情况下 gate-down-cpu=270
[num,time,totaltime]:4000 3812.59175 7604 //没有账号 gate-on-cp=500
[num,time,totaltime]:4000 3704.84475 7367 //没有账号
[num,time,totaltime]:4000 2645.96825 5687 //有账号无缓存
[num,time,totaltime]:4000 3631.25825 6298 //有账号无缓存
[num,time,totaltime]:4000 3327.40825 5974 //有账号无缓存
- 优化
[num,time,totaltime]:4000 3409.6435 6086 //有账号无缓存
[num,time,totaltime]:4000 2230.51525 3249 //缓存的情况下
[num,time,totaltime]:4000 2261.33125 3344
[num,time,totaltime]:4000 1461.44225 3206
[num,time,totaltime]:4000 845.5105 1836 //缓存的情况下 两个Game两个DB进程
[num,time,totaltime]:4000 1098.2785 2087
[num,time,totaltime]:4000 684.90225 1625
CPU:
gate:
- 缓存登录
cpu on 270%
cpu down 50%
内存:
- 启动占用内存
root 15872 1.2 0.0 125036 10560 pts/3 Sl 21:23 0:04 ./gate -config ./gate_config.yaml
root 15873 1.5 0.1 127620 45584 pts/3 Sl 21:23 0:04 ./game -config ./game_config.yaml
root 15874 1.2 0.0 125032 10608 pts/3 Sl 21:23 0:04 ./db -config ./db_config.yaml
root 15875 1.3 0.0 125024 9808 pts/3 Sl 21:23 0:04 ./auth -config ./auth_config.yaml
root 15876 0.8 0.0 125312 9400 pts/3 Sl 21:23 0:02 ./social -config ./social_config.yaml
root 15877 1.5 0.1 126848 44608 pts/3 Sl 21:23 0:05 ./battleboss -config ./battle_boss_config.yaml
root 15878 1.4 0.1 127068 46756 pts/3 Sl 21:23 0:04 ./rank -config ./rank_config.yaml
root 15872 1.2 0.0 125036 10772 pts/3 Sl 21:23 0:05 ./gate -config ./gate_config.yaml
root 15873 1.4 0.1 127620 47224 pts/3 Sl 21:23 0:06 ./game -config ./game_config.yaml
root 15874 1.2 0.0 125032 11068 pts/3 Sl 21:23 0:05 ./db -config ./db_config.yaml
root 15875 1.3 0.0 125024 10188 pts/3 Sl 21:23 0:06 ./auth -config ./auth_config.yaml
root 15876 0.7 0.0 125312 10316 pts/3 Sl 21:23 0:03 ./social -config ./social_config.yaml
root 15877 1.5 0.1 126848 46892 pts/3 Sl 21:23 0:07 ./battleboss -config ./battle_boss_config.yaml
root 15878 1.5 0.1 127068 48180 pts/3 Sl 21:23 0:07 ./rank -config ./rank_config.yaml
root 15872 1.2 0.0 125036 10824 pts/3 Sl 21:23 0:08 ./gate -config ./gate_config.yaml
root 15873 1.4 0.1 127620 47224 pts/3 Sl 21:23 0:09 ./game -config ./game_config.yaml
root 15874 1.2 0.0 125032 11136 pts/3 Sl 21:23 0:07 ./db -config ./db_config.yaml
root 15875 1.3 0.0 125024 10188 pts/3 Sl 21:23 0:08 ./auth -config ./auth_config.yaml
root 15876 0.7 0.0 125312 10352 pts/3 Sl 21:23 0:04 ./social -config ./social_config.yaml
root 15877 1.4 0.1 126848 46920 pts/3 Sl 21:23 0:09 ./battleboss -config ./battle_boss_config.yaml
root 15878 1.5 0.1 127068 48428 pts/3 Sl 21:23 0:09 ./rank -config ./rank_config.yaml
root 15872 1.2 0.0 125036 10948 pts/3 Sl 21:23 0:13 ./gate -config ./gate_config.yaml
root 15873 1.3 0.1 127620 47360 pts/3 Sl 21:23 0:14 ./game -config ./game_config.yaml
root 15874 1.2 0.0 125032 11436 pts/3 Sl 21:23 0:12 ./db -config ./db_config.yaml
root 15875 1.3 0.0 125024 10512 pts/3 Sl 21:23 0:14 ./auth -config ./auth_config.yaml
root 15876 0.7 0.0 125312 10388 pts/3 Sl 21:23 0:08 ./social -config ./social_config.yaml
root 15877 1.3 0.1 126848 47144 pts/3 Sl 21:23 0:14 ./battleboss -config ./battle_boss_config.yaml
root 15878 1.4 0.1 127068 48600 pts/3 Sl 21:23 0:15 ./rank -config ./rank_config.yaml
4000人登录 10次以上
root 22565 11.8 0.4 198480 136540 pts/3 Sl 21:58 5:13 ./gate -config ./gate_config.yaml
root 22566 6.3 5.2 2577724 1731252 pts/3 Sl 21:58 2:48 ./game -config ./game_config.yaml
root 22567 3.8 0.0 128872 24824 pts/3 Sl 21:58 1:41 ./db -config ./db_config.yaml
root 22568 2.3 0.0 126880 11088 pts/3 Sl 21:58 1:02 ./auth -config ./auth_config.yaml
root 22569 2.2 0.0 127104 13172 pts/3 Sl 21:58 0:59 ./social -config ./social_config.yaml
root 22570 1.3 0.1 127296 45988 pts/3 Sl 21:58 0:35 ./battleboss -config ./battle_boss_config.yaml
root 22571 1.3 0.1 127580 42196 pts/3 Sl 21:58 0:36 ./rank -config ./rank_config.yaml
root 22565 9.7 0.4 198480 136008 pts/3 Sl 21:58 5:21 ./gate -config ./gate_config.yaml
root 22566 5.4 5.2 2577724 1731312 pts/3 Sl 21:58 3:00 ./game -config ./game_config.yaml
root 22567 3.2 0.0 128872 23944 pts/3 Sl 21:58 1:48 ./db -config ./db_config.yaml
root 22568 2.1 0.0 126880 10516 pts/3 Sl 21:58 1:10 ./auth -config ./auth_config.yaml
root 22569 1.9 0.0 127104 12388 pts/3 Sl 21:58 1:05 ./social -config ./social_config.yaml
root 22570 1.3 0.1 127296 46448 pts/3 Sl 21:58 0:44 ./battleboss -config ./battle_boss_config.yaml
root 22571 1.3 0.1 127580 42544 pts/3 Sl 21:58 0:45 ./rank -config ./rank_config.yaml
root 22565 11.1 0.4 198480 137096 pts/3 Sl 21:58 6:22 ./gate -config ./gate_config.yaml
root 22566 6.3 5.9 2577724 1935620 pts/3 Sl 21:58 3:37 ./game -config ./game_config.yaml
root 22567 3.7 0.0 129192 25688 pts/3 Sl 21:58 2:08 ./db -config ./db_config.yaml
root 22568 2.2 0.0 126880 11612 pts/3 Sl 21:58 1:18 ./auth -config ./auth_config.yaml
root 22569 2.1 0.0 127104 13256 pts/3 Sl 21:58 1:14 ./social -config ./social_config.yaml
root 22570 1.3 0.1 127552 46440 pts/3 Sl 21:58 0:46 ./battleboss -config ./battle_boss_config.yaml
root 22571 1.3 0.1 127580 42812 pts/3 Sl 21:58 0:46 ./rank -config ./rank_config.yaml
ROUTINE ======================== roserver/game/model.(*Role).Init in /root/rogo/src/roserver/game/model/role.go
778.66MB 846.13MB (flat, cum) 94.87% of Total
. . 246:
. . 247: return role
. . 248:}
. . 249:
. . 250:func (this *Role) Init() {
776.73MB 776.73MB 251: this.UuidRoleList = make(map[uint64]*serverproto.AccountRole, 4096)
. . 252: //初始化角色状态机
. 229.34kB 253: this.InitState()
. 8.11kB 254: this.RegisterState(int32(ROLE_STATE_PULLING_LIST), pullingRoleList)
. . 255: this.RegisterState(int32(ROLE_STATE_PULLED_LIST), pulledRoleList)
. . 256: this.RegisterState(int32(ROLE_STATE_CREATE), createRole)
. . 257: this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_SUCCESS), createDbRoleSuccess)
. . 258: this.RegisterState(int32(ROLE_STATE_DB_ADD_ROLE_FAILURE), createDbRoleFailure)
. . 259: this.RegisterState(int32(ROLE_STATE_SELECT_ROLE), SelectingRole)
. . 260: this.RegisterState(int32(ROLE_STATE_SELECT_ROLE_SUCCESS), SelectRoleSuccess)
. . 261: this.RegisterState(int32(ROLE_STATE_ONLINE), RoleOnline)
. 1.02MB 262: this.RegisterState(int32(ROLE_STATE_OFFLINE), RoleOffline)
. . 263:
. 575.07kB 264: this.roleBattleAttr = newRoleBattleAttr(this)
. . 265:
. 1.55MB 266: this.base = newRoleBase(this)
. 647.78kB 267: this.roleHero = newRoleHero(this)
. 603.17kB 268: this.roleBag = newRoleBag(this)
. 34.74MB 269: this.roleEquip = newRoleEquip(this)
. 2.52MB 270: this.roleChip = newRoleChip(this)
. 727.72kB 271: this.roleMap = newRoleMap(this)
. 5.96MB 272: this.roleSkill = newRoleSkill(this)
. 2.56MB 273: this.roleCard = newRoleCard(this)
. 595.18kB 274: this.roleFashion = newRoleFashion(this)
. 580.98kB 275: this.roleBattle = newRoleBattle(this)
. 1.99MB 276: this.roleTask = newRoleTask(this)
. 720.52kB 277: this.roleFightPower = newRoleFightPower(this)
. 318.47kB 278: this.roleChat = newRoleChat(this)
. 330.95kB 279: this.roleArena = newRoleArena(this)
. 7.79MB 280: this.roleMail = newRoleMail(this)
. 373.86kB 281: this.roleRed = newRoleRed(this)
. 393.93kB 282: this.roleShop = newRoleShop(this)
. 548.41kB 283: this.roleCompetition = newRoleCompetition(this)
. 1.81MB 284: this.roleSocial = newRoleSocial(this)
. 595.14kB 285: this.roleActivity = newRoleActivity(this)
. 467.26kB 286: this.roleTower = newRoleTower(this)
. . 287:
1.93MB 1.93MB 288: this.soList = append(this.soList,
. . 289: this.base,
. . 290: this.roleHero,
. . 291: this.roleBag,
. . 292: this.roleCard,
. . 293: this.roleEquip,
ROUTINE ======================== roserver/game/model.newRoleEquip in /root/rogo/src/roserver/game/model/role_equip.go
1.48MB 34.74MB (flat, cum) 3.90% of Total
. . 20: equipTyeList map[int32]set.Interface
. . 21:}
. . 22:
. . 23:func newRoleEquip(r *Role) *RoleEquip {
. . 24: roleEquip := &RoleEquip{
144.56kB 144.56kB 25: role: r,
. . 26: }
189.10kB 189.10kB 27: roleEquip.equipList = make(map[int32]*serverproto.EquipData)
. . 28:
273.60kB 273.60kB 29: roleEquip.equipTyeList = make(map[int32]set.Interface)
. . 30: for i := Equip_Type_Head; i < Equip_Type_Max; i++ {
907.21kB 34.15MB 31: roleEquip.equipTyeList[int32(i)] = set.New(set.NonThreadSafe)
. . 32: }
. . 33:
. . 34: return roleEquip
. . 35:}
. . 36:
- 内存优化后
root 28632 78.7 0.4 2490484 140344 pts/3 Sl 14:37 3:23 ./gate -config ./gate_config.yaml
root 28633 34.2 0.7 1967492 238920 pts/3 Sl 14:37 1:28 ./game -config ./game_config.yaml
root 28634 26.5 0.0 1601664 31396 pts/3 Sl 14:37 1:08 ./db -config ./db_config.yaml
root 28635 8.4 0.0 1238752 15232 pts/3 Sl 14:37 0:21 ./auth -config ./auth_config.yaml
root 28636 12.4 0.0 1632516 16808 pts/3 Sl 14:37 0:32 ./social -config ./social_config.yaml
root 28637 1.4 0.1 1772548 45300 pts/3 Sl 14:37 0:03 ./battleboss -config ./battle_boss_config.yaml
root 28638 1.3 0.1 1689820 46616 pts/3 Sl 14:37 0:03 ./rank -config ./rank_config.yaml
root 28632 79.9 0.4 2490484 140576 pts/3 Sl 14:37 4:49 ./gate -config ./gate_config.yaml
root 28633 35.8 0.7 1968068 246664 pts/3 Sl 14:37 2:09 ./game -config ./game_config.yaml
root 28634 26.8 0.0 1601920 31640 pts/3 Sl 14:37 1:37 ./db -config ./db_config.yaml
root 28635 8.4 0.0 1312740 15440 pts/3 Sl 14:37 0:30 ./auth -config ./auth_config.yaml
root 28636 12.8 0.0 1633028 17216 pts/3 Sl 14:37 0:46 ./social -config ./social_config.yaml
root 28637 1.4 0.1 1772548 47740 pts/3 Sl 14:37 0:05 ./battleboss -config ./battle_boss_config.yaml
root 28638 1.3 0.1 1689820 46616 pts/3 Sl 14:37 0:04 ./rank -config ./rank_config.yaml
root 28632 66.3 0.4 2490484 145304 pts/3 Sl 14:37 5:33 ./gate -config ./gate_config.yaml
root 28633 30.1 0.7 1968068 247548 pts/3 Sl 14:37 2:31 ./game -config ./game_config.yaml
root 28634 22.4 0.0 1601920 31672 pts/3 Sl 14:37 1:52 ./db -config ./db_config.yaml
root 28635 7.1 0.0 1329388 15828 pts/3 Sl 14:37 0:36 ./auth -config ./auth_config.yaml
root 28636 10.7 0.0 1641224 17420 pts/3 Sl 14:37 0:54 ./social -config ./social_config.yaml
root 28637 1.4 0.1 1772548 47744 pts/3 Sl 14:37 0:07 ./battleboss -config ./battle_boss_config.yaml
root 28638 1.3 0.1 1689820 48824 pts/3 Sl 14:37 0:06 ./rank -config ./rank_config.yaml
root 28632 44.2 0.4 2490484 145480 pts/3 Sl 14:37 5:48 ./gate -config ./gate_config.yaml
root 28633 20.6 0.7 1968068 248048 pts/3 Sl 14:37 2:42 ./game -config ./game_config.yaml
root 28634 15.3 0.0 1601920 31760 pts/3 Sl 14:37 2:01 ./db -config ./db_config.yaml
root 28635 5.2 0.0 1329388 15928 pts/3 Sl 14:37 0:41 ./auth -config ./auth_config.yaml
root 28636 7.3 0.0 1641224 17492 pts/3 Sl 14:37 0:58 ./social -config ./social_config.yaml
root 28637 1.3 0.1 1772548 47880 pts/3 Sl 14:37 0:11 ./battleboss -config ./battle_boss_config.yaml
root 28638 1.3 0.1 1771748 49012 pts/3 Sl 14:37 0:10 ./rank -config ./rank_config.yaml
root 2378 131 0.4 2547760 144600 pts/3 Sl 17:46 2:53 ./gate -config ./gate_config.yaml
root 2379 72.7 0.7 2222656 234516 pts/3 Sl 17:46 1:36 ./game -config ./game_config.yaml
root 2380 43.8 0.0 1602048 29600 pts/3 Sl 17:46 0:57 ./db -config ./db_config.yaml
root 2381 12.7 0.0 1435872 14352 pts/3 Sl 17:46 0:16 ./auth -config ./auth_config.yaml
root 2382 21.2 0.0 1641480 16400 pts/3 Sl 17:46 0:28 ./social -config ./social_config.yaml
root 2383 1.5 0.1 1690364 43872 pts/3 Sl 17:46 0:02 ./battleboss -config ./battle_boss_config.yaml
root 2384 1.5 0.1 1632800 45404 pts/3 Sl 17:46 0:02 ./rank -config ./rank_config.yaml
1万人
root 15460 12.7 0.8 336316 279936 pts/3 Sl 22:19 5:24 ./gate -config ./gate_config.yaml
root 15461 11.7 1.3 547044 428304 pts/3 Sl 22:19 4:59 ./game -config ./game_config.yaml
root 15462 4.0 0.0 126744 17844 pts/3 Sl 22:19 1:43 ./db -config ./db_config.yaml
root 15463 3.7 0.0 127512 17772 pts/3 Sl 22:19 1:36 ./db -config ./db_config2.yaml
root 15464 2.2 0.0 125136 13160 pts/3 Sl 22:19 0:56 ./auth -config ./auth_config.yaml
TRACE:
linux open files设置
#ulimit -HSn 102400 //这只是在当前终端有效退出之后open files又变为默认值
#vim /etc/security/limits.conf //加入以下配置,重启即可生效
* soft nofile 65535
* hard nofile 65535
malg申请g携程时的消耗
go tool trace -http='192.168.10.158:37576' trace.out
✔ 1CPU耗时优化 @done (20-04-24 11:20)
✔ 2内存消耗优化 @done (20-04-24 11:20)
3函数耗时优化
✔ 4进程多开部署 @done (20-04-24 15:35)
1大包数据模拟一面断开连接
2断线重连测试
PC测试: 通过暂停测试通过
手机测试:
3,mysql连接不上的问题
4,gateserver中在转发给gameserver是添加了日志用来确定是否正常收到消息但是会增加加锁消耗