Skip to content

Rate limiter is per-pod in-memory: multi-replica deployments enforce N× the documented tier limits #635

Closed

Description

@robertocarlous

Context

src/middleware/rateLimiter.ts wraps express-rate-limit but never configures a custom store (grep shows no store/redis/db-backed counter usage), so counters live in each pod's memory. src/routes/registry.ts mounts adminRateLimiter, authRateLimiter, internalRateLimiter, webhookRateLimiter plus the tier matrix from src/middleware/rateLimitTiers.ts (634 lines) — and docs/RATE_LIMITING.md now publishes the tier budgets as if they were global.

Problem

With n replicas behind an LB, a client can make up to n × max requests per window (and much more if pod count scales under load — the limit scales with the attack). The tier matrix test (tests/unit/middleware/rateLimitTierMatrix.test.ts) only validates per-instance behavior, so CI cannot catch this.

Proposal

  • Back express-rate-limit with a shared store (Redis, consistent with the existing Redis usage for cache invalidation and feature-flag sync)
  • Keep the in-memory store only for NODE_ENV=test
  • Verify Retry-After/X-RateLimit-* headers derive from the shared counter
  • Add a multi-instance test (two app instances, one Redis) asserting the combined count trips the limit

Acceptance criteria

  • Shared store configured; pod count no longer multiplies effective limits
  • Integration test with two instances against one Redis proves global enforcement
  • docs/RATE_LIMITING.md notes the distributed enforcement model

Activity

  1. maxx-GENIUS commented on Oct 20, 2026

    @maxx-GENIUS

    @maxx-GENIUS has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Ready to ship immediately! Focus: Backend Services & Distributed APIs (Node.js / TypeScript) for "Rate limiter is per-pod in-memory: multi-replica d". Plan: Engineer idempotent request handlers with strict schema validation, robust error propagation, and optimized database queries. Guaranteed 100% green CI & test coverage. Zero hand-holding. SLA: clean PR in 1-2h. Track record: 166+ merged PRs in Web3 (OSS score 83, Top 2%).

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @maxx-GENIUS to this issue.

  2. maxx-GENIUS commented on Oct 20, 2026

    @maxx-GENIUS

    ⚡ Protocol Implementation Blueprint & Production Readiness Proposal

    Hi @maintainers, I am ready to implement and ship this issue immediately.

    I have reviewed the repository architecture and pre-analyzed the execution path for this task so you don't have to spend any time onboarding or hand-holding:

    1. Scope & Execution Boundary

    • Target Domain: Backend Services & Distributed APIs (Node.js / TypeScript)
    • Target Issue: Rate limiter is per-pod in-memory: multi-replica deployments enforce N× the
    • Architectural Scope: Review API route contracts, payload schemas, and database interaction boundaries for Rate limiter is per-pod in-memory: multi-replica deployments enfo.

    2. Implementation Strategy & Invariants

    • Engineer idempotent request handlers with strict schema validation, robust error propagation, and optimized database queries.
    • Preserves backward compatibility and strict type invariants across existing public APIs and internal interfaces.

    3. Verification & Quality Assurance Guarantee

    • Validate end-to-end endpoint contracts with integration tests and verify OpenAPI/Swagger documentation parity.
    • CI Guarantee: 100% green local test runs, zero linter/formatter warnings, and clean build checks before opening the PR.

    4. Turnaround SLA & Track Record

    • Estimated Delivery: Complete, atomic, ready-to-merge PR within 1–2 hours of assignment.
    • Zero Maintainer Overhead: Fully autonomous execution—branch is ready, dependencies reproduced locally, and ready to push.
    • Review SLA: Active availability with sub-15 minute revisions for any requested review tweaks.
    • Verified Pedigree: 166+ Merged PRs across Stellar & Web3 protocols | OSS Activity Score: 83 (Top 2% Global Contributor) | Fast & deterministic protocol-grade delivery.

    Looking forward to your green light! Ready to branch and ship.

  3. AbelOsaretin commented on Oct 20, 2026

    @AbelOsaretin
    Contributor

    @AbelOsaretin has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I would love to work on this issue.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @AbelOsaretin to this issue.

  4. drips-wave commented on Oct 20, 2026

    @drips-wave

    Congratulations, @AbelOsaretin! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @AbelOsaretin: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  5. drips-wave commented on Oct 20, 2026

    @drips-wave

    This issue has been completed by @AbelOsaretin as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @AbelOsaretin: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  6. grantfox-oss commented on Oct 20, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @AbelOsaretin's PR #705 was approved and merged by @robertocarlous.

    🏆 @AbelOsaretin: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,105 total points). Track your full progress on GrantFox.

    👏 Great work, @AbelOsaretin! Keep contributing to Neurowealth.

  7. added a commit that references this issue on Oct 20, 2026
    8332bae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions