*客户端*可扩展性适用于大量远程 Web 服务调用
我想知道您是否可以分享在进行大量时间敏感的 Web 服务调用时的最佳实践和常见错误。
就我而言,我有一个基于 SOAP 和 XML-RPC 的 Web 服务,我经常对其进行调用。我预测随着每秒调用次数的增加,这很快就会成为一个问题。
在更高的层面上,我正在考虑对这些调用进行批处理,并每 100 毫秒将它们提交到 Web 服务。你能分享一下还有什么有效的方法吗?
在较低级别的方面,我使用 Apache Xml-Rpc 客户端和标准 javax.xml.soap.* 包来实现客户端。您是否知道这些软件包与客户端可扩展性相关的技巧/提示/警告?
预先感谢
尤里
I was wondering if you could share best practices and common mistakes when it comes to making large numbers of time-sensitive web service calls.
In my case, I have a SOAP and an XML-RPC based web service to which I'm constantly making calls. I predict that this will soon become an issue as the number of calls per second will grow.
On a higher level, I was thinking of batching those calls and submitting those to the web services every 100 ms. Could you share what else works?
On a lower level side of the things, I use Apache Xml-Rpc client and standard javax.xml.soap.* packages for my client implementations. Are you aware of any client scalability related tricks/tips/warnings with these packages?
Thanks in advance
Yuriy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要意识到的一件事是,在 JavaScript 中,您总是在处理事件泵:某些浏览器事件发生,或者计时器到期,然后执行一段 JavaScript。考虑到该执行模型,您并不真的想考虑进行定期批处理和发送过程 - 您想要做的是将一个事件泵中发生的所有调用(执行的 JavaScript 块)批处理在一起响应来自浏览器的一个事件)并将其发送出去。
这是通过更改您的 rpc 代码来完成的,以便每个调用都将带有参数和回调函数的调用排队到一个全局数组中,如果它正在排队第一个调用,它也会使用
setTimeout(..., 0)
setTimeout(..., 0) 一个函数,它将发送队列中的所有内容并清除数组。从这里开始,然后您可以稍后尝试其他执行模型,例如在收到第一个请求时立即触发它,并在当前事件泵完成后批量发送其他所有内容。
One thing to realize is that in JavaScript you're always dealing with an event pump: some browser event happens, or a timer expires, and then a chunk of JavaScript gets executed. With that execution model in mind, you don't really want to think of having a periodic batch and send process going on - what you want to do instead is batch together all the calls that happen in one event pump (the chunk of javascript executing in response to one event from the browser) and send them off.
This is done by changing your rpc code so that every call queues up calls with parameters and callback functions into a global array, and if it's queueing up the first call it also schedules with
setTimeout(..., 0)
a function that will send off everything in the queue and clear the array.Start with that and then you can experiment later with other execution models, like firing off the first request right when you get it and sending everything else in a batch after the current event pump is done.