非常大的HTTP请求与许多小请求 [英] Very large HTTP request vs many small requests

查看:247
本文介绍了非常大的HTTP请求与许多小请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能的重复:

非常大的HTTP请求与许多小请求

我需要一个2D数组(如Json)从服务器发送到客户端。它将是大约400X400大小,每个条目大约4个字符的文本。

I need a 2D array(as Json) to be sent from server to client. It would be around 400X400 in size with each entry around 4 characters of text. So that makes it around 640KB of data.

以下哪种极端方法更好?

Which of the following extreme approaches is better ?

    $ b
  1. 我发出400个请求 - 每个请求一行(约1.6 KB)

  1. I make a large HTTP request of all the data at one go.
  2. I make 400 requests - each asking for a single row (around 1.6 KB)

我相信最佳方法会在中间。有谁能给我一个想法什么可能是这个数据的最佳单个请求大小。

I believe optimal approach would be somewhere in middle. Could anyone give me an idea what might be the optimal single request size for this data.

感谢,

推荐答案

提出要求时,处理一些开销(如DNS请求,打开连接并关闭它)。

When making a request you always have to deal with some overhead (like DNS request, opening connection and closing it). So it might be wiser to have 1 big request.

当你有一个大的请求时,你可能会遇到更好的gzip / deflate压缩。

Also you might experience better gzip/deflate compression when having 1 big request.

这篇关于非常大的HTTP请求与许多小请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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