Read and Write on a Huge Data System

Imagine you have a big distributed database system and you want to perform some read/write operations on it.

We want the transactions to be atomic and consistent. Using one thread to perform both reading and writing task will ensure the stability of the system but speed will take a hit. Also going through the entire database is no cake walk and takes multiple queries to get to the result.

Naturally the operation will take time. So we split the task of reading and writing to multiple threads to optimize performance.

A Typical Code to Solve it

Image for post

Simple Solution

#architecture #design #java #coding #programming

Advanced Locking in Java: Reentrant Read Write Lock
1.45 GEEK