Each user would have their own genserver holding their entire state(loaded from db)
%{
tree_one: %{
keyword_one: %{
domain: "elixirocks.com",
twitter: "some_lame_twitter_link.com",
score: 5,
}
}
}
There would be some 20+ trees and up to 10000 keywords total inside these “trees”.
Now let’s suppose some X process in the system gets updated score
for our elixirocks.com
domain, what would be the most efficient way to update it inside all the genservers that contain that domain?
Does it make sense to broadcast something like “topic:domain_update” + listen with all genservers and then check inside maps(state) for a match ? I am afraid how this will perform if I have say 1000 genservers(users) and each has some 10k entries and there is 1 update every 5 seconds
Those genservers would then be responsible for broadcasting this changes further to the users via phoenix channels…
Reading last 2 paragraphs back, makes me cringe a little… Maybe just ditch this design for shared state (ets/mnesia) or even just stick with damn postgres(trying to avoid this and have elixir processes be main source of truth) ?