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
Cowboy - RabbitMQ and websockets
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Wade Mealing
September 17, 2013
Technology
1.5k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cowboy - RabbitMQ and websockets
A quick overview on how to plug together some buzzword enabled tech for your enjoyment.
Wade Mealing
September 17, 2013
Other Decks in Technology
See All in Technology
技術・能力を向上する原理原則 #きのこセッションa #きのこ2026
bash0c7
0
130
コミュニティの有益性 ~JAWS Days 2026 での体験を通して~ / The Benefits of a Community ~Through My Experience at JAWS Days 2026~
seike460
PRO
0
270
クレデンシャル流出 ― 攻撃 3 時間 vs 復旧 10 時間。この非対称性にどう備えるか
kazzpapa3
3
570
【FinOps】データドリブンな意思決定を目指して
z63d
0
370
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
320
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
420
飲食店もAIで。レジ締めやハンディシステムをつくってる話 / Using AI for restaurant management
vtryo
0
180
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
180
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
不要なレビューをAIにまかせて AIコーディングの環境改善を加速した
shoota
1
270
Deep Data Security 機能解説
oracle4engineer
PRO
2
120
AI Agentをシステムに組み込む前にゆるく向き合ってみる
hayama17
0
150
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
210
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Context Engineering - Making Every Token Count
addyosmani
9
980
エンジニアに許された特別な時間の終わり
watany
107
250k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
400
The World Runs on Bad Software
bkeepers
PRO
72
12k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
Transcript
Erlang + Message Queue + HTML 5 Tech
= Over-engineered Chat Server
What Cowboy ? https://github.com/extend/cowboy Small, fast modular web server written
in erlang.
What Gen Bunny https://github.com/mochi/gen_bunny RabbitMQ client library for simple pubsub
in erlang.
What Websocket ? https://www.websocket.org/ Bi-directional web communication mechanism.
Over Architecturing You want it. I deliver !
Server Moving parts Cowboy Gen Bunny Browser
Client Moving parts Cowboy Gen Bunny Browser
Websockets Technical Detour
Client Moving parts Browser Browser Server HTTP Port 80 Port
80
Client Moving parts Browser Browser Server WS Upgrade Upgrade Port
80 Port 80
WHY ? WORKS WITH EXISTING PROXIES
Client JS Data is live chat stream
JS Connection wsUrl = "ws://server:8081/websocket"; websocket = new WebSocket(wsUrl);
Websocket Setup websocket = new WebSocket(wsURL); websocket.onopen = ... websocket.onmessage
= function(evt){ onMessage(e) }; websocket.onerror = ...
onMessage Handler function onMessage(e) { Msg = '<p>' + txt
+ '</p>' $('#output').prepend(Msg); };
Smooth Yeah
Server Side Server WS
Cowboy What comes to mind ?
Kid Rock
Fresh Leather
Pretty Lil' web server
Cowboy Routes, REST, middleware, web sockets and more.
Cowboy follows OTP principals.
Cowboy WS Required Callbacks init websocket_init websocket_handle websocket_info websocket_terminate
Cowboy WS init Upgrades from http → web socket
Cowboy WS init({tcp, http}, _Req, _Opts) → {upgrade,protocol,cowboy_websocket}.
Cowboy WS websocket_init Run on each connection.
Cowboy WS websocket_init(_Name, Req, _Opts) → Pid = consumer:start_link(), {ok,
Req, #state{pid=Pid}}.
Cowboy WS websocket_handle Recv data from client, optionally return data.
Cowboy WS websocket_handle(Data, Req, State) → {text, Msg} = Data,
{reply, {text, << "recv: ", Msg/binary >>}, Req, State};
Cowboy WS websocket_info Live Push data to client
Cowboy WS websocket_info(Data, Req, State) → {reply, {text, Data}, Req,State};
Sending to RabbitMQ RabbitMQ websocket_handle
Recv from RabbitMQ RabbitMQ websocket_info gen_bunny CONSUMER
Message Queues gen bunny
gen_bunny follows OTP principals.
callbacks Required: • handle_message • init • handle_call • handle_cast
• handle_info • terminate
callbacks handle_message Handle messages from the message subscribed message queue.
callbacks handle_message(Msg, State) → NewState = act_on_msg(Msg,State) {noreply, NewState};
MQ perspective Exchange Exchange “Fanout” M S G M S
G M S G M S G M S G M S G M S G M S G M S G M S G M S G M S G
Live demo Wireless Network: Name: rabbit Password: carrot VISIT: http://10.1.1.1:8081/
Benchmarking Method: Connect to Websocket Wait for signal. Send 100
messages. Receive all messages
Benchmarking Results: (Didn't get this done in time, sorry) 0.5
1 1.5 2 2.5 3 3.5 4 4.5 0 2 4 6 8 10 12 Column 1 Column 2 Column 3
Source Code github.com/wmealing/ bunny-cowboy-websocket