I'm calling a PHP REST API from an iOS app to retrieve data from my MySQL database. I wanted to know if there is a size limit on the amount of data I can receive via a HTTP GET request, given that it's serialized as JSON.
Asked
Active
Viewed 1.0k times
1
-
Its only limited by your mysql database, how much connections shes allow. – BlackNetworkBit Sep 09 '18 at 12:13
-
[link]https://stackoverflow.com/questions/7724270/max-size-of-url-parameters-in-get – Jamie_D Sep 09 '18 at 12:15
-
@jamie_D I mean size limit for JSON response not the parameter size limit – Micheal Powers Sep 09 '18 at 12:19
-
Ah ... right. I believe that would be browser specific. [link]https://technomanor.wordpress.com/2012/04/03/maximum-url-size/ That link is old and specs may have changed – Jamie_D Sep 09 '18 at 12:38
2 Answers
3
Is there a size limit for HTTP GET requests with JSON bodies?
No, there is no size limit in HTTP, but there might be a limit elsewhere.
HTTP response bodies may have an arbitrary size, though there are several other factors that might enforce a hard limit:
- In your specific case, PHP itself. PHP has a configuration variable named
memory_limit
which imposes a limit for the PHP process. - Your physical memory. The problem with sending out JSON is that, unless you have a very special setup and are streaming the response, the entire JSON payload needs to be buffered in your server's memory (alongside the result rows from your query!).
In practice, memory_limit
will be the first limit that you will hit. It's usually advisable to use LIMIT
in your SQL queries and paginate the responses. Sending out over, say, 1 MiB of JSON is generally not a very good idea.

Chiru
- 3,661
- 1
- 20
- 30
1
I believe there are no size limitations with JSON requests. Any direct limitations, however, could be caused or set by the parsing of the request via the server. Therefore, it's possible to think that perhaps the MySQL DB itself may have some. Hope this helps!

Sophia
- 46
- 3
-
1Thanks is there a way you can check the size of the Json response – Micheal Powers Sep 09 '18 at 12:20
-
1