1. arthas thrace命令分析耗时
[arthas@82]$ trace com.test.web.controller.OrderUniteController queryOrderPage -n 5 --skipJDKMethod false
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 655 ms, listenerId: 1
`---ts=2024-01-22 11:02:30;thread_name=http-nio-9166-exec-6;id=122;is_daemon=true;priority=5;TCCL=org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader@5ea0f263
`---[197.718153ms] com.test.web.controller.OrderUniteController:queryOrderPage()
+---[0.16% 0.321685ms ] org.slf4j.Logger:info() #83
+---[0.01% 0.014182ms ] com.test.web.request.OrderUnitePageDTO:getOrderType() #84
+---[0.01% 0.010145ms ] com.test.common.to.PaginationRequest:<init>() #101
+---[0.02% 0.043364ms ] com.test.web.mapstruct.OrderUniteMapStruct:pageDtoToRequest() #102
+---[8.46% 16.728599ms ] com.test.web.controller.OrderUniteController:setDataAuthByOrderType() #104
+---[0.01% 0.011294ms ] com.test.common.to.PaginationRequest:setConditions() #107
+---[0.00% 0.008099ms ] com.test.web.request.OrderUnitePageDTO:getPageSize() #108
+---[0.00% 0.008459ms ] com.test.common.to.PaginationRequest:setPageSize() #108
+---[0.00% 0.009668ms ] com.test.web.request.OrderUnitePageDTO:getPageIndex() #109
+---[0.00% 0.007329ms ] com.test.common.to.PaginationRequest:setPageNum() #109
+---[87.44% 172.885494ms ] com.test.web.client.OrderUniteClient:queryOrderPage() #110
+---[0.04% 0.070558ms ] com.test.web.mapstruct.OrderUniteMapStruct:dtoFaceToPageVO() #112
`---[3.14% 6.209232ms ] com.test.web.controller.OrderUniteController:doVoucherPageSumAmt() #115
Affect(class count: 2 , method count: 2) cost in 374 ms, listenerId: 7
`---ts=2024-01-22 11:46:05;thread_name=DubboServerHandler-10.253.68.210:9165-thread-56;id=9150;is_daemon=true;priority=5;TCCL=org.springframework.boot.loader.LaunchedURLClassLoader@3c8a7e38
`---[26.0524ms] com.test.core.accounting.impl.TestServiceImpl:queryTestPage()
+---[0.13% 0.034457ms ] com.test.facade.api.request.accounting.TestPageRequest:getPage() #136
+---[0.03% 0.007267ms ] com.test.facade.api.request.accounting.TestPageRequest:getRows() #136
+---[0.04% 0.010735ms ] com.baomidou.mybatisplus.extension.plugins.pagination.Page:<init>() #136
+---[1.94% 0.50524ms ] com.test.core.accounting.impl.TestServiceImpl:buildWrapper() #137
+---[79.70% 20.763484ms ] com.test.repository.mapper.voucher.TestMapper:selectPage() #137
+---[0.05% 0.012289ms ] com.baomidou.mybatisplus.extension.plugins.pagination.Page:getRecords() #137
+---[0.04% 0.010785ms ] com.test.common.to.PaginationResponse:<init>() #138
+---[0.02% 0.005444ms ] org.apache.commons.collections4.CollectionUtils:isEmpty() #141
+---[0.11% 0.028614ms ] java.util.Comparator:comparing() #145
+---[0.10% 0.026304ms ] java.util.Comparator:thenComparingInt() #145
+---[0.37% 0.096225ms ] java.util.List:sort() #145
+---[0.72% 0.187958ms ] com.test.repository.mapStruct.TestMapStruct:entityListToDtoList() #147
+---[0.03% 0.008859ms ] com.test.common.to.PaginationResponse:setList() #147
+---[0.03% 0.006987ms ] com.baomidou.mybatisplus.extension.plugins.pagination.Page:getTotal() #148
`---[0.03% 0.007384ms ] com.test.common.to.PaginationResponse:setTotal() #148
- java语句中,一般的ger/set方法,比如getPageSize,消耗的是0.008099ms,就是8.099ns,非常短
- java的(小规模)集合操作,会耗时一小会,[0.37% 0.096225ms ] java.util.List:sort() #145
- IO消耗的时间长[79.70% 20.763484ms ] com.test.repository.mapper.voucher.TestMapper:selectPage() #137
综合上面的测试及描述。一些核心接口在压力测试时, 就要评估好QPS以及TPS。评估时要全面考虑接口的 复杂度,后续调用链路的长短。 一般情况下。电商各条业务线的TPS和QPS可以粗略评估如下
2. 支付
一般支付有读写操作都频繁的核心接口如下
- 核心支付 单机TPS一般在500左右
- 取消订单 单机TPS一般在1000左右
- 订单查询
3. 交易
一般支付有读写操作都频繁的核心接口如下
- 创建 单机TPS一般在500左右
- 取消订单
- 订单查询 1S内超时
4. 风控
风控更多的是查询接口,而且一般是使用多级缓存(本地缓存、分布式缓存)来降低调用链路的时延
- 黑名单查询 RT在100ms以内,一般使用本地缓存
- 灰产查询 RT在100ms以内,一般使用本地缓存