Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wsgi server ports
#1
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
Reply
#2
(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.
Reply
#3
(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
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WSGI Multi processing. simbha 1 2,829 May-05-2020, 10:34 AM
Last Post: pyzyx3qwerty
  WSGI server vs Web Server chrisdb 24 10,462 May-29-2019, 02:21 AM
Last Post: heiner55
  Log WSGI directly to stdout ThomasT 4 3,875 Jan-24-2019, 10:17 AM
Last Post: ThomasT
  Trouble deploying Django (project folder, wsgi.py and libapache2-mod-wsgi) Drone4four 8 7,959 Mar-17-2018, 09:40 PM
Last Post: Drone4four
  Python wsgi example: problem with javascript imonike 12 10,007 Jun-19-2017, 03:27 PM
Last Post: imonike

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020