I am looking for any existing implementation of sharing a read only in-memory cache across pods on the same node. This setup would allow fast access without the need to load the entire cache into each pods memory.
Example: 1GB lookup dictionary is kept up to date, each pod has read access to the data allowing fast lookup without effectively cloning the data into memory. So end result would be just 1GB of memory utilized on the node, and not 1GB * N(number of pods)
Imagined solution for k8s:
- A single (Daemon) pod that has the tmpfs volume RW, maintaining an up to date cache data
- Multiple pods that have the same tmpfs volume R(only), mapping the data file(s) to read data out
- Naturally reading out values and operating on them is expected to create transitive memory usage
Notes:
- I have found multiple entries regarding volume sharing between pods, but no complete solution reference for the above
- tmpfs is ideal for cache speed of R/W, however obviously it can be over regular fs
- Looking for solutions that can be language specific or agnostic for reference
- Language specific would be utilizing a specific language to map a file data as a Dictionary / other KV lookup
- Language agnostic and more generalized solution could be utilizing sqlite where processes in our case here would be pods
tmpfs
but how your service will make sure to connect to same node POD read only instance ? ideally traffic flow from service to PODs doesn't matter read of write replica. inside your application you can't use POD ip or so. Read more same scenario discussion : #70452838 – Unwholesome