Http request fails due to json size - 503 response and Heroku H13 error

I have a simple flask program running on heroku:

from flask import Flask
app = Flask(__name__)

@app.route('/test', methods=['POST'])
def test():
    return 'OK'


Unbelievably it succeeds or fails, depending on the size of the json I'm sending. Here's the test code:

import json, random, string, requests

def rand_string(size):
    return ''.join([random.choice(string.letters) for i in xrange(size)])

for size in (4000, 10000):
    r ='',
                      headers={'content-type': 'application/json'})
    print r.status_code


On first call it returns status 200, second status 503 http with error code H13 heroku.

2014-09-18T08:23:46.594543+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/test" request_id=91b1cd91-5a4f-445e-ad52-3c64733154b3 fwd="" dyno=web.1 connect=5ms service=13ms status=503 bytes=0


HTTP response 503 means:


currently unable to process the request due to temporary overload or server maintenance

This cannot be the case as the server is running and not loaded, apart from my manual tests.

Heroku H13 Code Documentation says:

This error occurs when a process is in your web dino connection but then closes the socket without writing anything.

However, all code matters return 'OK'

, so it is not code.

Does heroic limit the request size? A hunting ship? How can I know and how to configure it otherwise?


source to share

1 answer

You may have been influenced by gunicorn's timeout mechanism, which defaults to 30 seconds. If serialization takes longer for some reason, the worker is killed and restarted.



All Articles