Creating separate process for each connected device

I have several devices which will be sending device information from time to time and I need to have separate processes for each device doing per device calculations. Each process will store previous state and whenever new device info is received to that device’s process it will do calculations using the old info and new device info and perform some actions. Now I am not sure whats the best way to achieve this. (I am aslo not expert in genserver if thats the way to go). I have seen some articles and stackoverflow etc e.g https://stackoverflow.com/questions/51523208/how-can-i-dynamically-create-genservers-in-elixir . Thanks any help will be really appreciated

I need to make sure that there is only one aggregator per device per instance cluster

To use dynamic processes, I would go for DynamicSupervisor.

To ensure there is only one process by device in a cluster, I would refer to How to use the registry for global process?

Maybe Erlang global would be enough, but You might use libraries as mentionned in linked post.

To speed up things, I would use ETS table.

And I would use all tools and benefits coming from OTP… not only GenServer :slight_smile:

You might also find some useful information here

https://www.youtube.com/results?search_query=elixir+iot

2 Likes