1

I'm writing an app for Google App Engine with Java. A certain servlet produces responses that may go over the 32 megabyte limit. On the development server, this does not seem to cause any issues. On the production server, I'll need a way to split the response over several requests.

I want to know what happens on the production server when the limit is exceeded. Does the PrintWriter throw an IOException when the limit is exceeded? Or is an exception only thrown when the servlet terminates? Ideally, I would like to be able to calculate the total response size before appending each section (without counting the bytes myself, because I don't know the size of the HTTP headers), so that I can properly clean up the end of the response (i.e. append "}" to complete the JSON object). Or is there a better way to handle this type of situation?

Zifre
  • 26,504
  • 11
  • 85
  • 105
  • The limit on HTTP requests and responses on App Engine was recently upped to 32MB. Before that, it was 10MB for quite some time. – Nick Johnson Jul 07 '11 at 01:01
  • The docs say 32 MB for requests and 10 MB for responses. Although exceeding this limit is less likely, it's definitely still possible. So I think the question is still valid. – Zifre Jul 07 '11 at 01:10
  • "without counting the bytes myself, because I don't know the size of the HTTP headers". Well, headers are not going to be that large, if you allow 25K for them you should be safe. – Thilo Jul 07 '11 at 01:12
  • Sorry, the docs are out of date in that respect - see the release notes: http://code.google.com/p/googleappengine/wiki/SdkReleaseNotes . Where did you read 10MB? – Nick Johnson Jul 07 '11 at 01:19
  • @Nick Johnson: see the very bottom of http://code.google.com/intl/en/appengine/docs/java/runtime.html. I guess it's out of date. – Zifre Jul 07 '11 at 13:22

1 Answers1

0

nick's right, the current response size limit is 32MB.

app engine buffers response data, so it doesn't see your response until your code has finished running, so it can't raise an exception or otherwise signal an error that your code can catch. instead, it returns a 500 to the client with a body like this:

HTTP response was too large: 34000134. The limit is: 33554432.

you can try it yourself by running this in http://shell.appspot.com/ :

print 'x' * 34 * 1000 * 1000

ryan
  • 2,687
  • 1
  • 29
  • 38
  • Is there *any* way around this? For example, using a custom runtime in `app.yaml`? I am working on a streaming media app that downloads files to the client which are larger than 32MB, and need GCE to support streaming large media files. Currently it appears that GCE (1) buffers response data and (2) may have a 32MB limit (using `runtime: ruby`). – Tronathan Apr 06 '16 at 05:20