新增接口速度慢应该怎么去排查呢?

Blade 已结 2 938
ccc
ccc 剑圣 2021-12-03 11:03

我们有一个新增接口每次调用的速度都比较慢,要将近5秒多。

并没有其他复杂逻辑,直接调用的生成代码的save接口,看日志数据库执行的时间也并不长。

Entity里面有几个数据转换的注解,是因为直接影响了速度吗?

/**
 * 培训的id
 */
@ApiModelProperty(value = "培训的id")
private Long planId;
/**
 * 签到名字
 */
@ApiModelProperty(value = "签到名字")
private String name;
/**
 * 签到开始时间
 */
@JsonFormat(
        pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty(value = "签到开始时间")
private LocalDateTime startTime;
/**
 * 签到结束时间
 */
@JsonFormat(
        pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty(value = "签到结束时间")
private LocalDateTime endTime;

/**
 * 是否校验地理位置信息1是0否
 */
@JsonSerialize(using = ToStringSerializer.class)
private Integer isCheckGeolocation;

/**
 * 地址名
 */
private String addressName;

/**
 * 经度
 */
private String longitude;

/**
 * 纬度
 */
private String latitude;

/**
 * 范围信息
 */
private String geolocationRange;

接口请求日志

================  Request Start  ================
===> POST: /plansign/save
====Body=====  {"id":null,"createUser":null,"createDept":null,"createTime":null,"updateUser":null,"updateTime":null,"status":null,"isDeleted":null,"tenantId":null,"planId":1465167353176719362,"name":null,"startTime":null,"endTime":null,"isCheckGeolocation":null,"addressName":null,"longitude":null,"latitude":null,"geolocationRange":null}
===Headers===  Origin: http://192.168.99.182:1888
===Headers===  Cookie: JIDENTITY=1e82e23e-efcb-40c2-a734-6118ded6dd39; Hm_lvt_a95f4d7c757c7240eb70bb597b827cd7=1633947789; 122_vq=197; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2217d45b05974863-0d89c4511b348-b7a1b38-2073600-17d45b059756fa%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22url%E7%9A%84domain%E8%A7%A3%E6%9E%90%E5%A4%B1%E8%B4%A5%22%2C%22%24latest_search_keyword%22%3A%22url%E7%9A%84domain%E8%A7%A3%E6%9E%90%E5%A4%B1%E8%B4%A5%22%2C%22%24latest_referrer%22%3A%22url%E7%9A%84domain%E8%A7%A3%E6%9E%90%E5%A4%B1%E8%B4%A5%22%7D%2C%22%24device_id%22%3A%2217d45b05974863-0d89c4511b348-b7a1b38-2073600-17d45b059756fa%22%7D; Hm_lvt_74b340479d1126865f1756ac4a438494=1637551723,1638163059,1638234638; bladex-ui-access-token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiI5NTYxNzYiLCJpY29uQ29sb3IyIjoiI0ZGQUQ0OCIsInVzZXJfbmFtZSI6ImFkbWluIiwiaWRDYXJkIjoiIiwicmVhbF9uYW1lIjoiYWRtaW4iLCJjbGllbnRfaWQiOiJsaWJyYS11aSIsImljb25Db2xvcjEiOiIjM2Y2MWZmIiwicm9sZV9pZCI6IjE0NjUxNjE5Mzg1NzE0MDczNjEiLCJzY29wZSI6WyJhbGwiXSwicG9zdE5hbWUiOiLpppbluK3miafooYzlrpgiLCJvYXV0aF9pZCI6IiIsImV4cCI6MTYzODU3NDc4NCwianRpIjoiMzQ2MjQwNjItMzAwOS00YTc0LTgxZjItZTViZmY0YjhkZDIxIiwic2V4IjoxLCJhdmF0YXIiOiIiLCJhdXRob3JpdGllcyI6WyJhZG1pbiJdLCJjaGVja0ZsYWciOjAsInJvbGVfbmFtZSI6ImFkbWluIiwibGljZW5zZSI6InBvd2VyZWQgYnkgbGlicmEiLCJwb3N0X2lkIjoiMTQ2NTE2MTk0MDk3NDc0MzU1NCIsImN1c3RvbVRoZW1lIjoiIzNmNjFmZiIsInVzZXJfaWQiOiIxNDY1MTYxOTQ4OTc0OTExNDg5IiwicGhvbmUiOiIiLCJuaWNrX25hbWUiOiJ1c2VySE93SjVwZGoiLCJkZXRhaWwiOnsidHlwZSI6IndlYiIsInVzZXJEZXRhaWxJZCI6IjE0NjUxNjE5NDg5NDk3NDU2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NvdW50IjoiYWRtaW4ifQ.HYh8Vxgi6KsNY6bi3vA2Db9ucw8MnKQcBZMegaPJjCI
===Headers===  X-Forwarded-Prefix: /bladex-plan
===Headers===  Accept: application/json, text/plain, */*
===Headers===  Referer: http://192.168.99.182:1888/
===Headers===  X-Forwarded-Host: 192.168.99.152
===Headers===  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
===Headers===  X-Forwarded-Proto: http
===Headers===  Accept-Encoding: gzip
===Headers===  X-Forwarded-Port: 80
===Headers===  Authorization: Basic bGlicmEtdWk6bGlicmEtdWlfc2VjcmV0
===Headers===  host: 192.168.99.152:8113
===Headers===  Forwarded: proto=http;host=192.168.99.152;for="192.168.99.107:55776"
===Headers===  X-Forwarded-For: 192.168.99.107
===Headers===  bladex-Auth: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiI5NTYxNzYiLCJpY29uQ29sb3IyIjoiI0ZGQUQ0OCIsInVzZXJfbmFtZSI6ImFkbWluIiwiaWRDYXJkIjoiIiwicmVhbF9uYW1lIjoiYWRtaW4iLCJjbGllbnRfaWQiOiJsaWJyYS11aSIsImljb25Db2xvcjEiOiIjM2Y2MWZmIiwicm9sZV9pZCI6IjE0NjUxNjE5Mzg1NzE0MDczNjEiLCJzY29wZSI6WyJhbGwiXSwicG9zdE5hbWUiOiLpppbluK3miafooYzlrpgiLCJvYXV0aF9pZCI6IiIsImV4cCI6MTYzODU3NDc4NCwianRpIjoiMzQ2MjQwNjItMzAwOS00YTc0LTgxZjItZTViZmY0YjhkZDIxIiwic2V4IjoxLCJhdmF0YXIiOiIiLCJhdXRob3JpdGllcyI6WyJhZG1pbiJdLCJjaGVja0ZsYWciOjAsInJvbGVfbmFtZSI6ImFkbWluIiwibGljZW5zZSI6InBvd2VyZWQgYnkgbGlicmEiLCJwb3N0X2lkIjoiMTQ2NTE2MTk0MDk3NDc0MzU1NCIsImN1c3RvbVRoZW1lIjoiIzNmNjFmZiIsInVzZXJfaWQiOiIxNDY1MTYxOTQ4OTc0OTExNDg5IiwicGhvbmUiOiIiLCJuaWNrX25hbWUiOiJ1c2VySE93SjVwZGoiLCJkZXRhaWwiOnsidHlwZSI6IndlYiIsInVzZXJEZXRhaWxJZCI6IjE0NjUxNjE5NDg5NDk3NDU2NjUifSwiZGVwdF9pZCI6IjE0NjUxNjE5NDA5NjYzNTQ5NDUiLCJhY2NvdW50IjoiYWRtaW4ifQ.r3eoqwlc_AxBZEmSD0NeiyukfycYl2JfQo28_NB7T08
===Headers===  Accept-Language: zh-CN,zh;q=0.9
===Headers===  Content-Length: 32
===Headers===  Content-Type: application/json;charset=UTF-8
================   Request End   ================

[XNIO-1 task-29] INFO org.springblade.bladex.core.mp.plugins.SqlLogInterceptor - 

==============  Sql Start  ==============
Execute SQL : insert into plan_sign (id, plan_id, create_user, create_dept, create_time , update_user, update_time, status, is_deleted, tenant_id) values (1466602446770946049, 1465167353176719362, 1465161948974911489, 1465161940966354945, TIMESTAMP '2021-12-03 10:57:26.123' , 1465161948974911489, TIMESTAMP '2021-12-03 10:57:26.123', 1, 0, '956176')
Execute Time: 110.467ms
==============  Sql  End   ==============

[XNIO-1 task-29] INFO org.springblade.bladex.core.mp.plugins.SqlLogInterceptor - 

==============  Sql Start  ==============
Execute SQL : select id, plan_id, user_id, user_detail_id, create_user , create_dept, create_time, update_user, update_time, status , is_deleted from plan_middle_user where is_deleted = 0 and plan_id = 1465167353176719362
Execute Time: 3.819ms
==============  Sql  End   ==============

[XNIO-1 task-29] INFO org.springblade.bladex.core.log.aspect.RequestLogAspect - 

================  Response Start  ================
===Result===  {"code":200,"success":true,"data":null,"msg":"操作成功"}
<=== POST: /plansign/save (3652 ms)


2条回答
  •  admin
    admin (最佳回答者)
    2021-12-04 00:40

    慢代码场景调试其实都是一个最基础的方向,那就是逐个删代码并验证。

    删掉你认为有问题的部分,然后运行看响应时间。比如某一个代码块删掉后速度变快了,那自然就是他的问题,那就可以删掉其他的部分,保留代码块。再到代码块的基础上逐个删,再验证,直到找到最终影响的代码。

    0 讨论(1)
  • 这个要结合你具体的业务代码分析。

    0 讨论(0)
提交回复