Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I came from a game development background and have little experience with web servers.

I'm developing a web server based on Elixir/Phoenix. Say we have some players that can join guilds. The relationship between Guild and Player is one-to-many. In order to boost up the performance, we want to cache data in memory as much as possible, so we cache data of players and also guilds. But since players may "share" the same guilds, we attempt to wrap the guild data into a GenServer, so that every operation for a single guild can be performed sequentially.

With the design mentioned above, we realized that caching for the guild became a little bit tricky to deal with. Since every guild itself is a separate process, what process is in charge of expiring the guild process?

  • If the guild process is in charge of expiring itself, every cast/call message sent after the expiration could not be successfully run.
  • If we have a GuildManager to manage all the expiration logic for the guild processes. Kill a guild process would also cause every guild-pid-holder process to crash.

So what's the best practice to deal with this kind of problem?

question from:https://stackoverflow.com/questions/65661196/elixir-best-practice-to-wrap-a-timed-state-inside-a-genserver

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
380 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...