Repository navigation
Conversation
The limiter now uses moving-window counting in REDIS_URL when set, falls back to per-process counting if Redis is unreachable, and never fails a request over a limiter error. Adds tests for the 61st-request 429 on every limited route.
After a PSX 429 the cooldown is written to psxdata:psx_cooldown with an expiry, so every worker stops calling PSX, not just the one that was refused. If Redis errors, each process falls back to its own timer.
WEB_CONCURRENCY sets the worker count (default 1, unchanged). --proxy-headers makes uvicorn use X-Forwarded-For from the addresses listed in FORWARDED_ALLOW_IPS, which defaults to 127.0.0.1 so behaviour is unchanged where no proxy sets it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets the API run several workers on one self-hosted VM with no per-process state.
moving-window) whenREDIS_URLis set. If Redis is down it falls back to per-process counting and never fails a request over the limiter./healthstays unlimited, as before.psxdata:psx_cooldown, set with an expiry), using the same client as the/historicalcache. Redis errors fall back to the in-process timer.--workers ${WEB_CONCURRENCY:-1} --proxy-headers. Defaults are unchanged where the variables are not set.linux/amd64andlinux/arm64.deploy/oracle/: Compose bundle (api, redis, caddy), Caddyfile,.env.example, README. Fixed bridge subnet, Caddy at a fixed address thatFORWARDED_ALLOW_IPStrusts alone; api and redis are not published to the host; log rotation 20m x 5.deploy-oracle.yml: after "Publish Docker Image" succeeds (or manually, with an optional tag) copies the bundle over SSH, setsAPI_TAG,docker compose pull && up -d, and polls/healthfor about 2 minutes. Skips with a notice whileORACLE_SSH_HOSTis unset.fakeredis[lua]added to dev extras: the moving-window limiter uses Lua scripts, which fakeredis only runs withlupa.Testing
pytest tests/api/: 261 passed.ruff check api/andmypy api/clean./healthunlimited, Redis-backed storage shared between limiter instances, fallback with Redis down; cooldown shared across two services, key expiry, fallback on Redis errors, factory wiring.docker compose -f deploy/oracle/compose.yaml configvalidates (withAPI_DOMAINandACME_EMAILset).v0.8.1, branch names and empty input.Not in this PR
servers=[...]toapi.psxdata.org(done at cutover).psx-log-exporter.