what happens when app server restarts constantly? #903
-
For simplicity, let's assume there's 2 memcached servers and we constantly deploy new versions of our applications. For reference, the implementation of the ring is: https://github.com/petergoldstein/dalli/blob/main/lib/dalli/ring.rb#L31
is it possible that if the app builds the new cache key (say "example"), it maps to node 2? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@petergoldstein i'm assuming everything will be lost in memory... would this be a possible scenario? |
Beta Was this translation helpful? Give feedback.
-
@karmingc. No, assuming you're using Dalli correctly, keys should map to the same node in different The ring build is designed to be consistent. That is, given the same set of memcached servers, in the same order, with the same weights, you should get the same continuum points for the ring. You can see that here. Similarly, the mapping of a key to a point on the continuum is designed to be deterministic as seen here. The fact that the individual rings are in memory is irrelevant because they are rebuilt consistently. The only situation where the mapping would change (given the same Dalli configuration for both application servers) is if the application servers don't see the same set of memcached servers. That is, if one of the memcached servers appears down to one application server and up to another, then the mappings will differ. And if you use different Dalli configurations for each application server, then you have no guarantees on consistency of mapping. |
Beta Was this translation helpful? Give feedback.
@karmingc. No, assuming you're using Dalli correctly, keys should map to the same node in different
Dalli::Client
instances in the same application server or in entirely different application servers.The ring build is designed to be consistent. That is, given the same set of memcached servers, in the same order, with the same weights, you should get the same continuum points for the ring. You can see that here. Similarly, the mapping of a key to a point on the continuum is designed to be deterministic as seen here. The fact that the individual rings are in memory is irrelevant because they are rebuilt consistently.
The only situation where the mapping would change (given the same Dalli c…