Answer the question
In order to leave comments, you need to log in
Is it possible to store data in redis?
Started reading about redis in real time applications. While it is difficult. I for example on event want to send the data to clients on a socket. I can't fully understand what exactly redis does in this chain. Apparently it takes data and distributes it by key?
But here's the main question - is it possible to continue to store and receive this data from redis. For example, I have a real-time chart. I need to store the old coordinates somewhere in order to load them along with the page. And at the same time send updated data to clients via sockets. Is it possible to store all this data in redis? After all, as I understand Redis stores data in RAM? It’s not a desire to write data into the muscle, I want it to work quickly.
Answer the question
In order to leave comments, you need to log in
Can.
I use Redis as the only database in several projects (games). Some copies have been working for 5 years and the flight is quite normal.
At regular intervals, Redis flushes data to disk. For me, it depends on the number of changes in the database for certain periods of time.
I initially had a performance issue. I was missing the speed of the radish. There were too many requests to the database. I wrote a ruby wrapper and began to add and read data from 8 radish databases running on one physical server. In modern versions of radish, such sharding is already out of the box.
Even such a work of radishes, when the data is spread over several databases, did not cause problems over several years of operation.
Radishes have one feature that relational databases don't have. If you need to delete a large number of records from the database (say, several tens of millions), then you will have to do this with the help of tens of millions of queries to the database. In relational basis - it would be necessary to execute one command. Therefore, in order not to put the radish database under such a load, you have to clean the database using a separate script that creates a constant small load.
Redis can be configured to flush data to disk according to certain conditions (time, number of records, etc.)
Theoretically, the data you need can be stored there, but you need to understand that Redis is still a "hot" storage.
You can store data there, but I would still use a more reliable storage.
The easiest option is Redis + MySQL, while in Redis store only the data that is needed now, the rest is in MySQL
. Alternatively, if these are some kind of graphs / metrics, you can use a specialized database for temporary data, for example InfluxDB and others
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question