REST API和网络延迟

时间:2015-02-10 16:46:48

标签: java performance rest amazon-web-services profiling

我们使用HTML5构建的Web应用程序(Angular)JS,它与后端的REST API进行通信。 后端使用Java(Jersey)和H2数据库开发,部署在亚马逊托管的tomcat应用服务器上。

我使用审计日志记录(AOP)计算Rest服务的执行时间,并注意到服务花费的时间与端到端调用的执行时间之间的执行时间差异很大。

我们存储了许多工作流,每个工作流包含一个文件(JSON),每次提取的文件总大小约为90Kb(因此,如果我们获得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

EndToEnd:

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

检索分页大小为50的工作流:

从服务器日志:

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

EndToEnd:

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

所以我看到服务器上的服务器执行时间和endToEnd之间的差异的线性评估(每次x10 / 20)。

有没有人对如何进一步阐述有一个好主意? 也许它是必须通过网络推送的文件大小和gzipping它可以为我提供时间的好处? 也许还有其他一些想法或经历? 也许我可以用一些工具来进一步调查需要花费这么多时间的东西?

0 个答案:

没有答案