0

Context

I've written a simple service that consists of

  • A Python Script
  • Running in Flask Framework
  • Hosted on Heroku - (currently running 1 dyno)

The mechanics of the data transfer are somewhat unique

  • Something calls the Heroku app
  • The Heroku app uses urllib2.urlopen to call a Google-GTFS api and the python script parses this data using the GTFS python module
  • Then the python returns (json.dumps) JSON

Issue

I've run a blitz.io test on this service with with 30 concurrent users and I get a bunch of timeout issues.

The heroku logs show a bunch of these errors

2013-10-13T02:30:20.101085+00:00 heroku[router]: at=error 
    code=H19 desc="Backend connection timeout" method=GET path=myapppath myappurl fwd=ipaddress dyno=web.1 connect=5001ms service= status=503 bytes=

Question

How do I fix this?

drc
  • 1,905
  • 4
  • 22
  • 28

1 Answers1

0

Excerpt from the documentation for the H19 Heroku error:

A router received a connection timeout error after 5 seconds attempting to open a socket to a web dyno. This is usually a symptom of your app being overwhelmed and failing to accept new connections in a timely manner. If you have multiple dynos, the router will retry multiple dynos before logging H19 and serving a standard error page.

How many dynos do you use? Sounds like you may need more to be able to handle the load of 30 concurrent users.

Depending on your application, it may also help to have a cache layer that prevents you from having to connect to the GTFS service for every single request.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152
  • Thanks for looking into this! I have one dyno, ideally I'd like to keep it at that to keep it free. Any tips on building a cache layer? I've never done that before. – drc Oct 13 '13 at 20:17
  • Take a look at Flask-Cache and see if that could work for your application. That could help if you find you are issuing the same request to GTFS over and over, but it won't help if the requests are all different. Unfortunately you don't have a lot of options at the "free" service level. – Miguel Grinberg Oct 14 '13 at 00:42
  • Well the entire dataset that the GTFS returns is pretty small - so I could download the entire set and cache that and I'd be covered. – drc Oct 14 '13 at 04:23