同时,异步Ajax请求的合理数量 [英] A reasonable number of simultaneous, asynchronous ajax requests

查看:332
本文介绍了同时,异步Ajax请求的合理数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的共识是多​​少同步异步Ajax请求的是一般允许的。

I'm wondering what the consensus is on how many simultaneous asynchronous ajax requests is generally allowable.

我想问的原因,是我工作的个人的Web应用程序。在大多数情况下我把我的请求到之一。但也有我的地方同时发送最多4个请求一些情况。这会导致一比特延迟的,因为浏览器将只处理2的时间。

The reason I ask, is I'm working on a personal web app. For the most part I keep my requests down to one. However there are a few situations where I send up to 4 requests simultaneously. This causes a bit of delay, as the browser will only handle 2 at a time.

的延迟是不可用性方面的问题,目前是这样。而这将是一段时间之前,我担心的可扩展性,如果有的话。但是我想坚持最佳实践,尽可能合理。你有什么想法? 4请求一个合理的数字?

The delay is not a problem in terms of usability, for now. And it'll be awhile before I have to worry about scalability, if ever. But I am trying to adhere to best practices, as much as is reasonable. What are your thoughts? Is 4 requests a reasonable number?

推荐答案

这真的取决于它是否工作那样正常。如果应用程序的逻辑构建了4 simultaneos请求有道理,像这样做。如果逻辑不被打包多个请求打扰到一个请求,你能做到这一点,但只有当它不会使code更复杂。保持它的简单和直接的,直到你有问题,那么你就可以开始优化。

That really depends on if it works like that properly. If the logic of the application is built that 4 simultaneos requests make sense, do it like this. If the logic isn't disturbed by packing multiple requests into one request you can do that, but only if it won't make the code more complicated. Keep it as simple and straight forward until you have problems, then you can start to optimize.

不过你可以问问自己,如果应用程序的设计可以提高,没有必要的多个请求。

But you can ask yourself if the design of the app can be improved that there is no need for multiple requests.

还要检查它放在一个很慢的连接。同时http请求不一定执行正确的顺序在服务器上,它们也可以返回以不同的顺序。这可能给问题,你会在速度较慢的线路既能体验。

Also check it on a really slow connection. Simultaneous http requests are not necessarily executed on the server in the proper order and they might also return in a different order. That might give problems you'll experience only on slower lines.

这篇关于同时,异步Ajax请求的合理数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆