0

I have a Flask (Python) application running on Passenger which works absolutely fine when I test it and I'm the only user.

But as soon as I attempt to have several concurrent connections, each client waits forever for a response. I have tried it with 50 concurrent users, which seems like it should easily be supported.

The app is very simple, reading and writing to a SQLite database once or twice. (Concurrent access of SQLite by this small number of users is not a problem.)

What am I missing?

Community
  • 1
  • 1
LondonRob
  • 73,083
  • 37
  • 144
  • 201
  • You're going to have to give some more information about how it's being served. sqlite is unlikely to be the bottleneck; how many processes/threads is passenger using? – Daniel Roseman Feb 06 '17 at 14:16
  • @DanielRoseman thanks for your comment. I think I have found [my answer](http://stackoverflow.com/a/42069933/2071807) (although it's hard to test until I have another 50 users to try it on.) I wanted to post this because I struggled to get help via Google. – LondonRob Feb 06 '17 at 14:19

1 Answers1

1

In the Passenger docs it makes the following suggestion:

Passenger also supports the magic file 'tmp/always_restart.txt'. If this file exists, Passenger will restart your application after every request. This way you do not have to invoke the restart command often.

Activate this mechanism by creating the file:

$ mkdir -p tmp

$ touch tmp/always_restart.txt

This is great for development because it means you only need to save your Python files for the latest version of the app to be available to clients.

But it's terrible for production because every client makes its own request and that restarts the Python app. This is a very major overhead for the server, so users are likely to timeout before receiving a response.

Delete the file tmp/always_restart.txt and your concurrency limits will shoot up.

LondonRob
  • 73,083
  • 37
  • 144
  • 201