【发布时间】:2018-10-23 16:04:09
【问题描述】:
我正在创建一个端点来检索我的一些数据,并在此调用中调用 3 个不同的 REST 调用,因此它会妨碍我的应用程序的性能。
My Endpoint Code:
1. REST call to get the userApps()
2. iterate over userAPPs
2.1 make REST call to get the appDetails
2.2 make use of above response to call the 3rd REST call which returns list.
2.3 iterate over the above list and filter out the required fields and put it in main response object.
3.return response
所以,这么多的复杂性会影响性能。
我尝试添加多线程概念,但是普通代码和多线程所花费的时间几乎相同。
条件是,我们不能修改 3 个外部 REST 调用来支持分页。
我们无法添加分页,因为我们没有任何数据库。 有什么解决办法吗?
【问题讨论】:
-
你用的是spring boot吗?
-
由于调用依赖于 prev 的结果。调用,我们不能使调用异步。您可以通过使用 RPC 调用来减少休息时间。微服务架构也支持它们。
-
@Naveen 是的,我正在使用 Spring boot
-
@AdityaGupta 我以前没有使用过 RPC,但它会支持还是会减少 100 次迭代的时间?
-
RPC 减少了网络周转时间(或任何术语,用于将回复返回给调用者),因此单个调用会更快。就是这样,我们可以在这里做什么。
标签: java multithreading rest caching pagination