Our backend is written in
Kotlin . The data is in
We did some profiling and this revealed that the current bottleneck is that too much data gets transferred between MongoDB and the
get_by_id() fetches the same data again and again.
We thought about caching all
get_by_id() calls in an
in-memory cache (shared by all threads of this node). This way all threads on a node can benefit from the faster access to data from this cache.
The next step would be to implement
cache-invalidation . All modifications would need to update the
Before implementing this, I want to know which different/better ways exist to implement this.
How to optimize the fact that the code does fetch the same data from MongoDB again and again?