Search code examples
pythonjsondatabasetensorboard

Saving frequently updated arrays to database


I am creating a machine learning app which should save a number to a database locally and frequently. These number values are connected which basically means that I want to frequently update a time series of values by appending a number to the list.

An ideal case would be to be able to save key-value pairs where key would represent the name of the array (example train_loss) and value would be according time series. My first idea was leveraging redis but as far as I know redis data is only saved in RAM? What I want to achieve is saving to a disk after every log or perhaps after every couple of logs.

I need the local save of data since this data will be consumed by other app (in javascript). Therefore some JSON-like format would be nice. Using JSON files (and Python json package) is an option, but I believe it would result in an I/O bottleneck because of frequent updates.

I am basically trying to create a clone of a web app like Tensorboard.


Solution

  • A technique we use in the backend of hosted application for frequently used read/post api is to write to the Redis and DB at the same time and during the read operation we check if the key is available in the Redis and if it's not we read update it to the Redis and then serve it