Browse Source

Document WebSocket support for threading mode

pull/683/head
Miguel Grinberg 4 years ago
parent
commit
2f085b3338
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 26
      docs/server.rst

26
docs/server.rst

@ -59,7 +59,7 @@ Socket.IO servers to integrate easily into existing WSGI or ASGI applications::
Serving Static Files
--------------------
The Engine.IO server can be configured to serve static files to clients. This
The Socket.IO server can be configured to serve static files to clients. This
is particularly useful to deliver HTML, CSS and JavaScript files to clients
when this package is used without a companion web framework.
@ -832,8 +832,7 @@ Standard Threads
While not comparable to eventlet and gevent in terms of performance,
the Socket.IO server can also be configured to work with multi-threaded web
servers that use standard Python threads. This is an ideal setup to use with
development servers such as `Werkzeug <http://werkzeug.pocoo.org>`_. Only the
long-polling transport is currently available when using standard threads.
development servers such as `Werkzeug <http://werkzeug.pocoo.org>`_.
Instances of class ``socketio.Server`` will automatically use the threading
mode if neither eventlet nor gevent are not installed. To request the
@ -854,15 +853,22 @@ development web server based on Werkzeug::
# ... Socket.IO and Flask handler functions ...
if __name__ == '__main__':
app.run(threaded=True)
app.run()
The example that follows shows how to start an Socket.IO application using
Gunicorn's threaded worker class::
$ gunicorn -w 1 --threads 100 module:app
When using the threading mode, it is important to ensure that the WSGI server
can handle multiple concurrent requests using threads, since a client can have
up to two outstanding requests at any given time. The Werkzeug server is
single-threaded by default, so the ``threaded=True`` option is required.
With the above configuration the server will be able to handle up to 100
concurrent clients.
Note that servers that use worker processes instead of threads, such as
gunicorn, do not support a Socket.IO server configured in threading mode.
When using standard threads, WebSocket is supported through the
`simple-websocket <https://github.com/miguelgrinberg/simple-websocket>`_
package, which must be installed separately. This package provides a
multi-threaded WebSocket server that is compatible with Werkzeug and Gunicorn's
threaded worker. Other multi-threaded web servers are not supported and will
not enable the WebSocket transport.
Scalability Notes
~~~~~~~~~~~~~~~~~

Loading…
Cancel
Save