以小批量方式向服务发送大请求 (Java)
我使用一个大型 Java Web 应用程序,该应用程序使用服务返回信息。我的主要目标是尽快检索 100 多个单独的结果。我们注意到,发送 100 多个信息请求并不能为我们提供数据回复的最佳性能。我们的解决方案是将 100 多个请求分成小批量(~15,25),并在收到所有请求后将它们组装起来。
我正在寻找 Java 中的建议,从应用程序向服务发出 1、50 或 200 个请求,将信息返回到应用程序,并在有更多请求时执行另一批。如果没有剩余请求,则组装到列表中并返回完整列表。
欢迎任何形式建议,谢谢。
I work with a large Java web application which uses a service to return information. My key goal is to retrieve 100+ individual results as quick as possible. We've noticed that sending 100+ requests for information doesn't give us the best performance on the replies of data. Our solution was to break the 100+ requests into small batches (~15,25) and assemble them once all have been received.
I'm looking for a suggestion in Java to make 1 or 50 or 200 requests from the application, to the service, get back info to the application and perform another batch if there are more requests. If no requests left, assemble into on list and return that full list.
Any suggestions of form are welcome, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用 Spring Integration 来处理这种事情。您可以设置一个可配置的消息拆分器,它会分割您的请求并发送许多微小的请求,以及一个消息聚合器,它知道何时收到所有响应,然后可以给您返回一个结果。
Spring 还有一个名为 Spring Batch 的产品,它可能是一个有用的替代方案,但更多的是对于繁重的批处理,这听起来不像你正在做的。
I use Spring Integration for this kind of thing. You can set up a configurable message splitter that chops up your request and sends off many tiny ones, and a message aggregator that knows when it has received all responses and can then give you back a single result.
Spring also has a product called Spring Batch that might be a useful alternative, but that is more for heavy batch processing which it doesn't sound like you are doing.
如果可能/可行,扩展/service以支持在单个协议请求中处理多个逻辑请求;例如HTTP请求。
理论上,如果服务器端收到单个请求,客户端和服务器端都应该能够以更少的开销完成工作。客户端和服务器端都应该节省成本。
If possible / feasible, extend the /service to support handle multiple logical requests in a single protocol request; e.g. HTTP request.
In theory, the both the client and server side should be able to do the work with less overheads if the server side gets a single request. There should be savings on both the client and server sides.