channels_redis

The Redis-backed channel layer that powers cross-process messaging for Django Channels.

Library
PyPI
v4.3.0
649stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
63/100Good
Development Activity64
Maintenance16
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture80
Code Quality76
Innovation72
Learning Curve70

channels_redis is the official Redis-backed channel layer implementation for Django Channels, the project that extends Django to handle WebSockets, long-poll HTTP, and other ASGI protocols alongside regular views. A “channel layer” is how independent Channels consumers — which may run in entirely different processes or servers — talk to each other and to groups of connected clients.

The package ships two layer implementations: RedisChannelLayer, a general-purpose layer built on Redis’s data structures for reliable at-most-once delivery, and RedisPubSubChannelLayer, a lighter pub/sub-based layer trading some delivery guarantees for lower latency and simpler Redis usage patterns.

What You Get

  • RedisChannelLayer - a reliable, at-most-once channel layer built on Redis lists and sorted sets
  • RedisPubSubChannelLayer - a lower-latency layer built on native Redis pub/sub
  • Group send/broadcast support for fanning a message out to many connected clients (e.g. a chat room)
  • Consistent-hashing support for sharding across multiple Redis hosts
  • Configurable message serializers, including an optional cryptography-backed encrypted serializer
  • Async-native implementation built on redis.asyncio, matching Channels’ async consumer model

Common Use Cases

  • Broadcasting real-time chat messages to all WebSocket consumers subscribed to a room/group
  • Coordinating between multiple Django Channels worker processes behind a load balancer
  • Building live notification systems that push updates to connected clients as events occur
  • Scaling a Channels deployment across multiple Redis instances via consistent-hash sharding
  • Choosing between reliable group messaging (RedisChannelLayer) and low-latency pub/sub (RedisPubSubChannelLayer) based on delivery-guarantee needs

Under The Hood

Architecture The package centers on core.py’s RedisChannelLayer, which implements Channels’ BaseChannelLayer interface using Redis lists (per-channel message queues) and sorted sets (per-group membership with expiry), plus a ChannelLock helper class for per-channel async locking. pubsub.py implements the alternate RedisPubSubChannelLayer using Redis’s native PUBLISH/SUBSCRIBE commands instead, trading reliable delivery for lower latency and simpler server-side state. serializers.py defines a pluggable serializer registry (MessagePack, JSON, and an optional encrypted serializer), and utils.py provides shared helpers for connection-pool creation, consistent hashing across multiple Redis hosts, and host-list decoding. Tech Stack Built on redis.asyncio (the redis-py async client) as its sole required Redis dependency, with an optional cryptography extra for the encrypted serializer; it targets Django Channels’ ASGI/asyncio consumer model directly rather than wrapping a sync API. Code Quality tests/ covers both channel-layer implementations plus serializers and utils, run via pytest with pytest-asyncio; the repo’s health signals show low recent commit activity, meaning it currently receives maintenance-mode-level upkeep rather than active feature development. API Design Both layers implement the same Channels BaseChannelLayer interface, so application code (consumers, routing) doesn’t need to know which backend is configured — switching from RedisChannelLayer to RedisPubSubChannelLayer is a one-line settings change, not a code change.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search