44

I am creating tree with some custom control prepared with JavaScript/jquery.

For creating the tree we are supplying json object as the input to java-script to iterate through and create the tree.

Since the volume of data may go up-to 25K nodes. during a basic load test we identified that the browser will be crashed for such volume.

The alternate solution is just load first level of the nodes and rest load on demand via AJAX request. the volume of first level can vary up-to 500 - 1K nodes.

What is the max size a json should have as a response from the server. What could be the best approach to process such volume of data on browser.

ankur
  • 4,565
  • 14
  • 64
  • 100
  • There is no size limit, I have dealt with Ajax requests which took 5 seconds to complete. – hrishikeshp19 Jan 20 '12 at 06:53
  • 3
    @hrishikeshp19 And so have I, and there was also only 500 bytes worth of data... what's the size limit got to do with your temporal quantification? – Jeach Apr 29 '13 at 21:31
  • 1
    I always thought there were limits... so I ran a very simple Ajax loop where I would send a PHP/Apache script a URL request (it sent it right back), incrementing the 'data payload' by one character on each loop. When my data size reached '8097 bytes', I received a: "414 (Request-URI Too Large)" message from the server. You can view more details of the 414 error all over if you Google it... this is the Wiki page: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes – Jeach Apr 29 '13 at 21:43
  • Note that my comment above is for GET requests... only realized now that the question is specific to a response to the browser. – Jeach Apr 30 '13 at 14:25
  • 1
    This blog post [How Big is TOO BIG for JSON](http://www.ziggytech.net/technology/web-development/how-big-is-too-big-for-json/) may be relevant. It shows test results for loading JSON in various browsers. – G. Lombard Sep 19 '13 at 05:43
  • @Jeach, off topic comment, but in such methods it is good too make it faster to find by increasing number greatly (for example double it), and if limit found - narrow the search – Andrzej Martyna Jul 28 '17 at 04:24
  • https://stackoverflow.com/questions/51687462/firefox-developer-tools-truncates-long-network-response-chrome-does-not-show – tirenweb Nov 22 '22 at 14:00

4 Answers4

17

There is no max size limit of the http response (or the max size of Int or the limit of browser or the limit of server have been configured).

The best approach is use AJAX to load part of data while it need to be shown.

xdazz
  • 158,678
  • 38
  • 247
  • 274
  • 16
    Ther are max sizes in some browser, which depends on how the Json will be evaluated. The mobile safari will not eval() a json, if it is larger than 10 MB – Christian Kuetbach Jan 20 '12 at 06:38
  • 3
    Also probably worth noting that [servers can have max sizes](http://forums.asp.net/t/1090853.aspx/1) as well. – ruffin Mar 27 '12 at 18:30
  • @ChristianKuetbach do you know of a reference for that 10 MB limitation? I think I am running up against it. Thanks! – qwwqwwq Jun 22 '15 at 02:54
  • I need to use complete json data in calculation so can't use ajax for load partial data and loading all data together crashing browser, Can anyone help? – Chetan S. Choudhary Dec 15 '16 at 11:27
  • 1
    I'm getting something very odd with a 22MB response that works in (Chromium) Edge but just errors out every time in Chrome when I try to get the JSON data. If I then if I activate 'Replay XHR' on the network panel it loads just fine every time (but only in the network panel). In other words my server is 100% not crashing but Chrome gives no useful error at all and the response is only a couple hundred bytes. It's very odd. – Simon_Weaver Apr 20 '22 at 21:48
11

An HTTP response has no size limit. JSON is coming as an HTTP response. So it has no size limit either.

There might be problem if the object parsed from JSON response consumes too much memory. It'll crash the browser. So it's better you test with different data sizes and check whether your app works correctly.

I think lazy-loading is the best approach for such large amounts of data. Especially when dealing with object literals.

See High Performance Ajax Application presentation from Yahoo.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
4

Well I think I am too late to give my two cents. Complementing shiplu.mokadd.im's answer browser memory is a limitation and HTTP response can have any amount of data according to the TCP spec.

But I have an application that uses Google Chrome (version 29.0.xx) and Jetty server where response from the Jetty server has a payload amounting to 335MB. While the browser is receiving the response of that sheer size Chrome stops leaving the message "IPC message is too big". Though this is specific to Google Chrome(not sure about other browsers), there should be a threshold on the max size of response.

Bunti
  • 1,730
  • 16
  • 20
0

There is no max size limit but the size depends the client system's (The system in which browser exists) RAM, CPU, Network bandwidth to parse the large json data. If the system is low end and with the large json data then the browser hangs.

krishna
  • 99
  • 9