Java RESTAPI和网络延迟

Java RESTAPI和网络延迟,java,performance,rest,amazon-web-services,profiling,Java,Performance,Rest,Amazon Web Services,Profiling,我们使用一个用HTML5构建的web应用程序,它是一个与后端的RESTAPI通信的Angular JS。 后端是使用JavaJersey和H2数据库开发的,部署在托管在Amazon上的tomcat应用服务器上 我使用审计日志AOP对Rest服务的执行时间进行了计时,并注意到在服务中花费的时间与端到端调用的执行时间之间存在很大的差异 我们存储了很多工作流,每个工作流都包含一个总文件大小约为90Kb的JSON文档,每次都会获取该文档。因此,如果我们获得50个工作流,则会通过网络返回50个90Kb大小

我们使用一个用HTML5构建的web应用程序,它是一个与后端的RESTAPI通信的Angular JS。 后端是使用JavaJersey和H2数据库开发的,部署在托管在Amazon上的tomcat应用服务器上

我使用审计日志AOP对Rest服务的执行时间进行了计时,并注意到在服务中花费的时间与端到端调用的执行时间之间存在很大的差异

我们存储了很多工作流,每个工作流都包含一个总文件大小约为90Kb的JSON文档,每次都会获取该文档。因此,如果我们获得50个工作流,则会通过网络返回50个90Kb大小的文档

以下是我的经验:

正在检索分页大小为1的工作流:

从服务器日志中:

GET Request: Get all workflows with range [items=1-2]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete

GET Request: Get all workflows with range [items=2-3]
[PROFILING] WorkflowRestService method GetAll took [28] millis to complete

GET Request: Get all workflows with range [items=3-4]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete

GET Request: Get all workflows with range [items=4-5]
[PROFILING] WorkflowRestService method GetAll took [25] millis to complete

GET Request: Get all workflows with range [items=5-6]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete
GET Request: Get all workflows with range [items=1-50]
[PROFILING] WorkflowRestService method GetAll took [108] millis to complete

GET Request: Get all workflows with range [items=51-100] 
[PROFILING] WorkflowRestService method GetAll took [106] millis to complete

GET Request: Get all workflows with range [items=101-150]
[PROFILING] WorkflowRestService method GetAll took [109] millis to complete

GET Request: Get all workflows with range [items=151-200]
[PROFILING] WorkflowRestService method GetAll took [112] millis to complete

GET Request: Get all workflows with range [items=201-250]
[PROFILING] WorkflowRestService method GetAll took [106] millis to complete
结束结束:

Time to retrieve items [1-2] took 299 millis
Time to retrieve items [2-3] took 388 millis
Time to retrieve items [3-4] took 406 millis
Time to retrieve items [4-5] took 477 millis
Time to retrieve items [5-6] took 370 millis
Time to retrieve items [1-50] took 1777 millis
Time to retrieve items [51-100] took 753 millis
Time to retrieve items [101-150] took 1143 millis
Time to retrieve items [151-200] took 1709 millis
Time to retrieve items [201-250] took 1703 millis
正在检索分页大小为50的工作流:

从服务器日志中:

GET Request: Get all workflows with range [items=1-2]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete

GET Request: Get all workflows with range [items=2-3]
[PROFILING] WorkflowRestService method GetAll took [28] millis to complete

GET Request: Get all workflows with range [items=3-4]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete

GET Request: Get all workflows with range [items=4-5]
[PROFILING] WorkflowRestService method GetAll took [25] millis to complete

GET Request: Get all workflows with range [items=5-6]
[PROFILING] WorkflowRestService method GetAll took [26] millis to complete
GET Request: Get all workflows with range [items=1-50]
[PROFILING] WorkflowRestService method GetAll took [108] millis to complete

GET Request: Get all workflows with range [items=51-100] 
[PROFILING] WorkflowRestService method GetAll took [106] millis to complete

GET Request: Get all workflows with range [items=101-150]
[PROFILING] WorkflowRestService method GetAll took [109] millis to complete

GET Request: Get all workflows with range [items=151-200]
[PROFILING] WorkflowRestService method GetAll took [112] millis to complete

GET Request: Get all workflows with range [items=201-250]
[PROFILING] WorkflowRestService method GetAll took [106] millis to complete
结束结束:

Time to retrieve items [1-2] took 299 millis
Time to retrieve items [2-3] took 388 millis
Time to retrieve items [3-4] took 406 millis
Time to retrieve items [4-5] took 477 millis
Time to retrieve items [5-6] took 370 millis
Time to retrieve items [1-50] took 1777 millis
Time to retrieve items [51-100] took 753 millis
Time to retrieve items [101-150] took 1143 millis
Time to retrieve items [151-200] took 1709 millis
Time to retrieve items [201-250] took 1703 millis
因此,每次x10/20时,我看到服务器上的服务器执行时间与endToEnd之间的差异是线性的

有没有人对我如何进一步阐述有好的想法? 也许是文件大小必须通过网络推送,而压缩它可以为我提供时间优势? 也许有其他的想法或经历?
也许我可以使用一些工具来进一步调查什么需要这么多时间?

您是否想过缩小服务器返回的JSON响应?删除空间等以减小大小,其次启用输出压缩可能是有意义的,但首先我会对备选方案进行基准测试,并确定最佳行动原因。您是否在问为什么必须处理/服务更大的数据集,然后通过网络传输它需要更多时间?您将能够提高性能的地方是高度随机应变的。