Show HN: Multiplayer Demo Built with Elixir

📰 Hacker News · wenbo

Learn how to build a multiplayer demo using Elixir and Supabase Realtime, a Change Data Capture server for PostgreSQL databases

intermediate Published 11 Apr 2022
Action Steps
  1. Build a Change Data Capture server using Elixir and Phoenix
  2. Configure PostgreSQL's logical replication functionality to write database changes to WAL segment files
  3. Use the wal2json extension to convert database changes to JSON objects
  4. Implement security checks using JWT validation to ensure only authorized clients receive database changes
  5. Test the multiplayer demo using WebSockets to broadcast changes to authorized subscribers
Who Needs to Know This

Backend engineers and developers can benefit from this demo to learn about building real-time applications using Elixir and Supabase Realtime. The demo showcases a multiplayer environment, which can be useful for gaming and collaborative applications

Key Insight

💡 Supabase Realtime uses PostgreSQL's logical replication functionality and wal2json extension to broadcast database changes to authorized subscribers

Share This
🚀 Build a multiplayer demo with Elixir and Supabase Realtime! 🚀

Key Takeaways

Learn how to build a multiplayer demo using Elixir and Supabase Realtime, a Change Data Capture server for PostgreSQL databases

Full Article

Hey HN, I’m an engineer at Supabase [0] and one of the creators of this demo. My team and I have been working hard to bring developers the next version of Supabase Realtime. The current version of Realtime [1] is a Change Data Capture (CDC) server for a PostgreSQL database that broadcasts changes via WebSockets to authorized subscribers. It’s written in Elixir/Phoenix. The server utilizes PostgreSQL’s logical replication functionality, which writes database changes to Write-Ahead Logging (WAL) segment files, and a replication slot, responsible for managing and retaining WAL files. Database changes are polled from WAL by the server using PostgreSQL’s replication function pg_logical_slot_get_changes and changes converted to JSON objects using the wal2json [2] extension by setting it as the output plugin. Security is enforced through two checks - each check ensures only authorized client subscribers are sent database changes. The first check validates a JWT that is sent by clients su
Read full article → ← Back to Reads