Skip to content

perf(platform): every REST API request writes its key holder's rate-limit row #4716

Closed

Description

@yannickmonney

Summary

Every authenticated REST API request charges its key holder's rest:api budget in the database before it does anything else (services/platform/backend/rest/v1.ts:273-276, checkUserRateLimit(deps.sql, 'rest:api', session.user.id); limits in lib/rate-limit.ts:159). Verified on main at aa53363.

That is one rate-limit row write per request, and all requests of one integration key land on the same row, so a busy integration serializes on it and adds a write to every read it makes. At the 4% API-client share of a million-user run this is thousands of writes per second for reads.

Suggested fix

Count in memory per process (a token bucket per key holder) and reconcile with the shared row in batches, or shard the counter row; keep the database check only where an exact cross-process limit matters.

Activity

  1. added
    priority: low
    perf
    service: platform
    on Oct 10, 2026
  2. added
    agent-ready
    on Oct 29, 2026
  3. added a commit that references this issue on Nov 1, 2026
    1a1314f
  4. added a commit that references this issue on Nov 1, 2026
    fd59fad
  5. added 2 commits that reference this issue on Nov 1, 2026
    8364181
    757efb8
  6. tale-code-bot commented on Nov 1, 2026

    @tale-code-bot
    Collaborator

    Landed on the feature line release/0.6 with feature train #5265, merged by rebase at 2026-11-01 17:57:59Z, as 757efb8 perf(platform): charge rest:api from leased slices, not per request (task TALE-125). It ships with Tale 0.6.0.

    GitHub closes an issue from a Closes #4716 line only for a commit on the default branch main, so the feature-train role closes it here.

  7. added 15 commits that reference this issue on Nov 2, 2026
    680ba97
    04844ee
    33e26fa
    9827c78
    ec14299
    2f3197c
    0eccae2
    b32047c
    2c11aad
    d27fa88
    d2cbf85
    156902e
    9760a65
    983c554
    444924f
  8. added a commit that references this issue on Nov 15, 2026
    b94e67d
  9. added a commit that references this issue on Nov 23, 2026
    6a98b46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyperfpriority: lowservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions