Python Forum
wsgi server ports - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: wsgi server ports (/thread-24665.html)



wsgi server ports - chrisdb - Feb-26-2020

Hello,

I'm coming from a Java background and for most web projects I've used tomcat as a web server. The thing is that if I want to deploy an application, I just put it in the 'webapps' folder and then go to 'http:localhost:8080/<nameofapplication>' to run it.

While reading about WSGI f.e. with Gunicorn, the examples always use a specific port per application.
So my question is, is it always necessary for an application to run an a different port? So if I would have 2 applications, is it required to run them on 2 different ports? Isn't it also possible to use 1 port like with Tomcat(java) to run different apps?

thx


RE: wsgi server ports - snippsat - Feb-26-2020

(Feb-26-2020, 07:04 AM)chrisdb Wrote: While reading about WSGI f.e. with Gunicorn, the examples always use a specific port per application.
Can use specific port eg 5000 in setup process with Gunicorn,
then just delete delete that setup rule as should in front run Nginx server that listen default to port 80.
Look at How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04
DO Wrote:Finally, let’s adjust the firewall again. We no longer need access through port 5000, so we can remove that rule.
We can then allow full access to the Nginx server:

sudo ufw delete allow 5000
sudo ufw allow 'Nginx Full'

Note that this setup is only needed for a finished app that want to share with the world.
All most of all web-development i do mostly training and testing out stuff,i do with the build in development WSGI server that included in Flask and Django.
Also in Flask 1.0 the development sever is multi-threaded.
Flask Wrote:As of Flask 1.0, the WSGI server included with Flask is run in multi-threaded mode by default.
So scale well in local development to,but if want to share with the world then need a production ready WSGI server like Gunicorn or uWSGI with NGINX in front.

Or if don't want to mess with server setup AWS Lambda
AWS Lambda Wrote:AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume.
Lambda takes care of everything required to run and scale your code with high availability.



RE: wsgi server ports - chrisdb - Feb-26-2020

(Feb-26-2020, 01:55 PM)snippsat Wrote: Look at How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04
In the url you provided, the example binds an application to a specific port:
gunicorn --bind 0.0.0.0:5000 wsgi:app

So if what I think is correct, you have to bind applications per port on your localhost, correct? So if I would like to make app2 available, I will have to run:
gunicorn --bind 0.0.0.0:5001 wsgi:app2


RE: wsgi server ports - snippsat - Feb-26-2020

I have not look into bind several app to Gunicorn.
When tested a while back on DO,i did span up 3 Droplet(server) all running Flask.
As this is easy i would no try to run 2 app from one Droplet(server).
Just to make clear so will these 3 web-app have dedicated Droplet(server) on a own clean Linux distro,they are not connect in any way.
I think can span 20 Droplet on one plan each providing varying levels of resources.

So as example this site use DO as host,running on one Droplet(server).
We had to scale up this Droplet(server) several times because of increase traffic.
No we run 3-CPU, 3-TB Transfer, 1-GB memory.