Python Forum
WSGI server vs Web Server - 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 vs Web Server (/thread-17793.html)

Pages: 1 2 3


WSGI server vs Web Server - chrisdb - Apr-24-2019

Hello everyone,

I've been trying to get into the concept of wsgi, but I still got some questions:

- from wat I can tell most wsgi servers are also http servers?
- can I run a wsgi server, without using a web server to run a webapp (i.e. run an angular spa with a rest api in flask with waitress alone)?
- what are the advantages of using a web server in combination with a wsgi server

thank you


RE: WSGI server vs Web Server - heiner55 - May-26-2019

can I run a wsgi server, without using a web server to run a webapp:

Yes, you can.


RE: WSGI server vs Web Server - Skaperen - May-26-2019

i am doing my web stuff "in the cloud" ... specifically at AWS. S3 is, effectively, i nice low cost web server. but, it's static, and has to be front-ended to do HTTPS. i had to split things between a static server and a dynamic server. so, my domains have multiple host names, some going to S3, some going to a server running in an instance, both using CloudFront for caching. there are names like www.example.com, images.example.com, submit.example.com, downloads.example.com.


RE: WSGI server vs Web Server - heiner55 - May-26-2019

What does your server cost at maximum (runs 24h, 30 day)?


RE: WSGI server vs Web Server - Skaperen - May-26-2019

i'd have to work it out. i do other stuff there, too, like various backups, multiple domains, cloud automation testing, stuff for one of my clients. even then, i'm often under $10 total, per month, not counting some domain registration i have, there.


RE: WSGI server vs Web Server - heiner55 - May-26-2019

Thank you.


RE: WSGI server vs Web Server - snippsat - May-26-2019

(Apr-24-2019, 07:43 AM)chrisdb Wrote: - can I run a wsgi server, without using a web server to run a webapp (i.e. run an angular spa with a rest api in flask with waitress alone)?
The work flow with eg Flask is building the web-app is all done local with Development Server(wsgi) that come with Flask.
If want to share with the world then get a host and then leave development server and then eg go for good option like Gunicorn and Nginx.
Look at this post for host recommendations.

WSGI Servers for a little history.
As a note there no need to dig into WSGI specification,unless you want build yet another Python web-framework.
fullstackpython Wrote:WSGI is by design a simple standard interface for running Python code.
As a web developer you won't need to know much more than
  • what WSGI stands for (Web Server Gateway Inteface)

  • that a WSGI container is a separate running process that runs on a different port than your web server

  • that a WSGI container is a separate running process that runs on a different port than your web server
    your web server is configured to pass requests to the WSGI container which runs your web application,
    then pass the response (in the form of HTML) back to the requester



RE: WSGI server vs Web Server - Skaperen - May-27-2019

why can't you just set up the wsgi container to listen to ports 80/443 directly and reduce the total workload on your server and increase the response time?

and i have already written my own little http server and am curious how much work would be involved to add wsgi support to it (not as the proxy).

edit:

that little http server i wrote is entirely in python. i wrote it back before i did anything with python3 (which is now the only python version i write for) and i have not updated it, yet. so i guess that means it is currently a python2 thing. its design is to use the http request path to find a python file and it loads it as a module and runs it in the same process. it is not a multi-user server.

edit:

the apache server and many others support the cgi method of dynamic execution. to execute python code, the code will have to be a command which runs in a separate process which exits when complete, making for a lower performing server. this includes the disadvantage of the need to store persistent data in files (and probably deal with process sharing issues) or in a database that a new connection needs to be made to for each dynamic web request.


RE: WSGI server vs Web Server - snippsat - May-27-2019

Quote:why can't you just set up the wsgi container to listen to ports 80/443 directly and reduce the total workload on your server and increase the response time?

and i have already written my own little http server and am curious how much work would be involved to add wsgi support to it (not as the proxy).
Yes can do other stuff,i also have written toy web-server as practice.
But when i advice what people should use i mention Gunicorn which is a production ready fast WSGI HTTP Server.
With NGIX(not Apache in my option) in front for Proxy Requests.

I also mention AWS in link i posted,for not messing with server stuff talked about over at all.
Can re-post it here:
Not messing 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 - there is no charge when your code is not running.
For Python setup is Zappa good.
zappa Wrote:Never Worry About Web Hosting Again


(May-27-2019, 12:32 AM)Skaperen Wrote: the apache server and many others support the cgi method of dynamic execution.
Apache will i not use when Nginx is a better and easier to use in my option,CGI is dead in Python it will be removed in the future PEP 594.
CGI was never a good solution for Python in the future,that's why Python community did write an all Python solution PEP 3333(WSGI).


RE: WSGI server vs Web Server - heiner55 - May-27-2019

For CGI: see https://python-forum.io/Thread-Run-Python-CGI-from-Apache


For Flask: see https://python-forum.io/Thread-Flask-Starting-web-development-part-1