Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable multi threading #4

Open
decryp2kanon opened this issue Feb 8, 2020 · 1 comment
Open

enable multi threading #4

decryp2kanon opened this issue Feb 8, 2020 · 1 comment
Assignees

Comments

@decryp2kanon
Copy link

decryp2kanon commented Feb 8, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@volbil @decryp2kanon and others