Skip to content

[CLEAN] Synthetic Benchmark PR #19957 - Add semaphore to limit concurrent API calls during Kubernetes observer startup#570

Open
tomerqodo wants to merge 1 commit intobase_pr_19957_20260121_5967from
clean_pr_19957_20260121_5967
Open

[CLEAN] Synthetic Benchmark PR #19957 - Add semaphore to limit concurrent API calls during Kubernetes observer startup#570
tomerqodo wants to merge 1 commit intobase_pr_19957_20260121_5967from
clean_pr_19957_20260121_5967

Conversation

@tomerqodo
Copy link

Benchmark PR PrefectHQ#19957

Type: Clean (correct implementation)

Original PR Title: Add semaphore to limit concurrent API calls during Kubernetes observer startup
Original PR Description: closes PrefectHQ#19937

Summary

  • Adds a configurable semaphore to rate-limit concurrent API calls during Kubernetes observer startup
  • Prevents the "thundering herd" problem when there are many existing pods/jobs in the cluster
  • Default concurrency limit is 5, configurable via PREFECT_INTEGRATIONS_KUBERNETES_OBSERVER_STARTUP_EVENT_CONCURRENCY
Changes
  • Added startup_event_concurrency setting to KubernetesObserverSettings with default value of 5
  • Added module-level semaphore _startup_event_semaphore initialized during observer startup
  • Wrapped the startup event deduplication API call with the semaphore to limit concurrent requests
  • Added test to verify semaphore correctly limits concurrency

🤖 Generated with Claude Code
Original PR URL: PrefectHQ#19957

…r startup

closes PrefectHQ#19937

When the observer starts, it receives events for all existing pods/jobs
and checks for duplicates via API calls. This can overwhelm the server
when there are many pods. This change adds a configurable semaphore
(default: 5 concurrent calls) to rate-limit these startup checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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