后端返回前端的数据量过大解决方案
性能面板(Performance) · chrome调试指南
原因
遇到一个页面有好几个表格,部分表格采用虚拟滚动条
数据量有点大
接近快60s了,看一下是哪里导致的慢
后台请求方法执行并不慢
2024-12-04 15:21:52.889 INFO 69948 --- [nio-8004-exec-7] s.d.e.i.SecurityEventMonitorDaoHibernate : build sql time: 4ms
2024-12-04 15:21:52.889 INFO 69948 --- [nio-8004-exec-5] s.d.e.i.SecurityEventMonitorDaoHibernate : build sql time: 4ms
2024-12-04 15:21:52.889 INFO 69948 --- [nio-8004-exec-8] s.d.e.i.SecurityEventMonitorDaoHibernate : build sql time: 4ms
2024-12-04 15:21:52.889 INFO 69948 --- [io-8004-exec-10] s.d.e.i.SecurityEventMonitorDaoHibernate : build sql time: 4ms
2024-12-04 15:21:58.276 INFO 69948 --- [nio-8004-exec-8] s.d.e.i.SecurityEventMonitorDaoHibernate : exec sql [select * from ( select * from SECURITY_EVENT_MONITOR_202411 union all select * from SECURITY_EVENT_MONITOR_202412) where 1=1 and alarmTime >= to_date('2024-11-30','yyyy-MM-dd') and alarmTime <= to_date('2024-12-03','yyyy-MM-dd')] time: 5392ms
2024-12-04 15:21:58.276 INFO 69948 --- [nio-8004-exec-5] s.d.e.i.SecurityEventMonitorDaoHibernate : exec sql [select * from ( select * from SECURITY_EVENT_MONITOR_202411 union all select * from SECURITY_EVENT_MONITOR_202412) where 1=1 and alarmTime >= to_date('2024-11-30','yyyy-MM-dd') and alarmTime <= to_date('2024-12-03','yyyy-MM-dd')] time: 5392ms
2024-12-04 15:21:58.283 INFO 69948 --- [nio-8004-exec-7] s.d.e.i.SecurityEventMonitorDaoHibernate : exec sql [select * from ( select * from SECURITY_EVENT_MONITOR_202411 union all select * from SECURITY_EVENT_MONITOR_202412) where 1=1 and alarmTime >= to_date('2024-11-30','yyyy-MM-dd') and alarmTime <= to_date('2024-12-03','yyyy-MM-dd')] time: 5398ms
2024-12-04 15:21:58.297 INFO 69948 --- [io-8004-exec-10] s.d.e.i.SecurityEventMonitorDaoHibernate : exec sql [select * from ( select * from SECURITY_EVENT_MONITOR_202411 union all select * from SECURITY_EVENT_MONITOR_202412) where 1=1 and alarmTime >= to_date('2024-11-30','yyyy-MM-dd') and alarmTime <= to_date('2024-12-03','yyyy-MM-dd')] time: 5412ms
2024-12-04 15:21:58.412 INFO 69948 --- [io-8004-exec-10] s.d.e.i.SecurityEventMonitorDaoHibernate : transform data time: 5527ms
2024-12-04 15:21:58.414 INFO 69948 --- [nio-8004-exec-5] s.d.e.i.SecurityEventMonitorDaoHibernate : transform data time: 5527ms
2024-12-04 15:21:58.481 INFO 69948 --- [nio-8004-exec-8] s.d.e.i.SecurityEventMonitorDaoHibernate : transform data time: 5595ms
2024-12-04 15:21:58.482 INFO 69948 --- [nio-8004-exec-7] s.d.e.i.SecurityEventMonitorDaoHibernate : transform data time: 5597ms
2024-12-04 15:21:58.485 INFO 69948 --- [nio-8004-exec-8] .s.s.e.i.SecurityEventMonitorServiceImpl : build queryGrid4 data cost time:2ms
2024-12-04 15:21:58.553 INFO 69948 --- [nio-8004-exec-7] .s.s.e.i.SecurityEventMonitorServiceImpl : build queryGrid1 data cost time:70ms
2024-12-04 15:21:58.562 INFO 69948 --- [nio-8004-exec-7] com.wisdom.facade.BizWebServiceSkeleton : Biz web service skeleton process request done
2024-12-04 15:21:58.562 WARN 69948 --- [nio-8004-exec-7] com.wisdom.facade.BizWebServiceSkeleton : request = com.wisdom.imd.wypap.security.dto.event.SecurityEventMonitorDto, method = queryGrid1, cost = 5690 ms
2024-12-04 15:21:58.562 INFO 69948 --- [io-8004-exec-10] .s.s.e.i.SecurityEventMonitorServiceImpl : build queryGrid3 data cost time:149ms
2024-12-04 15:21:58.564 INFO 69948 --- [io-8004-exec-10] com.wisdom.facade.BizWebServiceSkeleton : Biz web service skeleton process request done
2024-12-04 15:21:58.564 WARN 69948 --- [io-8004-exec-10] com.wisdom.facade.BizWebServiceSkeleton : request = com.wisdom.imd.wypap.security.dto.event.SecurityEventMonitorDto, method = queryGrid3, cost = 5692 ms
exec method : queryGrid3 time: 5709ms
exec method : queryGrid1 time: 5709ms
2024-12-04 15:21:58.571 INFO 69948 --- [nio-8004-exec-8] com.wisdom.facade.BizWebServiceSkeleton : Biz web service skeleton process request done
2024-12-04 15:21:58.571 WARN 69948 --- [nio-8004-exec-8] com.wisdom.facade.BizWebServiceSkeleton : request = com.wisdom.imd.wypap.security.dto.event.SecurityEventMonitorDto, method = queryGrid4, cost = 5699 ms
exec method : queryGrid4 time: 5712ms
2024-12-04 15:21:59.711 INFO 69948 --- [nio-8004-exec-5] .s.s.e.i.SecurityEventMonitorServiceImpl : build queryGrid2 data cost time:1297ms
2024-12-04 15:21:59.713 INFO 69948 --- [nio-8004-exec-5] com.wisdom.facade.BizWebServiceSkeleton : Biz web service skeleton process request done
2024-12-04 15:21:59.713 WARN 69948 --- [nio-8004-exec-5] com.wisdom.facade.BizWebServiceSkeleton : request = com.wisdom.imd.wypap.security.dto.event.SecurityEventMonitorDto, method = queryGrid2, cost = 6841 ms
exec method : queryGrid2 time: 6854ms
后台并行请求了4分方法,这个最慢接近60s,直接看一下这个为什么,找到占比最多的时间在执行什么方法
我靠,返回这么大,主要是解析后台加密的json
数据过大导致
json会存储额外的结构,易读,但是数据量过大时性能不好
序列化使用json肯定说改不了了,只能想办法去节省传输的内容大小