We are currently looking for the most suitable solution for accessing critical data in a distributed system, and we are considering whether to use memory caching compared to a centralized cache.
Some information about the data we want to store / receive:
- Very small data size
- The data is very cold; which means that it practically does not change and changes only when a person changes something in our back-office system.
- Must be updated upon change (100 ms delay ok)
- A very important way for our application, it requires a very high SLA (both in reliability and in response time (no more than 20 ms for access))
- Data is read frequently (up to thousands of times per second).
As we can see, it looks like this:
In memory cache
Pros:
- Faster than network access + serialization
- Higher reliability in terms of distribution (if one instance dies, data still exists in other instances)
Minuses:
- It's much harder to code and maintain
- Notification of instances after changes and the need for each separate update of each instance is required + The need to download data at the start of each server.
- Adds a high risk of data inconsistency (one instance has different or outdated data than others)
Centralized cache
For conversation, we looked at using Redis.
Pros:
- Much easier to maintain
- Very reliable, we have extensive experience working with Redis in a distributed system.
- Only one place to upgrade
- Ensures data consistency
Minuses: