Home / Companies / PlanetScale / Blog / Post Details
Content Deep Dive

Video Conferencing with Postgres

Blog post from PlanetScale

Post Details
Company
Date Published
Author
Nick Van Wiggeren
Word Count
1,312
Language
English
Hacker News Points
-
Summary

In an innovative experiment, SpacetimeDB demonstrated a video call using a database as a real-time message broker, capturing and encoding browser media into frames, sending them through PostgreSQL, and playing them back on another browser. The implementation, open-sourced on GitHub, was replicated using a SvelteKit frontend, a Node.js WebSocket server, and a $5 PlanetScale PostgreSQL database. This method utilizes logical replication to reliably stream video and audio data by inserting frames into tables and forwarding them through WebSocket, maintaining a 15fps video stream. The setup includes a cleanup job to manage frame storage, ensuring only recent frames are retained. While alternative methods like LISTEN/NOTIFY and unlogged tables were considered, they were dismissed due to limitations and complexities. The experiment exceeded expectations, demonstrating PostgreSQL's capacity to handle real-time video and audio streams, although it is recommended to use WebRTC for practical applications. The project serves as a fascinating exploration of PostgreSQL's capabilities as a real-time backend.