DocumentsCloud-Barista's Space
CSP API Rate Limiting
CSP API Rate Limiting
Type
Topic
Status
Published
Created
Jul 13, 2026
Updated
Jul 13, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

CSP API Rate Limiting#

CB-Tumblebug enforces per-CSP and global concurrency limits when performing bulk operations — primarily spec fetching and resource registration — to stay within cloud provider API rate limits. The configuration is centralized in src/core/model/csp/csp.go and consumed by the bulk operation logic in src/core/resource/spec.go.


Configuration: RateLimitConfig#

The RateLimitConfig struct captures three categories of limits per CSP:

FieldPurpose
MaxConcurrentRegistrationsMax parallel connections during resource registration
RegistrationDelayMinMs / RegistrationDelayMaxMsStagger delay range to prevent API bursts
MaxConcurrentRegions / MaxNodesPerRegionVM creation parallelism
MaxConcurrentRegionsForStatus / MaxNodesPerRegionForStatusVM status fetch parallelism

A global cap of GlobalMaxConcurrentConnections = 10 applies across all CSPs simultaneously.

Per-CSP values are looked up via GetRateLimitConfig(providerName), which resolves derived CSP names (e.g., openstack-new01openstack) before table lookup. Unknown CSPs fall back to a conservative default (MaxConcurrentRegistrations=3, delays 1000–3000ms).

Per-CSP Limits at a Glance#

CSPMaxConcurrentRegistrationsDelay Range (ms)MaxConcurrentRegionsForStatusNotes
AWS5500–200010
Azure4500–20008
GCP41000–300012
Alibaba31000–30006Strict API; see below
Tencent22000–50006Hard 10 req/sec limit
IBM3500–200010
NCP21000–30003Strictest infra limits
NHN21000–30005
KT21000–300010
OpenStack3500–20005


Bulk Spec Fetching: Two-Level Semaphore#

fetchSpecsForAllConnConfigsInternal uses a two-level concurrency model:

  1. Provider goroutine — one goroutine per CSP provider, all run in parallel.
  2. Connection semaphore — within each provider, a buffered channel limits concurrent connections :
    • Default: 50 concurrent connections per provider
    • Alibaba override: 5 — empirical testing showed concurrency ≥10 causes ~90% timeout on DescribeAvailableResource

Each connection task runs with a 20-minute timeout. Capacity test results are inline in the code comments :

CSPConnections testedParallel result
AWS28All OK (~8.8s)
GCP42All OK (~3.2s)
Azure46All OK (~100s)
Tencent16All OK (~11.0s)
IBM11All OK (~8.5s)
Alibaba29Limited to 5

Price Fetching: Three-Level Concurrency#

Bulk price fetching in spec.go adds a third layer :

  1. Provider-level: max 3 providers processed simultaneously via semaphore
  2. Per-provider connection-level: 8 concurrent connections for GCP and Azure; 8 for AWS; configurable for Alibaba (TB_ALIBABA_REGION_CONCURRENCY, default 10)
  3. Spider path: 15 concurrent connections for all other providers

Alibaba: Dedicated Rate-Limit Handling#

Alibaba has the most complex rate-limit handling, in src/core/csp/alibaba/price.go:

  • Worker pool: default 5 goroutines (TB_ALIBABA_PRICE_WORKERS)
  • Per-call delay: 200ms between DescribePrice calls (TB_ALIBABA_PRICE_INTERVAL_MS)
  • Retry with backoff: up to 3 retries (TB_ALIBABA_PRICE_MAX_RETRY), base 1200ms backoff + jitter, triggered on ErrorCode: Throttling or TooManyRequests
  • Transient network retry: single retry for connection reset, I/O timeout, TLS handshake timeout, EOF

Adding a New CSP#

To configure rate limits for a new provider :

  1. Add a name constant to csp.go and append it to AllCSPs.
  2. Add a RateLimitConfig entry to rateLimitConfigs with appropriate limits.
  3. If the CSP is a derived instance (e.g., private OpenStack), call RegisterCloudPlatform at startup so it resolves to the base platform's config.