将大型阵列传输到客户端
I need to transfer a large array of 16 bit integers to a client using an AJAX request to a web service. This array is essentially grey-scale pixel data for an image with some additional meta data.
我需要使用对Web服务的AJAX请求将大量16位整数传输到客户端。该阵列本质上是具有一些附加元数据的图像的灰度像素数据。
The original image is in a proprietary format that is not supported by browsers. A typical image is 2000px x 4000px so the array could contain 8,000,000+ 16bit values.
原始图像采用浏览器不支持的专有格式。典型图像为2000px x 4000px,因此阵列可包含8,000,000+ 16位值。
Is it acceptable to make one AJAX request and return this entire array in one response or should I split into into smaller chunks and request each individually? If it is an accepted practice to transfer the whole array in one response, would I have to handle unreliable connections during the request (or does that come 'out of the box' in the browsers)?
是否可以制作一个AJAX请求并在一个响应中返回整个数组,还是应该分成更小的块并单独请求每个?如果在一个响应中传输整个数组是公认的做法,我是否必须在请求期间处理不可靠的连接(或者在浏览器中是否“开箱即用”)?
We are writing both the client and the web service so we are entirely flexible on our approach.
我们正在编写客户端和Web服务,因此我们对方法完全灵活。
2 个解决方案
#1
0
The data you need to transfer is more than 16 MB in size, but you should get a smaller size by using gzip given the fact that you're working with unarchived data. Also you should think about a very fast serialization format (because you will need a lot of processing both on the client and the server to serialize/deserialize the data).
您需要传输的数据大小超过16 MB,但考虑到您正在使用未归档数据这一事实,您应该使用gzip获得更小的大小。您还应该考虑一种非常快速的序列化格式(因为您需要在客户端和服务器上进行大量处理才能序列化/反序列化数据)。
更多相关文章
- 如何使用Angular.js从json文件中使用id获取特定数据
- javaScript怎么实现双向数据绑定
- 使用Directive通过AngularJS使用指令和数据绑定来注入HTML
- 一旦db通过Node.js发生更新,就立即推送数据
- ng- repeat显示的行等于no属性,甚至不显示html视图上的数据
- 将数据从AJAX请求序列化到PHP
- 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什
- 访问D3的var格式数据
- HTML/JS作为本地SQLite数据库的接口