@@ -576,6 +576,27 @@ The RabbitMQ queue is configured through the
576576 mgr = socketio.AsyncAioPikaManager('amqp://')
577577 sio = socketio.AsyncServer(client_manager=mgr)
578578
579+ Horizontal Scaling
580+ ~~~~~~~~~~~~~~~~~~
581+
582+ Socket.IO is a stateful protocol, which makes horizontal scaling more
583+ difficult. When deploying a cluster of Socket.IO processes, all processes must
584+ connect to the message queue by passing the ``client_manager `` argument to the
585+ server instance. This enables the workers to communicate and coordinate complex
586+ operations such as broadcasts.
587+
588+ If the long-polling transport is used, then there are two additional
589+ requirements that must be met:
590+
591+ - Each Socket.IO process must be able to handle multiple requests
592+ concurrently. This is needed because long-polling clients send two
593+ requests in parallel. Worker processes that can only handle one request at a
594+ time are not supported.
595+ - The load balancer must be configured to always forward requests from a
596+ client to the same worker process, so that all requests coming from a client
597+ are handled by the same node. Load balancers call this *sticky sessions *, or
598+ *session affinity *.
599+
579600Emitting from external processes
580601~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
581602
@@ -911,24 +932,6 @@ multi-threaded WebSocket server that is compatible with Werkzeug and Gunicorn's
911932threaded worker. Other multi-threaded web servers are not supported and will
912933not enable the WebSocket transport.
913934
914- Scalability Notes
915- ~~~~~~~~~~~~~~~~~
916-
917- Socket.IO is a stateful protocol, which makes horizontal scaling more
918- difficult. To deploy a cluster of Socket.IO processes hosted on one or
919- multiple servers, the following conditions must be met:
920-
921- - Each Socket.IO process must be able to handle multiple requests
922- concurrently. This is required because long-polling clients send two
923- requests in parallel. Worker processes that can only handle one request at a
924- time are not supported.
925- - The load balancer must be configured to always forward requests from a
926- client to the same worker process. Load balancers call this *sticky
927- sessions *, or *session affinity *.
928- - The worker processes need to communicate with each other to coordinate
929- complex operations such as broadcasts. This is done through a configured
930- message queue. See the section on using message queues for details.
931-
932935Cross-Origin Controls
933936---------------------
934937
0 commit comments