Open krapie opened 3 months ago
@krapie Kevin, I'm interested in this issue so, i want to conversation with you. do you have any idea in caching strategies?
What is the primary goal?
What exactly are you caching?
Changes
and Snapshots
?When does caching occur?
WatchDoc
(deleting documents after they are no longer watched).min_synced_seq
.WatchDoc
request, subsequent requests should receive the cached results, which should prevent any issues.What strategies are you considering? if the goal is to reduce user response time, a local cache might be better
Global Cache
:
Changes
and Snapshots
in a single server's memory could consume a lot of memory.Local Cache
:
WatchDoc
, a Thundering Herd
problem could occur during server additions or downs, leading to split-brain scenarios. (However, this may not be a critical issue depending on the number of users.)@binary-ho Well, this issue is just a conceptual thought that I have, and I think we need to discuss about the necessity and the benefits of this feature. But this is a very fun issue to discuss, so maybe starting with PoC might do.
For your questions:
- What is the primary goal?
Reducing the load of MongoDB is the primary goal, but I'm expecting reduced response time as well.
- What exactly are you caching?
Primary Changes
, but need to check MongoDB query pattern.
- When does caching occur?
About the caching strategy, we need to brainstorm about it. I do not have any ideas for now.
- What strategies are you considering? if the goal is to reduce user response time, a local cache might be better
I'm considering local in-memory caching because we do not need global caching in cluster mode, which do not share document workload across the servers.
Description:
Currently, PushPull RPC always queries MongoDB, resulting in overhead. To reduce this overhead and improve the response time of PushPull RPC, we can consider implementing a caching mechanism for Changes or Snapshot data used in PushPull operations. These data have high locality due to the nature of CRDT use cases and are immutable, making them suitable for caching.
Why:
Implementing a cache for Changes or Snapshot data will optimize MongoDB performance and reduce response time for PushPull RPC operations. It will help improve overall system efficiency and user experience while working with PushPull functionalities.