Skip to content

Add load balancing #236

@vcarl

Description

@vcarl

Load Balancer Architecture

Track horizontal scaling implementation using deterministic guild sharding.

Architecture

Load Balancer → HTTP Service (stateless, 2-10 pods)
                    ↓
              hash(guildId) % NUM_PODS → Gateway Pod N
                    ↓
              SQLite + Litestream → DO Spaces

Issues

Issue Title Tier Risk Status
#229 Litestream backup sidecar 1 Low Open
#230 Ingress rate limiting/timeouts 1 Very Low Open
#231 PostgreSQL StatefulSet - - Closed
#232 SERVICE_MODE support 3 Medium Open
#233 Config service - - Closed
#234 HTTP service + deterministic routing 3 Medium Open
#235 Gateway StatefulSet + shard filtering 4 High Open

Dependencies

#229 (Litestream) ──┐
                    ├── #232 (SERVICE_MODE) ── #234 (HTTP) ──┐
                    │                                        ├── #235 (Gateway)
                    └────────────────────────────────────────┘

Key Decision: Deterministic Sharding

Eliminated config service (#233) and PostgreSQL (#231) in favor of deterministic sharding:

const podOrdinal = hash(guildId) % NUM_GATEWAY_PODS;
const gatewayUrl = `http://gateway-${podOrdinal}.gateway-internal:3000`;

Benefits: Simpler, no external state, no network lookups
Trade-off: Scaling requires coordination (all pods recalculate)

References

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions