You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wsgi-servers.html
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,39 @@ <h1>WSGI Servers</h1>
142
142
<p>However, knowing the WSGI standard and how these frameworks and containers
143
143
implement WSGI should be on your learning checklist though as you become
144
144
a more experienced Python web developer.</p>
145
+
<divclass="section" id="why-wsgi">
146
+
<h2>Why WSGI?</h2>
147
+
<p>Understanding the purpose of WSGI, and WSGI servers, is just as important as
148
+
understanding their implementation. Why not just point a web server directly at
149
+
your application?
150
+
There are a couple of reasons:</p>
151
+
<ul>
152
+
<li><pclass="first"><strong>WSGI gives you flexibility.</strong> Because the WSGI standard has been adopted
153
+
by all Python application frameworks and many web servers, it is trivial for
154
+
an application developer to swap out components of their stack for others.
155
+
Switching web servers, WSGI servers and even frameworks becomes easy, because
156
+
the configuration pattern is the same regardless of whether you are using
157
+
NGINX, Gunicorn and Django or Apache, mod_wsgi and Flask. From <aclass="reference external" href="http://www.python.org/dev/peps/pep-3333/">PEP 3333</a>:</p>
158
+
<blockquote>
159
+
<p>The availability and widespread use of such an API in web servers for Python
160
+
[...] would separate choice of framework from choice of web server, freeing
161
+
users to choose a pairing that suits them, while freeing framework and
162
+
server developers to focus on their preferred area of specialization.</p>
163
+
</blockquote>
164
+
</li>
165
+
<li><pclass="first"><strong>WSGI servers promote scaling.</strong> If you want to serve thousands of requests
166
+
for dynamic content at once, relying on your application framework to smoothly
167
+
handle the traffic is a bad idea. Most app frameworks don't focus on serving
168
+
lots of concurrent requests gracefully. Rather, that job is left up to the WSGI
169
+
server. It will handle processing requests from the web server and deciding
170
+
how to communicate them to your application framework's process.</p>
171
+
<p>TODO: go into more detail about this</p>
172
+
<p>WSGI servers are designed with scaling in mind, and therefore their infrastructure
173
+
is better suited to handling high traffic volume than directly exposing your
0 commit comments