A high-performance distributed hash table (DHT) implementation using the Chord protocol with real-time event streaming capabilities via gRPC. Built for fault-tolerance, scalability, and low-latency event distribution in distributed systems.
- Overview
- Key Features
- Architecture
- Quick Start
- Usage Examples
- Documentation
- Performance
- Contributing
- License
This project implements a production-ready event mesh using the Chord distributed hash table protocol. It provides O(log N) lookup complexity with automatic network stabilization, making it ideal for building scalable distributed applications that require real-time event notifications.
An event mesh is a distributed architecture layer that dynamically routes events between services, applications, and devices. This implementation uses a peer-to-peer approach, eliminating single points of failure while providing:
- Decentralized Architecture: No central coordinator or broker
- Automatic Load Distribution: Consistent hashing evenly distributes data
- Self-Healing Network: Periodic stabilization maintains correctness
- Real-Time Streaming: Server-side push for sub-millisecond latency
- Chord DHT Protocol: Efficient O(log N) lookup in 160-bit identifier space
- gRPC Streaming: Bidirectional streaming for real-time event delivery
- Automatic Stabilization: Background processes maintain network health
- Event Migration: Transparent listener reestablishment when keys move
- Thread-Safe Operations: Concurrent-safe with read-write locks
- CLI Interface: Interactive command-line for testing and monitoring
- Hash Ring: 160-bit SHA-1 identifier space with consistent hashing
- Finger Table: Logarithmic routing table for efficient lookups
- Event Types: NewBinding, MovedBinding, DeletedBinding
- Fault Tolerance: Automatic failure detection and recovery
- Zero Configuration: Nodes auto-configure on join
┌─────────────────────────────────────────────────────────┐
│ Presentation Layer │
│ CLI Interface + gRPC Server │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────▼────────────────────────────────┐
│ Business Layer │
│ Chord Protocol + Event Broker + Consumers │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────▼────────────────────────────────┐
│ Resource Layer │
│ Local Storage + Hash Utilities │
└─────────────────────────────────────────────────────────┘
- DHTNode: Main application and CLI controller
- ChordNode: Core Chord protocol implementation
- EventBroker: Server-side publish/subscribe manager
- EventConsumer: Client-side event listener
- LocalHashTable: Thread-safe key-value storage
- HashUtil: SHA-1 hashing and range utilities
For detailed architecture documentation, see docs/ARCHITECTURE.md.
- Java 17 or higher
- Maven 3.6+
- Terminal/Command prompt
# Clone the repository
git clone https://github.com/KPandya1903/High-Performance-Decentralized-P2P-Event-Mesh.git
cd High-Performance-Decentralized-P2P-Event-Mesh
# Compile and package
mvn clean package
# Verify build
ls -lh target/p2p-event-mesh-1.0-SNAPSHOT.jarjava -jar target/p2p-event-mesh-1.0-SNAPSHOT.jar localhost:5001java -jar target/p2p-event-mesh-1.0-SNAPSHOT.jar localhost:5002 localhost:5001java -jar target/p2p-event-mesh-1.0-SNAPSHOT.jar localhost:5003 localhost:5001# Add a key-value binding
> addBinding user:123 alice@example.com
Key hash: 8a9b7c4d3e2f...
Stored at: localhost:5001 (id: 3a4b5c6d...)
# Retrieve a value
> get user:123
Value: alice@example.com# Terminal 1 - Subscribe to events
> listenOn sensor:temperature
Listening for events on key 'sensor:temperature'...
# Terminal 2 - Add data (triggers event)
> addBinding sensor:temperature 72.5
# Terminal 1 receives:
[EVENT] New binding for key 'sensor:temperature':
Value: 72.5
Stored at: localhost:5002 (id: 7e8f9g0h...)
Timestamp: 2026-01-11T20:00:00Z# View routing table
> routes
Finger Table for node localhost:5001 (id: 3a4b...):
finger[0] → localhost:5002 (id: 7e8f...)
finger[1] → localhost:5003 (id: 9e8d...)
...
# View local storage
> storage
Local key-value pairs:
user:123 → alice@example.com (stored: 2026-01-11T19:55:00Z)
sensor:temperature → 72.5 (stored: 2026-01-11T20:00:00Z)
# Node information
> info
Node Address: localhost:5001
Node ID: 3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
Predecessor: localhost:5003 (id: 9e8d...)
Successor: localhost:5002 (id: 7e8f...)| Command | Description |
|---|---|
addBinding <key> <value> |
Store a key-value pair in the DHT |
get <key> |
Retrieve value for a key |
listenOn <key> |
Subscribe to events for a key |
routes |
Display finger table (routing table) |
listeners |
Show active event listeners |
info |
Display node information |
storage |
Show local key-value pairs |
help |
Show all available commands |
exit |
Shutdown node gracefully |
- Architecture Overview - Detailed system design and components
- Deployment Guide - AWS EC2 deployment instructions
- Testing Guide - Testing strategies and examples
- Quick Start Guide - Step-by-step getting started
- Project Summary - High-level project overview
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Lookup | O(log N) | O(1) |
| Insert | O(log N) | O(1) |
| Delete | O(log N) | O(1) |
| Join Network | O(log² N) | O(log N) |
| Event Delivery | O(1) | O(S) |
N = number of nodes, S = number of subscribers
- Lookup Latency: < 5ms (p99) in 100-node network
- Event Delivery: < 1ms local network
- Stabilization: Converges in O(log² N) rounds
- Storage Distribution: ±5% variance with SHA-1 hashing
See docs/TESTING.md for detailed performance testing.
- Language: Java 17
- RPC Framework: gRPC 1.60+
- Serialization: Protocol Buffers 3
- Build Tool: Maven 3.6+
- Logging: SLF4J + Logback
- Hashing: SHA-1 (160-bit)
This event mesh is suitable for:
- Microservices Communication: Decentralized service discovery and messaging
- IoT Event Distribution: Real-time sensor data routing
- Distributed Caching: Consistent hash-based cache coordination
- Event Sourcing: Distributed event log and replay
- Real-time Analytics: Stream processing across nodes
- Data replication for fault tolerance
- Persistent storage backend (RocksDB)
- TLS/SSL encryption for gRPC
- Authentication and authorization
- Metrics and monitoring (Prometheus)
- Virtual nodes for better load distribution
- Web-based dashboard
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Enzo - Distributed Systems Engineer
- GitHub: @KPandya1903
- Project Link: High-Performance-Decentralized-P2P-Event-Mesh
- Based on the Chord protocol by Stoica et al. (2001)
- Built with gRPC and Protocol Buffers
- Inspired by modern event mesh architectures
Star this repository if you find it useful!