Skip to content

A scalable, fault-tolerant distributed banking system implementing Two-Phase Commit (2PC) for cross-shard atomicity and Paxos for intra-shard replication. This project demonstrates strong consistency models (Linearizable/Read-Committed) in a sharded architecture.

Notifications You must be signed in to change notification settings

SoumojitDalui/Consensus-Ledger

Repository files navigation

Distributed Banking System (2PC & Paxos)

A scalable, fault-tolerant distributed banking system implementing Two-Phase Commit (2PC) for cross-shard atomicity and Paxos for intra-shard replication. This project demonstrates strong consistency models (Linearizable/Read-Committed) in a sharded architecture.

Architecture

The system is composed of multiple logical clusters (shards), each responsible for a subset of accounts.

  • Scheduler: The central orchestrator that spawns clusters, manages mapping, and benchmarks performance.
  • Clusters (Shards): Each cluster is a replicated state machine using Paxos for consensus.
  • Nodes: Replicas within a cluster. They persist data and handle locking for 2PL (Two-Phase Locking).

Diagram

System Architecture

Key Protocols

  1. Sharding: Accounts are partitioned across clusters.
  2. Paxos: Ensures consensus within a cluster for fault tolerance.
  3. Two-Phase Commit (2PC): Coordinates transactions that span multiple shards (Cross-Shard) to ensure atomicity.
  4. Two-Phase Locking (2PL): Used during transaction execution to isolate concurrent operations.

Usage

Prerequisites

  • Python 3.8+

Running the System

The entry point is src/main.py.

1. Interactive Mode

Run the system processing transactions from a CSV file:

python3 src/main.py run --input CSE535-F25-Project-3-Testcases.csv

To run in auto-mode (non-interactive):

python3 src/main.py run --input CSE535-F25-Project-3-Testcases.csv --auto

Options:

  • --clusters N: Number of logical clusters (default: 3)
  • --nodes-per-cluster M: Nodes per cluster (default: 3)
  • --consistency LEVEL: linearizable, read_committed, or eventual

2. Benchmarking

Run performance benchmarks with generated traffic:

python3 src/main.py benchmark --tx-count 1000 --read-only 0.2 --cross-shard 0.4 --skew 0.6

Benchmark Options:

  • --concurrency K: Number of client threads.
  • --clusters N, --nodes-per-cluster M: System topology.

Examples

Small workload:

python3 src/main.py benchmark --tx-count 200 --read-only 0.2 --cross-shard 0.1 --skew 0.0

Heavy cross-shard workload:

python3 src/main.py benchmark --tx-count 2000 --read-only 0.2 --cross-shard 0.2 --skew 0.9

High-throughput read-only workload:

python3 src/main.py benchmark --tx-count 30000 --read-only 0.0 --cross-shard 0.0 --skew 0.0

About

A scalable, fault-tolerant distributed banking system implementing Two-Phase Commit (2PC) for cross-shard atomicity and Paxos for intra-shard replication. This project demonstrates strong consistency models (Linearizable/Read-Committed) in a sharded architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages