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.9k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
A Brief History of Channels
A talk I gave at DjangoCon Europe 2016
Andrew Godwin
March 31, 2016
More Decks by Andrew Godwin
See All by Andrew Godwin
Reconciling Everything
andrewgodwin
1
400
Django Through The Years
andrewgodwin
0
320
Writing Maintainable Software At Scale
andrewgodwin
0
520
A Newcomer's Guide To Airflow's Architecture
andrewgodwin
0
420
Async, Python, and the Future
andrewgodwin
2
740
How To Break Django: With Async
andrewgodwin
1
820
Taking Django's ORM Async
andrewgodwin
0
850
The Long Road To Asynchrony
andrewgodwin
0
770
The Scientist & The Engineer
andrewgodwin
1
850
Other Decks in Programming
See All in Programming
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
460
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
240
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
350
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
1k
1B+ /day規模のログを管理する技術
broadleaf
0
120
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
1
180
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.6k
どこまでゆるくて許されるのか
tk3fftk
0
300
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
330
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
190
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
330
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
280
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
Raft: Consensus for Rubyists
vanstee
141
7.6k
sira's awesome portfolio website redesign presentation
elsirapls
0
290
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Test your architecture with Archunit
thirion
1
2.3k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
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