Skip to content

enable multi threading #4

@decryp2kanon

Description

@decryp2kanon

this is single thread and slow

$ python3 app.py

By doing python3 app.py you running api server in single thread with development server, which is highly not recommendation for production

Volbil, [08.02.20 11:03]
There is couple ways to do that, I'm personally using gunicorn and systemd

Volbil, [08.02.20 11:33]
Well, it's not a python but flask server

Volbil, [08.02.20 11:33]
Framework which I'm using

Volbil, [08.02.20 11:39]
Also debug server is bad for production

Volbil, [08.02.20 11:39]
Since it can expose some debug consoles and etc

Volbil, [08.02.20 11:39]
[Forwarded from Fork]
pip3 install gunicorn
pip3 install eventlet
gunicorn app:app --worker-class eventlet -w 1 --bind 0.0.0.0:5000 --reload

Volbil, [08.02.20 11:39]
[In reply to Volbil]
[Unit]
Description=uWSGI instance to serve sugar api
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/api
Environment="PATH=/home/ubuntu/api/venv/bin"
ExecStart=/home/ubuntu/api/venv/bin/gunicorn app:app --worker-class eventlet -w 1 --bind 0.0.0.0:5000 --reload

[Install]
WantedBy=multi-user.target

Volbil, [08.02.20 11:39]
[In reply to Volbil]
Systemd config

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04

https://blog.fossasia.org/setting-up-nginx-gunicorn-and-flask-socketio/

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions