Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
A Brief History of Channels
Search
Andrew Godwin
March 31, 2016
Programming
2
2.6k
A Brief History of Channels
A talk I gave at DjangoCon Europe 2016
Andrew Godwin
March 31, 2016
Tweet
Share
More Decks by Andrew Godwin
See All by Andrew Godwin
Reconciling Everything
andrewgodwin
1
320
Django Through The Years
andrewgodwin
0
210
Writing Maintainable Software At Scale
andrewgodwin
0
440
A Newcomer's Guide To Airflow's Architecture
andrewgodwin
0
360
Async, Python, and the Future
andrewgodwin
2
670
How To Break Django: With Async
andrewgodwin
1
730
Taking Django's ORM Async
andrewgodwin
0
730
The Long Road To Asynchrony
andrewgodwin
0
660
The Scientist & The Engineer
andrewgodwin
1
770
Other Decks in Programming
See All in Programming
iOS開発スターターキットの作り方
akidon0000
0
240
Jakarta EE Meets AI
ivargrimstad
0
610
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
990
物語を動かす行動"量" #エンジニアニメ
konifar
12
3k
MCP連携で加速するAI駆動開発/mcp integration accelerates ai-driven-development
bpstudy
0
280
あまり知られていない MCP 仕様たち / MCP specifications that aren’t widely known
ktr_0731
0
230
中級グラフィックス入門~効率的なメッシュレット描画~
projectasura
4
2.5k
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
0
410
PHPカンファレンス関西2025 基調講演
sugimotokei
6
1.1k
管你要 trace 什麼、bpftrace 用下去就對了 — COSCUP 2025
shunghsiyu
0
300
Google I/O Extended Incheon 2025 ~ What's new in Android development tools
pluu
1
230
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
1
1.3k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
329
21k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Being A Developer After 40
akosma
90
590k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Site-Speed That Sticks
csswizardry
10
760
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Transcript
Andrew Godwin @andrewgodwin BRIEF HISTORY of CHANNELS A
Andrew Godwin Hi, I'm Django core developer Senior Software Engineer
at Likes networking a little bit too much
Channels
Channels?
WebSocket
HTTP 1 request response Browser Server request response request response
request response
HTTP 2 request response Browser Server request response request 1
response 2 request 2 response 1
WSGI request response Browser Server Django call app return val
WebSockets receive send Browser Server send receive send send
receive send Browser Server send receive send send Django ?
Hard to deadlock Built-in authorisation Scales down Widely deployable Optional
Django is not built for this.
But what if it was?
Instead of requests, we have events
Events of the same type are grouped on a named
channel
HTTP requests HTTP responses WebSocket connecteds WebSocket frames received WebSocket
frames sent WebSocket disconnections
A channel is a: named, first-in-first-out, at-most-once, non-broadcast, network-transparent queue
of messages
http.request Protocol Server Worker Server http.response websocket.connect websocket.send websocket.receive websocket.send
websocket.send
Responses are on single-reader channels (http.response!1A2B3C)
You can send onto channels from anywhere
How do you use it?
View request response callable
Consumer event event callable event event
Every message on a channel runs the consumer function
http.request routes to a view system consumer
def ws_message(message): # Get things from message data = json.loads(message['text'])
# Use ORM like normal MyModel.objects.create( value=data['value'], ) # Send a reply and close socket message.reply_channel.send({ 'text': 'OK', 'close': True, })
routing.py: urls.py for Channels
message.user: like request.user
message.channel_session: per-socket sessions
Groups broadcast/pub-sub
Add a channel to a Group Remove a channel from
a Group Send to a Group
Worked Examples github.com/andrewgodwin/channels-examples
Liveblog http.request Django view layer websocket.connect Add to liveblog Group
websocket.disconnect Remove from liveblog Group <Article.save> Send notification to liveblog
Chat http.request Django view layer websocket.receive Either add to room
Group or send to chat_messages websocket.disconnect Remove from room Groups chat_messages Send to room Groups
It's so easy to join! CALL NOW
Things I didn't even get to: Replacing WSGI Pluggable channel
backends Sharding and scaling It's still just runserver
A base for the future Scheduler? Retry logic? Generic Consumers?
...and much more
1.10 "Provisional"?
1.8 1.9 pip install channels
channels.readthedocs.com github.com/andrewgodwin/channels-examples
Thanks. Andrew Godwin @andrewgodwin