Skip to content

Distributed Calculator powered by .NET 8 uses gRPC for fast, strongly-typed communication and integrates Vector Clocks to track causality across operations. It ensures high performance, consistency, and clarity in concurrent, multi-node environments.

Notifications You must be signed in to change notification settings

chamod0003/GRPC-Calculator

Repository files navigation

🧮 Distributed Calculator with Vector Clocks & Rollback

Built with .NET Core & gRPC

🎯 Objective

This project simulates a distributed calculator system using gRPC services in .NET Core. It demonstrates key distributed systems concepts such as vector clocks, rollback, eventual consistency, and CAP theorem trade-offs.


📦 Project Structure

DistributedCalculator/
├── CalculatorClient/       # gRPC client with vector clock logic
├── GrpcServer1/
├── GrpcServer2/
├── GrpcServer3/     
├── Shared/                 # Shared VectorClock class and models
└── README.md               # This file

🚀 Features

  • ✅ gRPC-based calculator with Square, Cube, and SlowMultiply operations
  • ✅ Vector Clock tracking for causality
  • ✅ Rollback mechanism on simulated errors
  • ✅ CAP theorem simulation: prioritizes Availability + Partition Tolerance
  • ✅ Eventual consistency with delayed clock sync
  • ✅ Leader election (simulated)
  • ✅ Two-phase commit for multi-server operations

🛠️ Technologies Used


🧪 How It Works

  1. Client sends a number and operation to selected server
  2. Server merges vector clock, simulates delay, and may fail randomly
  3. On failure → rollback and return isSuccess = false
  4. Client retries with previous clock
  5. Vector clocks evolve and log causal relationships

📖 CAP Theorem in Practice

  • Consistency: relaxed (vector clocks allow divergence)
  • Availability: prioritized (client always gets a response)
  • Partition Tolerance: supported (servers operate independently)

🧠 Learning Goals

  • Understand vector clocks vs Lamport clocks
  • Implement rollback and compensation logic
  • Simulate distributed failures and recovery
  • Explore consistency models and trade-off

🧑‍💻 Author

Chamod

About

Distributed Calculator powered by .NET 8 uses gRPC for fast, strongly-typed communication and integrates Vector Clocks to track causality across operations. It ensures high performance, consistency, and clarity in concurrent, multi-node environments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages