javaapplication-design

Design a System for faster retrieval and modification without burdening the Heap Memory


I need to design a system where data is received via ServerSocket and the data should be readily available for retrieval and modification. Currently, all the data is stored in ConcurrentHashMap.

Data will be refreshed when the application restarts.

Maintaining a Flat File and data retrieval from the file will add some delay.

Is there any better approach to solve this kind of problem.


Solution

  • You could use a key/value store like Redis (with persistent backing storage) to retrieve records as needed, saves you to load the whole file or to keep everything in memory at once. You might want to keep your own HashMap for the "very hot", most frequently requested items, if the cashing of Redis or whatever won't suffice.