linux - Nginx load balancer to serve static files from multiple WSGI servers -


so have been learning more nginx. used before serve 1 web app on same system want scale out separately. have been able setup nginx load balancer 2 gunicorn servers running flask app. question how set use nginx's static serving abilities each of these gunicorn servers.

lets have 3 virtual private servers am paying for. number 1 has nginx load balancer/reverse proxy routing requests number 2 , number 3 duplicate web apps. want these stand alone need run app, including static directories. instead of having static directory on load balancer/reverse proxy contained in web app directory structure.

currently looks this:

                                  gunicorn -> flask                                 / nginx loadbalancer/reverseproxy                                  \                                   gunicorn -> flask 

do need put nginx on each gunicorn server access static dir , return static files nginx loadbalancer/reverseproxy? follows:

                                  nginx -> gunicorn -> flask                                 / nginx loadbalancer/reverseproxy                                  \                                   nginx -> gunicorn -> flask 

maybe doing wrong , above overkill , may not increase performance. if structure load balancing , caching on 1 main entry point , routing gunicorn ability serve static files gunicorn doesn't have to?

what want able have server web app installed can add more needed , point load balancer these upstream servers.

any suggestions helpful.

assuming on production, , far understanding of gunicorn takes me, should not use unicorn serve static files,

at end of day nginx @ front of whole system act load balancer/rev proxy, configure server distribute incoming requests set of upstream servers,

now, regarding upstream servers, go this

nginx -> gunicorn -> flask 

where configuration make requests served static file directory , others go straight gunicorn server,

at end of day deploy discrete upstream servers pool , add them rev proxy conf, (just mentioned)

                                  nginx -> gunicorn -> flask                                 / nginx loadbalancer/reverseproxy                                  \                                   nginx -> gunicorn -> flask 

be aware each server deployed on own , has capacity of server whole site on own,

this answer comes fact cannot serve static files other backend hosts if not going through server , since nginx literally 1 of best things out there on task, makes sense use it.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -