Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Libcluster Postgres Strategy for Elixir (github.com/supabase)
26 points by filipecabaco on Nov 30, 2023 | hide | past | favorite | 5 comments
hey hn, I’m Filipe, a developer at supabase

we have three projects using Elixir in a clustered setup. we’ve always used libcluster[0] to achieve it but ended up using multiple strategies. now we’ve converged into one approach for all our projects using Postgres as the coordinator.

we’re using Postgres LISTEN and NOTIFY commands with Postgrex as the system to propagate node addresses so they can connect plus we use it to send healtcheck pings to heal when required.

big thanks to https://twitter.com/gotbones for the libcluster library and https://twitter.com/kevinbuch_ for the inspiration

[0] libcluster: https://hexdocs.pm/libcluster/readme.html




supabase team here

eager to hear your feedback, thoughts and questions!


nice work! It makes sense that a company that works with postgres would make the lib_postgres adapter.

There are many libcluster adapters already, so what pushed Supabase to make a database backed one? What is the advantage?

> Postgres LISTEN and NOTIFY commands with Postgrex

I know Supabase has hooks (https://supabase.com/docs/guides/database/webhooks) so is the hope to leverage that tech to trigger something whenever a new node connects?

---

This is just a feature idea (and perhaps if I have time I'll draw up a PR), but since most folks interacting with Supabase are using Phoenix/Ecto already so it would be nice to configure it with a Repo module and/or database_url rather than a keyword list.


> There are many libcluster adapters already, so what pushed Supabase to make a database backed one? What is the advantage?

usually the strategies are focused on the cloud provider and since we want to keep it adaptable to multiple cloud providers it felt that using one of those strategies would not be the way to go.

another factor was the fact that we already use heavily postgres in all our projects so if that is available to us we should use that instead

> I know Supabase has hooks (https://supabase.com/docs/guides/database/webhooks) so is the hope to leverage that tech to trigger something whenever a new node connects?

we already have a presence system available for users in https://supabase.com/docs/guides/realtime/presence using phoenix presence

> Repo module and/or database_url rather than a keyword

Good call! we should have more flexible configuration options


also follow up question, is Supabase using one database per "app" (one cluster) or are there a few different elixir apps that are being backed by the same database (multiple independent clusters)? Though I wonder if using the same storage location for multiple clusters conflicts with how libcluster strategies work.


currently one database per app but indeed that is a good question, I hope people will test it out and find those caveats so we can improve on it




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: