diff --git a/README.rst b/README.rst index 5d1877f..f969780 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,8 @@ Support can be obtained either here via issues, or in the ``#django-channels`` channel on Freenode. You can install channels from PyPI as the ``channels`` package. -You'll likely also want to ``asgi_redis`` to provide the Redis channel layer. +You'll likely also want to install ``asgi_redis`` or ``asgi_rabbitmq`` +to provide the Redis/RabbitMQ channel layer correspondingly. See our `installation `_ and `getting started `_ docs for more. @@ -78,4 +79,5 @@ The Channels project is made up of several packages; the others are: * `Daphne `_, the HTTP and Websocket termination server * `asgiref `_, the base ASGI library/memory backend * `asgi_redis `_, the Redis channel backend +* `asgi_rabbitmq `_, the RabbitMQ channel backend * `asgi_ipc `_, the POSIX IPC channel backend diff --git a/channels/package_checks.py b/channels/package_checks.py index 4509c81..6e4bbf8 100644 --- a/channels/package_checks.py +++ b/channels/package_checks.py @@ -3,6 +3,7 @@ from distutils.version import StrictVersion required_versions = { + "asgi_rabbitmq": "0.4.0", "asgi_redis": "1.2.0", "asgi_ipc": "1.3.0", } @@ -21,7 +22,7 @@ def check_all(): try: module = importlib.import_module(package) except ImportError: - return + continue else: if StrictVersion(version) > StrictVersion(module.__version__): raise RuntimeError("Your version of %s is too old - it must be at least %s" % ( diff --git a/docs/backends.rst b/docs/backends.rst index 16f1d6b..f500d14 100644 --- a/docs/backends.rst +++ b/docs/backends.rst @@ -54,6 +54,31 @@ the consistent hashing model relies on all running clients having the same settings. Any misconfigured interface server or worker will drop some or all messages. +RabbitMQ +-------- + +RabbitMQ layer is comparable to Redis in terms of latency and +throughput. It can work with single RabbitMQ node and with Erlang +cluster. + +You need to install layer package from PyPI:: + + pip install -U asgi_rabbitmq + +To use it you also need provide link to the virtual host with granted +permissions:: + + CHANNEL_LAYERS = { + "default": { + "BACKEND": "asgi_rabbitmq.RabbitmqChannelLayer", + "ROUTING": "???", + "CONFIG": { + "url": "amqp://guest:guest@rabbitmq:5672/%2F", + }, + }, + } + +This layer has complete `documentation `_ on its own. IPC --- diff --git a/docs/contributing.rst b/docs/contributing.rst index 8620a43..9e03e40 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -22,6 +22,7 @@ of the Channels sub-projects: * `Daphne issues `_, for the HTTP and Websocket termination * `asgiref issues `_, for the base ASGI library/memory backend * `asgi_redis issues `_, for the Redis channel backend + * `asgi_rabbitmq `_, for the RabbitMQ channel backend * `asgi_ipc issues `_, for the POSIX IPC channel backend Issues are categorized by difficulty level: diff --git a/docs/deploying.rst b/docs/deploying.rst index 8b72707..2b2e92a 100644 --- a/docs/deploying.rst +++ b/docs/deploying.rst @@ -79,6 +79,19 @@ Make sure the same settings file is used across all your workers and interface servers; without it, they won't be able to talk to each other and things will just fail to work. +If you prefer to use RabbitMQ layer, please refer to its +`documentation `_. +Usually your config will end up like this:: + + CHANNEL_LAYERS = { + "default": { + "BACKEND": "asgi_rabbitmq.RabbitmqChannelLayer", + "ROUTING": "my_project.routing.channel_routing", + "CONFIG": { + "url": "amqp://guest:guest@rabbitmq:5672/%2F", + }, + }, + } Run worker servers ------------------ diff --git a/docs/index.rst b/docs/index.rst index 7135ba9..a9fa415 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,6 +29,7 @@ Channels is comprised of five packages: * `Daphne `_, the HTTP and Websocket termination server * `asgiref `_, the base ASGI library/memory backend * `asgi_redis `_, the Redis channel backend +* `asgi_rabbitmq `_, the RabbitMQ channel backend * `asgi_ipc `_, the POSIX IPC channel backend This documentation covers the system as a whole; individual release notes and diff --git a/loadtesting/2016-09-06/README.rst b/loadtesting/2016-09-06/README.rst index 2c79b59..4acc015 100644 --- a/loadtesting/2016-09-06/README.rst +++ b/loadtesting/2016-09-06/README.rst @@ -1,5 +1,5 @@ Django Channels Load Testing Results for (2016-09-06) -=============== +===================================================== The goal of these load tests is to see how Channels performs with normal HTTP traffic under heavy load. @@ -11,7 +11,7 @@ comparison to a WSGI HTTP server. Gunincorn was chosen as its configuration was Summary of Results -~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~ Daphne is not as efficient as its WSGI counterpart. When considering only latency, Daphne can have 10 times the latency when under the same traffic load as gunincorn. When considering only throughput, Daphne can have 40-50% of the total @@ -29,7 +29,7 @@ Some additional things that should be tested: Methodology -~~~~~~~~~~~~ +~~~~~~~~~~~ In order to control for variances, several measures were taken: @@ -42,7 +42,7 @@ In order to control for variances, several measures were taken: Setups -~~~~~~~~~~~~ +~~~~~~ 3 setups were used for this set of tests: @@ -52,7 +52,7 @@ Setups Latency -~~~~~~~~~~~~ +~~~~~~~ All target and sources machines were identical ec2 instances m3.2xlarge running Ubuntu 16.04. @@ -63,7 +63,7 @@ In order to ensure that the same number of requests were sent, the rps flag was Throughput -~~~~~~~~~~~~ +~~~~~~~~~~ The same source machine was used for all tests: ec2 instance m3.large running Ubuntu 16.04. All target machines were identical ec2 instances m3.2xlarge running Ubuntu 16.04. @@ -77,7 +77,7 @@ Gunicorn had a latency of 6 ms; daphne and Redis, 12 ms; daphne and IPC, 35 ms. Supervisor Configs -~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~ **Gunicorn (19.6.0)** @@ -89,7 +89,7 @@ This is the non-channels config. It's a standard Django environment on one machi command = gunicorn testproject.wsgi_no_channels -b 0.0.0.0:80 directory = /srv/channels/testproject/ user = root - + [group:django_http] programs=gunicorn priority=999 @@ -107,13 +107,13 @@ Also, it's a single worker, not multiple, as that's the default config. command = daphne -b 0.0.0.0 -p 80 testproject.asgi:channel_layer directory = /srv/channels/testproject/ user = root - + [program:worker] command = python manage.py runworker directory = /srv/channels/testproject/ user = django-channels - - + + [group:django_channels] programs=daphne,worker priority=999 @@ -130,13 +130,13 @@ This is the channels config using IPC (Inter Process Communication). It's only p command = daphne -b 0.0.0.0 -p 80 testproject.asgi_for_ipc:channel_layer directory = /srv/channels/testproject/ user = root - + [program:worker] command = python manage.py runworker --settings=testproject.settings.channels_ipc directory = /srv/channels/testproject/ user = root - - + + [group:django_channels] programs=daphne,worker priority=999