We recently switched from running gunicorn with gevent and geventwebsocket workers, to running gunicorn with sync and geventwebsocket workers. The sync workers handle all routes which do not launch asynchronous tasks or make external network requests and the geventwebsocket worker handles those plus /socket.io/. This has improved our stability and backend response times.
Modify the Dockerfile to support launching gunicorn in production configurations with different worker types, using a shell script controlled by environment variables. The shell script also supports a configs directory containing alternative configurations, selected by an environment variable.
Add psycogreen to the dependencies to make psycopg2green thread safe.
Since dividing the routes between sync and geventwebsocket workers is no longer as trivial as dividing between /socket.io/ and everything else, add a new decorator to mark routes as required to be run by greenlets, a command to list all routes including whether they are marked as requiring greenlets, and some enforcement at runtime.
Update the documentation on deployment to include deploying with docker, and share some things we've learned about configuring gunicorn and database connections.
In other minor changes, remove some no longer used dependencies from the Dockerfile, and have it include in the image all directories ending in migrations, to support forks with multiple migration directories.
We recently switched from running
gunicorn
withgevent
andgeventwebsocket
workers, to runninggunicorn
with sync andgeventwebsocket
workers. The sync workers handle all routes which do not launch asynchronous tasks or make external network requests and thegeventwebsocket
worker handles those plus/socket.io/
. This has improved our stability and backend response times.Modify the
Dockerfile
to support launchinggunicorn
in production configurations with different worker types, using a shell script controlled by environment variables. The shell script also supports aconfigs
directory containing alternative configurations, selected by an environment variable.Add
psycogreen
to the dependencies to makepsycopg2
green thread safe.Since dividing the routes between sync and
geventwebsocket
workers is no longer as trivial as dividing between/socket.io/
and everything else, add a new decorator to mark routes as required to be run by greenlets, a command to list all routes including whether they are marked as requiring greenlets, and some enforcement at runtime.Update the documentation on deployment to include deploying with
docker
, and share some things we've learned about configuring gunicorn and database connections.In other minor changes, remove some no longer used dependencies from the
Dockerfile
, and have it include in the image all directories ending inmigrations
, to support forks with multiple migration directories.