Skip to content

About

High-performance distributed load balancer.

Topics

Resources

Stars

15 stars

Watchers

0 watching

Forks

Repository files navigation

HuddleCluster

PyPI version Python versions Website and Live Demo AGPL-3.0 License DOI CI

Self-organizing load balancer and cluster orchestrator with adaptive thermal eviction.
Interactive Simulation & Architecture →


HuddleCluster models server scheduling after emperor penguin huddle dynamics. Active servers operate in an inner ring; when a node's latency, error rate, or resource load spikes relative to the cluster median, it rotates to an outer ring to cool down with reduced or zero traffic. Once its metrics recover, it rotates back in.

This avoids static thresholds and manual weight tuning, keeping tail latency bounded when individual backends degrade.


Install

pip install huddle-cluster

Optional extras: fastapi, redis, grpc, kubernetes, simulation.


Single-instance usage

from huddle_cluster import create_cluster
import requests

cluster = create_cluster([
    ("web-1", "10.0.0.1", 8080),
    ("web-2", "10.0.0.2", 8080),
    ("web-3", "10.0.0.3", 8080),
])
cluster.start()

with cluster.get_server_context() as server:
    response = requests.get(f"http://{server.host}:{server.port}/api")

Inspect cluster state:

print(cluster.health_report())
{
  "inner_servers": ["web-1", "web-3"],
  "outer_servers": ["web-2"],
  "fairness_score": 0.94,
  "rotation_count": 12,
  "requests_per_sec": 847.3,
  "cluster_health": "healthy"
}

Anomaly demo

Run the local anomaly demo to observe thermal eviction under an injected 280ms+ latency spike:

python demos/reproducible_anomaly_demo.py

Multi-node cluster

Each node runs an agent that reports heartbeats and thermal metrics to a coordinator (MasterNode):

# Start coordinator
huddle-cluster master start --port 7070

# Enroll nodes
huddle-cluster agent start --id web-01 --master http://master:7070 --port 8080

# List registered nodes
huddle-cluster nodes list
NODE ID                ADDRESS                STATUS       HB       LAST SEEN
-----------------------------------------------------------------------------
web-01                 10.0.0.1:8080          alive        142      0.8s ago
web-02                 10.0.0.2:8080          alive        139      1.1s ago
web-03                 10.0.0.3:8080          dead         41       34.2s ago

Query the scheduler for the next target node:

curl http://master:7070/v1/scheduler/next
{ "ok": true, "node": { "node_id": "web-01", "address": "10.0.0.1", "port": 8080 } }

Built-in endpoints when the master is running:

  • http://master:7070/dashboard - live cluster topology
  • http://master:7070/v1/metrics - Prometheus scrape endpoint
  • http://master:7070/v1/docs - OpenAPI / Swagger UI

Core concepts

Concept Role
Inner ring Active servers handling normal traffic
Outer ring Servers resting after a high-load or high-latency interval
Thermal score EMA of relative latency anomaly, CPU, memory, and error rate
Rotation Overheated nodes move outward; cooled nodes return inward
Relative anomaly Scored against the cluster median rather than hardcoded constants

Components

  • Core engine (huddle_cluster_pkg/core.py): dual-ring balancing, EMA anomaly scoring, adaptive thresholds, HTTP health checks, WebSocket draining, and UDP gossip.
  • Control plane (cluster_master.py, cluster_agent.py): node registry, heartbeats, RBAC, TLS/mTLS, state persistence, and Prometheus/OTLP observability.
  • Traffic & resilience: circuit breaker, token-bucket rate limiter, canary traffic splitting, rolling updater, request hedging, and auto-remediation.
  • HA & discovery: Raft-based leader election (cluster_ha.py), multi-region routing, Redis shared state, Kubernetes Watch discovery, and Helm charts.
  • Experimental / simulation: WAN latency simulator (wan_simulator.py), hardware/GPU sensor hooks (hardware_sensors.py), and an XDP/eBPF userspace control interface (ebpf_controller.py, ebpf/huddle_xdp.bpf.c).

Benchmarks

Under injected server degradation, P95 latency stays under 86 ms compared to 5,027 ms with round-robin. See the paper and benchmarks/ for methodology and scripts.


Documentation

Resource Location
Interactive demo rahadbhuiya.github.io/HuddleCluster
Single-instance guide USAGE.md
Cluster architecture docs/CLUSTER.md
Research paper docs/HuddleCluster.pdf / Zenodo

Citation

Bhuiya, R. (2025). HuddleCluster: A Penguin-Inspired Self-Organizing Load Balancer
with Adaptive Thermal Eviction. https://github.com/rahadbhuiya/HuddleCluster
Bhuiya, Rahad (2026). HuddleCluster. Zenodo. https://doi.org/10.5281/zenodo.20348019

License

Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-or-later). See LICENSE for details.

Contact: rahadbhuiya2021@gmail.com

About

High-performance distributed load balancer.

Topics

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages