by kiwicopple · 4y ago · 0 comments
we're excited about this release - it adds a few neat features to our Realtime server[0]. For those who don't read the post (it's quite long), our Realtime server was initially built for subscribing to Postgres changes via websockets. We've added Broadcast functionality (for "ephemeral" messages that don't need to be persisted to Postgres) and Presence (similar to Broadcasts, but it retains an eventually-consistent state between users).
We were planning a larger write-up with all the technical details but it became a bit long. Some highlights:
- Realtime is built with Elixir an Phoenix[1]
- We've moved to a single, global cluster - We're using `Phoenix.Tracker` to globally distribute the Erlang PIDs of all of our Postgres connections. This guarantees there is only a single connection to each database.
- We've implemented a "leaky-bucket" rate-limiter using Erlang's `:counters` module[3] for "per tenant" rate-limiting. We'll move this to a global rate-limiter in the future
- We're currently seeing ~2000 concurrent connected users - it will be interesting to see what this spikes up to now that this is on HN
It's still in heavy development, and we'll make sure to detail all the choices we take as we continue solve problems. A few of the Realtime team will be here answer questions - @chasers, @wenbo, @abc3erl.
[0] Realtime: https://github.com/supabase/realtime
[1] Phoenix Framework: https://www.phoenixframework.org/
[2] rate limiter: https://en.wikipedia.org/wiki/Leaky_bucket
[3] :counters: https://www.erlang.org/doc/man/counters.html
I say that because I just used Supabase for the first time, and I was able to build and launch the Slack clone in ~15 minutes. Seriously cool. Thank you for sharing
If no connection exists yet, you're right, two connections could try to establish themselves at the same time. In which case, whoever gets to the db first wins. But then the loser is still connected to PubSub, so they'll now start getting changes just the same.
What are the chances of an official C# library being in the works? I think this would greatly fill the needs for unity devs. I use firebase on almost all game backends because of how quickly I can get set up with auth and a db.
I used supabase in my latest project and it served my needs but there were a few difficulties to overcome. The greatest shortcoming was the lack of real time support (C#), and I had to do everything via REST api.
I am planning on publishing the game as OSS and making some learning videos about it
https://github.com/supabase-community/#client-libraries
They won't support the functionality we outline in our blog post yet (we are still figuring it out on our official JS libraries), but I'll send him your message.
As an aside, if anyone is reading this and wants to help maintain the C# libraries, please reach out.
[0] acupofjose: https://github.com/orgs/supabase-community/people/acupofjose
Creating dev and staging environments is a feature that I am most looking forward to. Hopefully that is on the road map.
Temporal has done an incredible job of ensuring there will be no side-effects (even with external systems), so I doubt we'll be able to do something as extensive as they have. That said, we will probably build a simple Postgres queue/workflow engine (similar to pgboss[0]). It will live in the Postgres database (as an extension), but will be nicely integrated with Edge Functions. We haven't started this yet, so I don't have any timelines.
[0] pgboss: https://github.com/timgit/pg-boss
The reason we paused it was the realisation that it's far more powerful to co-locate this sort of product with the data. In this case, Workflows would be more powerful as a Postgres extension - you can store the workflows into your database, create them using SQL, and the workflows would have direct access to your operational data. We'll probably re-write this using pgx[0] at some stage (if anyone is reading this and wants to attempt this, please reach out).
[0] pgx: https://github.com/tcdi/pgx
Does the global cluster architecture make it much harder to self-host supabase? Not that I plan to, but having the promise of portability is really important.
The code is already open source, and anyone can extract it into a more reusable package. And it's developed in the open, anyone can fork or send PRs or anything. That's what open sourcing a piece of code is really about.
Of course the latency can go up with load but it shouldn't get very spiky thanks to the preemptive multitasking.