6 ms·
Hey HN, we’re excited about this launch. This was a collaborative effort with the team at Snaplet [0]. postgres-wasm is an embeddable Linux VM with Postgres in
by kiwicopple 4y ago
Hey HN, we’re excited about this launch. This was a collaborative effort with the team at Snaplet [0].
postgres-wasm is an embeddable Linux VM with Postgres installed, which runs inside a browser. It provides some neat features: persisting state to browser, restoring from pg_dump, logical replication from a remote database, etc.
The idea was inspired by CrunchyData’s HN post about a month ago [1]. We love the possibilities of Postgres+WASM, and so Supabase & Snaplet teamed up to create an open source version. The linked blog post explains the technical difficulties we encountered, and the architecture decisions we made.
We’re still working hard on this, but it’s at a good “MVP” stage where you can run it yourself. Snaplet are working on a feature where you can drag-and-drop a snapshot into your browser to restore the state from any backup. Supabase are exploring ways we can run the entire Supabase stack inside the browser. You can find the Snaplet repo here [2], and the Supabase fork here [3]. There’s very little difference between these two, we just have a different browser UI.
Both Supabase team and the Snaplet team will be in here commenting if you want to know anything else about the technical details.
[0] Snaplet: https://www.snaplet.dev/ https://www.snaplet.dev/
[1] Crunchy post: https://news.ycombinator.com/item?id=32498435 https://news.ycombinator.com/item?id=32498435
[2] Snaplet repo: https://github.com/snaplet/postgres-wasm https://github.com/snaplet/postgres-wasm
[3] Supabase fork: https://github.com/supabase-community/postgres-wasm https://github.com/supabase-community/postgres-wasm
- boltzmann-brain 4y agoDo you have a benchmark of load times after the includes are cached? Depending on whether it's < 100 ms or > 1s it will make the applications for this very different.
- kiwicopple 4y agoWe don't have any benchmarks yet, but it's definitely something we should add/automate now that we're past the "POC" phase
- gurjeet 4y agoThe links at the bottom are broken; presumably the post was written in Markdown, HN doesn’t understand that.
- kiwicopple 4y agoThanks Gurjeet - fixed
- vineyardmike 4y ago> an embeddable Linux VM with Postgres installed, which runs inside a browser. Wow! I feel like this is the lede. How much work was done supporting the VM and OS privatives (eg networking) vs PG specific work? I feel like a minimal Linux in the browser opens up a LOT more opportunities than just a database. When figma got bought out, a lot of articles were written about “where’s the wasm applications”, and I feel like throwing Linux into a browser really shows potential. One commenter already wondered if it could be used to compile microcontrollers (so creative, i now want that too), I wonder if it can be used similar to Repl.it, with packaging test environments. To be very, very clear, I would LOVE a write up about just the linux portion of this interesting project.
- kiwicopple 4y ago> How much work was done supporting the VM All of the heavy lifting here is done by v86: https://github.com/copy/v86 https://github.com/copy/v86 v86 can be used for a number of things besides Postgres - things like Repls or other entire applications are definitely achievable. Networking between Postgres and the internet was a lot of work, and Mark came up with a neat solution detailed in the blog post. This solution can be used for any other application. If you're looking to run a native application in the browser using v86, the repo & blog post is a good launching pad.
- Ericson2314 4y agoThis is cool, but is also somewhat saddening too. The dream is a real wasm native postgres; in fact to get all of postgresql's cool shared mem proccess stuff and make it something like shared array buffer! The dream is also that WASI interface and new-school OS interfaces like memfd_create are increasingly aligned. Instead of rationalization our interfaces, however, it's just emulation layer on top of emulation layer, tech debt all the way down. ---- I am not blaming you all in the slightest, to be clear. Obviously one needs to start somewhere. Just sighing at the state of things.
- pistoriusp 4y agoI think we'll see this - and it would be amazing to get someone to work towards this - once there is an amazingly compelling use case that resonates with the market, then I think there's room for optimization!