Apache/Flask/mod_wsgi: Increase speed of request on flask app running on apache server

Viewed 144

This is most likely an issue with the server configuration rather than Flask itself. I have a function that uses a Flask library called streaming-form-data that allows me to upload big files (roughly 70mb each) without waiting an absurd amount of time per upload. Here is the core of it (the part that matters for this question anyway) which receives the data in chunks until there are no more.

while True:
    chunk = request.stream.read(8192)
    if not chunk:
        break
    parser.data_received(chunk)

When I run this on my local machine the files are stored almost instantly, within seconds. However on an EC2 server with apache2 and mod_wsgi it takes well over a minute which is not ideal. By refreshing FileZilla I can see the files being saved chunk by chunk but it's far slower than when ran on my local machine. Here is the part of the config that could reasonably affect it:

WSGIDaemonProcess metadata user=www-data group=www-data processes=5  threads=25 python-path=/var/www/html/APPNAME:/var/www/html/APPNAME/virtualenv/lib/python3.6/site-packages
WSGIScriptAlias / /var/www/html/APPNAME/app.wsgi

I've already messed around with processes and threads with no visible effect really. I'm not much of a server guy, which part of the config or code could actually improve performance? The EC2 metrics show that the usage or memory don't really spike to dangerous levels either so I'm guessing there's a way to change the config around.

0 Answers
Related