[Flask] Multiple backend servers with Flask

Morgan Connolly connollymorg at gmail.com
Tue Aug 4 16:31:24 CEST 2015


I have a Flask application that has an architecture like so:


It currently all runs on a single server, but I need to be able to scale
the application by adding in more servers. I know how I can scale the
database(by creating a cluster), I do not really care about scaling the
message queue at this point, but I can create a cluster for that too.

What I am not sure about scaling is the application itself.

My sessions are stored client side in cookies (Flask-Login), so that
shouldn't be a problem. I am using Redis for storing temporary data that
needs to be accessible from every node(application server). This data has a
lifetime of 5 minutes, so no big deal.

I am using Celery as a task queue, with RabbitMQ as the broker. This is
used for running background processes and executing tasks asynchronously.

All pages served are basically static HTML, with no AJAX or anything fancy
like that.

I've thought of setting up two application servers, have each one connect
to the same database, same RabbitMQ instance, and same Redis instance, and
set up a load balancer in front of it to forward requests to either server.
But I'm worried this might cause problems like tasks getting executed twice
by Celery; would it?

Is there a better way to scale Flask applications?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150804/3a93f49b/attachment.html>

More information about the Flask mailing list