How to optimize the massive data of Redis Set
This article introduces the relevant knowledge of "how to optimize the massive data of Redis Set". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Project data business architecture diagram
In order to realize the function of removing weight [counting the number of ships in grid time], the redis Set structure is adopted. The data is valid for 2 days. Due to the huge amount of data, redis down is dropped in the test environment.
First, flushdb is used to clear the data.
The storage code is as follows: convert ship MMSI to String- > byte []
So that each MMSI [9 bits] takes up 9 bytes of memory.
Optimize the data structure:
It only takes 4 bytes to convert Integer to byte [].
So now for 200 million redisKey, it will save at least the memory size as follows:
200 million * (9-4) = 1 billion bytes
It will save at least nearly 1G of memory. If an average of 10 MMSI is stored in a KEY, it saves nearly 10 gigabytes of memory.
This is the end of the content of "how to optimize Redis Set massive data". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!