article --summary
The summary
The author explains why a shared drawing app is awkward in a typical PHP-FPM setup, where state can't live between requests, and how Laravel Rust lets the canvas sit in memory as a singleton. The drawing is stored as one byte per pixel, so the full canvas is only about 250 KB, and it is saved to object storage every five seconds when it changes so a restart doesn't wipe it out.
For live updates, the app runs its own WebSocket route on Axum rather than paying for a separate Reverb cluster. New visitors get the full canvas first, then batches of changed pixels go out every 50 milliseconds, with repeated paints on the same pixel collapsed into the final color. Cursor positions are throttled the same way.
The post also notes the tradeoffs: the app runs on a single instance with autoscaling off, since a second instance would hold its own canvas, and a crash can lose changes made since the last snapshot. It closes with a pitch for the Flare error tracker and a note about Spatie's ports of its PHP packages to Rust and Go.
Editorial note: This is a summary of an article first published by freek.dev. The full piece is on their site.