mindreader

mindreader

We currently have a monolith where I work, on kubernetes. We are using libcluster to get the nodes the mesh together, and up until now, there has only been one type of node that has every possible dependency and library. It isn’t really sustainable so I’d like to break up some functionality.

The way libcluster works is it gets a list of ips where erlang nodes could be, and then connects them together. Since there could be multiple erlang vms on one machine, it uses a basename@hostname combo for its long names, where the hostname determines what machine it is on, and the basename determines which vm on that machine you want.

In kubernetes every container is just going to have one node on it, so libcluster made a design decision that every erlang node should have the same basename. That’s fine, but then how do I tell the difference between node types in my cluster?

For example, if I have some api nodes, and I have some analytics nodes, and one of the api nodes wants to contact a random analytics node to crunch some data and wait for the results, how do I determine which nodes are “analytics” nodes, when all of the nodes names look like :foo@whatever ?

Up until now I would have just named them api@whatever and analytics@whatever and just done a Node.list and filtered out the analytics nodes, but I don’t see a lot of people doing that so it makes me wonder if there is a better way.

Showing Posts 1 to 9

chasers

chasers

I think a lot of k8s people use a service registry like etcd.

I would be interested in another way however as I’m choosing not to go down the k8s route (for now … using Google’s instance groups) but I’m at a place where I need to deregister a node when it receives a sigterm. Perhaps Swarm or Syn.

shanesveller

shanesveller

Is there a clear requirement informed by some other aspect of the design that calls for all of the heterogeneous BEAM nodes to be meshed together in one large pool? Can they be meshed with just their direct peers instead, or in many cases not need to mesh at all?

shanesveller

shanesveller

Most of the time we’d use Pod labels and a ClusterIP or headless Service that selects over those labels to do sibling discovery, which is a model libcluster directly supports. In many environments you don’t have any direct connectivity to etcd that powers the cluster, for security and safety reasons, and some don’t actually use etcd under the hood. IIRC Amazon EKS is actually persisting to DynamoDB or something to that effect.

mindreader

mindreader OP

Honestly they could be meshed only with direct peers. Most of these will only ever interact with one other node type, although it is likely that the api nodes will have to interact with the majority at one point or another.

My purpose in this is mostly to avoid having to write rest api glue between services that could just directly make rpc calls to each other.

mindreader

mindreader OP

I’ve tried to use swarm in the past, but it did not give me useable results. I actually just tried out syn. I decided to use its process groups to register the top level supervisor of each app into the groups :api, and :analytics, then when they start up, their top level pids are registered. Then I can call :syn.get_members(:api) |> Enum.map(&node/1) to get a list of nodes in the system of that type.

I think that works, and I can’t see any reason why it wouldn’t. Does that seem like a good solution?

elcritch

elcritch

Are you certain about the libcluster node naming? I’m using libcluster in IoT devices and the node name follows the sname/name given at node startup. Like:

iex(sensor-display@172.31.51.29)1> Node.list
[:“sensor-router@172.31.51.30”]

Not sure how/if there’s an easy way to pass snam/name to the BEAM on k8s from some metadata. Though I think when Node.start is called it can be passed a new name? It’s not too hard to create custom modules for libcluster so you could try that too if you don’t want to use swarm/syn or something else.

chasers

chasers

Definitely seems reasonable to me!

mindreader

mindreader OP

I’m assuming your IoT devices are using a strategy like gossip or something, which causes each node to send its node name to others periodically, allowing them to connect back.

I think I might go with the syn option. Now if only there were a way to make it log less verbosely.

elcritch

elcritch

Yes, it’s gossip. That’s useful to know as I didn’t know the different libcluster modules don’t send the node name.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews