为什么同步 RPC 不好
在阅读有关 Google Webtool 套件的内容时,发现了一个声明:“同步 RPC 很糟糕”。他们有什么理由吗?我能想到的一个很好的理由是,对最终用户的响应可能会受到远程服务器中的任何延迟或网络问题的影响。
谁能说出具体原因是什么?
预先感谢大家。
While reading about Google webtool kit, came across a statement saying 'synchronous RPCs are bad'. Any reason why they are? One good reason i could think of is the response to end user may be impacted by any lag in the remote server or due to networking issues.
Can anyone tell what the exact reasons are?
Thank you all in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜 GWT 正在谈论从浏览器中运行的 javascript 代码到服务器的同步 RPC。这确实很糟糕,因为 JavaScript 是单线程的,从 JavaScript 线程执行冗长的同步 RPC 调用会使浏览器页面无法响应:GUI 被冻结,直到 RPC 调用结束。
这就是为什么 AJAX 默认情况下是异步的:它允许向服务器发出异步请求,这让浏览器处于响应状态。当响应返回时,调用回调方法来处理结果。
I guess GWT is talking about synchronous RPC from the javascript code running in the browser to the server. And it's indeed bad, because JavaScript is single-threaded, and doing a lengthy synchronous RPC call from the JavaScript thread makes the browser page not responsive: the GUI is frozen until the RPC call ends.
That's why AJAX is asynchronous by default: it allows making asynchronous requests to the server, which lets the browser in a responsive state. When the response comes back, a callback method is called to handle the result.