Comments (5)
Alright, that makes sense. I will check your suggestion anyway. Also, it is planned for the replicated adapter to use Mnesia in the near future, so keep you posted. Thanks!
from nebulex.
Everything seems to be lost on deployment. I tried with 3 instances to give more time potentially for syncing, but it didn't help.
from nebulex.
Hey!
Can it be expected that no data is lost during such a deployment with the replicated adapter?
Unfortunately, that cannot be guaranteed. As you know, a deployment can be done in many different ways, so the cache can't be aware of that. The replicated cache tries to keep consistency across the "Erlang/Elixir Cluster", however, it doesn't guarantee "no data loss".
- Will instance 2 wait with the shutdown until the cache is in sync?
No, it won't. When you shut down an instance, you are killing the cache too, the cache is not aware you are updating or shutting down the instance; it does a clean-up on termination ensuring the stopped cache leaves the cluster, but that's all (and this will happen only if you stop the app – like using Application.stop(...)
or calling your release stop script my_app stop
, like a graceful shutdown). So, maybe what is happening when you update instance 1, the sync-up process may have started, but instance 2 is immediately updated, then instance 1 is not able to finish the sync-up process (or maybe it happens so fast that the sync-up hasn't started yet), means, there is no data at that point in time.
On the other hand, if "cache data loss" is critical for you, I'd take a different approach. Currently, the cache runs within your app (same supervision tree) in the same instance. There may be other approaches (a bit more complex but more robust):
- "Cache Servers" topology – cache servers running outside your app (like a separate cache app), on a separate cluster, so they are not affected by your app deployments.
- "Redis Cache" – you could use the
NebulexRedisAdapter
and use Redis as a cache. This is usually the approach I take for more robust and complex scenarios. Here, you can leverage Redis features, like, cluster mode, persistency, sharding topology using Envoy proxy, etc.
Anyway, please let me know if that helps, I stay tuned!
from nebulex.
Hey thanks for confirming!
Would it be in vain to do the following:
Add a callback option to the replicated adapter that is called when the sync is complete, and have that callback be tied to the healthcheck of the app (set a value in a local cache or keep it in a genserver).
Now until that value is set to true the healthcheck on the new instance would fail and keep the deployment from moving forward.
I am experimenting with this on this fork: benonymus@2f6036c
from nebulex.
We decided to use mnesia with https://github.com/sheharyarn/memento for the shared cache, thanks for the responses!
from nebulex.
Related Issues (20)
- Docs on Migrating to v2 from Nebulex.Adapters.Dist.Cluster HOT 5
- `Nebulex.Cache` callbacks mention "Shared Options" section that do not exist
- Support for functions that can set TTL in Decorator similar to Match HOT 9
- Where to use load/2, dump/2 HOT 4
- random :erpc, :timeout with partitioned get HOT 2
- Is there any way to get the size of the cache? HOT 4
- Seeing Nebulex.RPCError during deployments with partitioned adapter HOT 4
- Nebulex.RegistryLookupError HOT 9
- Ambiguity regarding ttl and gc_interval relation. HOT 4
- Bug on Local adapter when using `delete_all` and keys are nested tuples: not a valid match specification HOT 3
- is allocated_memory param global on per node when using Nebulex.Adapters.Partitioned with :shards HOT 2
- Dangling reference on `cache_evict` when using referenced keys HOT 4
- Regression on decorated functions and Elixir 1.16 HOT 3
- Empty arguments list passed to `generate/3` in Elixir 1.16 HOT 3
- `Multilevel` inclusive cache doesn't duplicate entries backwards on `get_all/2` HOT 3
- Fix compatibility with Elixir 1.15 and 1.16 HOT 3
- Support cache refreshing in the background HOT 1
- Having a cache per user ID... HOT 4
- 2.6.2 is missing from tags and releases on github HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nebulex.