Skip to content

Allow extended api call limit with client side cache - #2813

Merged
cb-github-robot merged 1 commit into
cloud-barista:mainfrom
seokho-son:main
Oct 8, 2026
Merged

cb-github-robot merged 1 commit into
cloud-barista:mainfrom
seokho-son:main

Conversation

@seokho-son

@seokho-son seokho-son commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

GET /ns/{ns}/infra/{id} and GET /ns/{ns}/infra are the heaviest read APIs (full etcd read plus per-node hydration) and were capped at 2 req/s per client. Behind a gateway or NAT every GUI shares that budget, so normal polling from a few clients already hit rate limit exceeded, while each poll still cost a full read.

Changes

  • Read cache (1 s) with singleflight for the Infra detail (default option) and Infra list (default/simple). Concurrent identical requests share one fetch; the result is reused for one second. Every write path (UpdateInfraInfo, UpdateNodeInfo, node create/delete, Infra create/delete) invalidates the Infra's entries, so a read right after a control request returns the new state. detail=true, accessinfo and status bypass the cache.
  • Concurrency cap of 8 on the full Infra read; a request waiting longer than 3 s gets 503 with Retry-After: 1.
  • Configurable rate limits via TB_API_RATE_LIMIT_GLOBAL (default 200:400), TB_API_RATE_LIMIT_INFRA_LIST (10:30), TB_API_RATE_LIMIT_INFRA_GET (5:15), in rate:burst form. 429 responses now carry Retry-After: 1. Documented in conf/setup.env.

Verification

  • Unit tests: coalescing, invalidation, expiry, write-path invalidation, semaphore overflow.
  • Live (2-node Infra): 10 concurrent detail reads served as one fetch; 40 back-to-back reads hit 429 only after the configured burst with Retry-After; a detail read right after a suspend request showed Suspending, not the cached Running.

Notes

  • Defaults raised: list 2→10/s, detail 2→5/s, global 50→200/s. Clients should honor Retry-After on 429/503.
  • Limits remain per client IP; XFF-based identification was intentionally not added.

Signed-off-by: Seokho Son <shsongist@gmail.com>
@seokho-son
seokho-son requested a review from yunkon-kim as a code owner October 8, 2026 08:42
@seokho-son

Copy link
Copy Markdown
Member Author

/approve

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: seokho-son

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions github-actions Bot added the approved This PR is approved and will be merged soon. label Oct 8, 2026
@cb-github-robot
cb-github-robot merged commit 359ec4d into cloud-barista:main Oct 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants