Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Functional Horizontal scaling for Slack #3008

Merged
merged 10 commits into from
Nov 6, 2024
Merged

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Oct 31, 2024

Description

The gist of it

  • Tenant Acquisition Loop

    • Pods run acquire_tenants_loop at intervals (TENANT_ACQUISITION_INTERVAL).
      • Fetch all tenant IDs from the database and attempt to acquire a Redi lock which expires after TENANT_LOCK_EXPIRATION. If acquired, begin handling
  • Heartbeat Mechanism

    • Pods run heartbeat_loop at intervals (TENANT_HEARTBEAT_INTERVAL).
      • For each tenant the pod handles:
        • Update a heartbeat key in Redis (DanswerRedisLocks.SLACK_BOT_HEARTBEAT_PREFIX:{pod_id}).
          • Indicates the pod is alive.
          • Heartbeat expires after TENANT_HEARTBEAT_EXPIRATION.
    • Ensuring One Pod per Tenant:
      • If a pod fails or stops sending heartbeats:
        • Its locks expire after TENANT_LOCK_EXPIRATION.
        • Other pods can acquire the lock and take over the tenant.
      • Prevents a single pod from monopolizing a tenant if it becomes unresponsive.
  • Scaling with HPA

    • Pods expose active_tenants_gauge metric to Prometheus.
      • Reflects the number of tenants each pod is handling.
    • Horizontal Pod Autoscaler (HPA) uses this metric to adjust pod replicas.
      • Scales Up:
        • When active tenants per pod exceed a threshold.
      • Scales Down:
        • When the number of active tenants decreases.
    • Ensures sufficient pods are available to handle all tenants efficiently.

Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 6, 2024 9:53pm

@hagen-danswer hagen-danswer merged commit faeb9f0 into main Nov 6, 2024
6 of 7 checks passed
@hagen-danswer hagen-danswer deleted the horizontal_slack branch November 6, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants