Building a Realtime Websocket API in Phoenix
summary
Built a realtime WebSocket API with Phoenix and Elixir where the server is the authoritative timer and each user gets an OTP process as the timer, tracked and rehydrated on restart, using a GraphQL connect mutation that returns a token and WS URL, custom JSON messages shaped as [model, action] with timestamped tick events every second, tests verifying the OTP timer state and throughput with Blaze, removed Phoenix channel internals to simplify clients, heartbeat and reconnect logic handle intermittent drops and the cross‑device sync works.
AI-written summary · about
chapters (25)
- 0:00Introduction
- 1:05Talk overview
- 3:54Websockets for Pomodoro
- 6:08What is websocket
- 10:26Websockets vs HTTP
- 11:28Phoenix and Elixir
- 13:13OTP and hot code reload
- 14:20Realtime API inspiration
- 15:03GraphQL API setup
- 20:51Phoenix websocket OTP
- 21:34Phoenix channels
- 25:26Custom websocket API
- 26:08Message structure
- 27:13Timer start events
- 30:01Broadcasting events
- 32:53Implementation flow
- 33:59Q&A Elixir ecosystem
- 36:32Q&A language servers
- 36:53Q&A resilience
- 38:38Q&A message ordering
- 39:53Q&A client support
- 40:55Q&A message frequency
- 42:25Q&A reconnecting heartbeats
- 44:08Q&A timing precision
- 44:52Q&A multi-server sync
related talks
50mPhoenix Framework: a (Truly) Fullstack Stack for Building Real-Time Web
41mElixir & Phoenix – fast, concurrent and explicit
01h 00mPhoenix: an Intro to Elixir's Web Framework
34mAnatomy of a Real Time Elixir App
45mPhoenix a web framework for the new web
01h 00mPhoenix a Web Framework for the New Web
44mRise of The Phoenix - Building an Elixir Web Framework
44mElixir & Phoenix - Fast, Concurrent and Explicit
