This project is a hands-on exploration of the CAP Theorem (Consistency, Availability, Partition Tolerance). I built a distributed bank account system in Java to simulate how databases handle network failures.
In this mode, the system acts like PostgreSQL. If a node cannot reach its peer to confirm a transaction, it aborts the operation.
- Result: Data remains 100% accurate, but the system becomes "Unavailable" during a network cut.
In this mode, the system acts like Cassandra or DynamoDB. If the peer is unreachable, the node accepts the transaction locally anyway.
- Result: The system stays "Available," but it creates a Split-Brain scenario where two nodes disagree on the account balance.
- Start two nodes on different ports.
- Synchronize a withdrawal (Observe both nodes update).
- Kill one node (Simulate a Partition).
- Switch the active node to AP Mode and perform a withdrawal.
- Restart the dead node.
- Observation: Node A shows $60 while Node B shows $80. You have successfully simulated a distributed data conflict!