hn.today

Once Campfire in Rust: one binary, the Rails app's data, 19–44× faster

github.com4 points0 comments
Screenshot of Once Campfire in Rust: one binary, the Rails app's data, 19–44× faster

Once Campfire in Rust is a complete port of a Rails-based chat app into a single Rust executable that preserves the original frontend (CSS, Stimulus, Turbo and vendored JS) and reads the Rails app’s SQLite database and storage layout. The port reproduces Rails behavior byte-for-byte where required using a set of crates that map to Rails subsystems - rails_compat (cookies, signed IDs), kit (Rack/Action Dispatch on Axum), db (Active Record-like rusqlite), richtext (Action Text pipeline), storage (Active Storage with libvips/ffmpeg), cable (Action Cable protocol), assets, views and routes - while documenting deliberate divergences. Parity is proven with a Playwright harness that runs Rails and Rust side-by-side on identical seed data and frozen clocks, comparing 225 screen states across Chromium/Firefox/WebKit (server HTML, live DOM, accessibility tree, subresources, Action Cable frames and pixel-perfect screenshots). Early checks compared 5,018 cells and later gates pass 873/874 checked cells.

Benchmarks show dramatic improvements in throughput, latency, real-time scaling, startup and memory. Typical page routes moved from hundreds of req/s to tens of thousands (room page 212→20,213 req/s, 95×; messages 411→23,092 req/s, 56×), p50 room latency 10.4 ms→0.19 ms (54×) and p99 461 ms→5.2 ms (88×). Action Cable deliveries scale from ~9-12k/sec to hundreds of thousands (10,000 clients: 9,485→656,183 deliveries/sec, 69×) and connecting/subscribing 10,000 clients fell from 29.2 s to 1.6 s. Cold start dropped 2,607 ms→143 ms (18×), idle memory 355 MB→15 MB (24×), and image/unpacked size 933 MB→169 MB (5.5×). The Rust port replaces Ruby/Puma/Redis/Resque/Thruster while keeping the UI identical and documents known differences.

Read on github.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.