Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

What is the difference between deploying a Flask application on an ec2 instance (in other words running your script on any computer) and deploying a Flask application via AWS Elastic Beanstalk? The Flask deployment documentation says that:

While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well and by default serves only one request at a time. Some of the options available for properly running Flask in production are documented here.

One of the deployment options they recommend is AWS Elastic Beanstalk. When I read through Amazon's explanation of how to deploy a Flask app, however, it seems like they are using the exact same server application as comes built-in to Flask, which for example is single-threaded and so cannot handle simultaneous requests. I understand that Elastic Beanstalk allows you to deploy multiple copies, but it still seems to use the built-in Flask server application. What am I missing?

1 Answer

0 votes
by (44.4k points)

they are using the exact same server application as comes built-in to Flask.

You can confirm that this isn't the case by removing the run-with-built-in-server section yourself

- i.e. the following from the example:

if __name__ == "__main__":

    # Setting debug to True enables debug output. This line should be

    # removed before deploying a production app.

    application.debug = True

You'll stop having the ability to run it yourself locally with python however it's going to still happily run on EB!

The EB Python platform uses its own WSGI server (Apache with mod_wsgi, last I looked) and some assumptions/config to find your WSGI callable:

From Configuring a Python project for Elastic Beanstalk:

By default, Elastic beanstalk looks for a file called to start your application. If this does not exist in the Python project that you have created, some adjustment of your application's environment is important.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories