Skip to content

feat: soften HTTP rate limits with bounded queues + request timeout - #63

Merged
fclairamb merged 15 commits into
mainfrom
feat/soften-http-rate-limits-with-queues
May 16, 2026
Merged

fclairamb merged 15 commits into
mainfrom
feat/soften-http-rate-limits-with-queues

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

Softens the per-IP HTTP rate / concurrency middleware: instead of an immediate 429 the moment a token or slot is unavailable, requests get a bounded waiting room (default 10 deep) capped at MaxQueueWait (default 30 s). Adds a server-wide 30 s request-duration ceiling that returns 504 REQUEST_TIMEOUT if the queue wait plus handler execution overruns.

Implements the spec in specs/done/2026/05/2026-05-16-01-soften-http-rate-limits-with-queues.md.

What changed

  • Bounded slow lane for the rate limiter — RateQueue requests per IP may wait for the next token refill before being rejected.
  • Bounded waiting room for the concurrency limiter — ConcurrencyQueue requests per IP may wait for an active slot to free.
  • Wait-time headers on success-after-wait: X-Rate-Limit-Delayed-Ms, X-Concurrency-Queued-Ms. Hard rejects still set Retry-After: 60.
  • Server-wide RequestTimeout middleware wrapping every route on mainGroup. Race-safe writer prevents the handler from double-writing after the 504 is emitted; separate handlerStarted / timedOut flags so the canonical WriteHeader + Write pattern still reaches the wire.
  • Config (SP_SERVER_RATE_LIMITING_RATE_QUEUE, _CONCURRENCY_QUEUE, _MAX_QUEUE_WAIT, SP_SERVER_MAX_REQUEST_DURATION) with sensible defaults; manual env readers because koanf's loader can't parse multi-word snake_case under the SP_ namespace.
  • Metric solidping_http_rate_limited_total gains two new reason values: rate_delayed and concurrency_queued (admitted-after-wait) alongside the existing hard-reject labels.

Test plan

  • go test ./internal/middleware/ -count=1 — 22 / 22 (includes regression for WriteHeader + Write body propagation)
  • make lint-back clean
  • make build-backend and make build-dash0 succeed
  • Manual smoke against a running dev server: with tight RPM=12 BURST=2 RATE_QUEUE=3, expect 2 fast 200, 3 slow 200 with the new header, 5 × 429 — capture in PR comment after merge.

🤖 Generated with Claude Code

fclairamb added 14 commits May 16, 2026 19:17
…utWriter

The previous single 'claimed' bool meant that calling WriteHeader followed
by Write (the canonical JSON-handler pattern) caused WriteHeader to set the
flag and Write to silently swallow the body, leaving the client with an
empty 200. Split the flag in two so the 504-vs-handler race is exclusive
without breaking the normal two-step write sequence. Add a regression test
covering WriteHeader + Write.
@fclairamb
fclairamb enabled auto-merge (squash) May 16, 2026 18:00
@fclairamb
fclairamb merged commit 025501b into main May 16, 2026
10 checks passed
@fclairamb
fclairamb deleted the feat/soften-http-rate-limits-with-queues branch May 16, 2026 18:07
@fclairamb fclairamb mentioned this pull request May 16, 2026
fclairamb added a commit that referenced this pull request Jun 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.0](v0.0.0...v0.1.0)
(2026-06-22)


### Features

* add check type registry, sample configs, notification senders, and
observability integrations
([eea049e](eea049e))
* batch — Warning/Degraded statuses, SSL/Docker check upgrades, MCP
OAuth 2.1, config-as-code
([#85](#85))
([936d830](936d830))
* batch spec implementations (dashboard UI, jobs, notifications, SaaS,
perf) ([#78](#78))
([fe003e4](fe003e4))
* bulk feature integration (discovery, web push, badges, webhooks, and
more) ([#73](#73))
([a976856](a976856))
* custom user-agent, refresh checks, vite plugin switch, CI updates
([#1](#1))
([cc00858](cc00858))
* documentation site served at /docs (co-located in web/docs)
([#88](#88))
([27d9ccd](27d9ccd))
* email check frontend (spec 03)
([#30](#30))
([aebd106](aebd106))
* email inbox foundation via JMAP (spec 01)
([#24](#24))
([0f3b0c1](0f3b0c1))
* email passive checks (spec 02)
([#27](#27))
([ba5536f](ba5536f))
* **entitlements:** trim to MaxSSOUsers + MaxChecksPerMinute + status
page history fixes
([#50](#50))
([a007de0](a007de0))
* **entitlements:** trim to MaxSSOUsers + MaxChecksPerMinute, enforce
both ([#49](#49))
([d25cc5f](d25cc5f))
* group incident correlation (spec 04 backend v1)
([#31](#31))
([1883986](1883986))
* **observability:** instrument hot path + add bench harness
([#60](#60))
([c6604cc](c6604cc))
* **oncall:** searchable timezone dropdown + sidebar logo polish
([#46](#46))
([4396898](4396898))
* per-IP HTTP rate limiting and concurrency limiting
([#59](#59))
([f9cc273](f9cc273))
* soften HTTP rate limits with bounded queues + request timeout
([#63](#63))
([025501b](025501b))
* SolidPing — distributed uptime monitoring platform
([eef4383](eef4383))
* **statuspages:** drag-and-drop resource reordering + dash conventions
([#41](#41))
([cf910d4](cf910d4))


### Bug Fixes

* **deps:** update dependency i18next to v26
([#26](#26))
([d5d1b7e](d5d1b7e))
* **deps:** update dependency lucide-react to v1
([#28](#28))
([cdc8e8c](cdc8e8c))
* **deps:** update dependency react-i18next to v17
([#29](#29))
([13135d8](13135d8))
* **deps:** update dependency recharts to v3.8.1
([#14](#14))
([5d95a3b](5d95a3b))
* **deps:** update go dependencies (non-major)
([#16](#16))
([2450f13](2450f13))
* **deps:** update go dependencies (non-major)
([#19](#19))
([f842310](f842310))
* **deps:** update go dependencies (non-major)
([#37](#37))
([c020eca](c020eca))
* **deps:** update go dependencies (non-major)
([#44](#44))
([ff0bcd0](ff0bcd0))
* **deps:** update go dependencies (non-major)
([#52](#52))
([2e3bc28](2e3bc28))
* **deps:** update go dependencies (non-major)
([#69](#69))
([a65ed4c](a65ed4c))
* **deps:** update go dependencies (non-major)
([#77](#77))
([a0920ff](a0920ff))
* **deps:** update go dependencies (non-major) to v1.4.2
([#86](#86))
([1eb7504](1eb7504))
* **deps:** update module github.com/aws/aws-sdk-go-v2/config to
v1.32.18 ([#72](#72))
([6406537](6406537))
* **deps:** update module github.com/aws/aws-sdk-go-v2/service/s3 to
v1.101.0 ([#39](#39))
([f9c9563](f9c9563))
* **deps:** update module github.com/go-webauthn/webauthn to v0.17.3
([#45](#45))
([593931a](593931a))
* **deps:** update module github.com/go-webauthn/webauthn to v0.17.4
([#70](#70))
([fca1c97](fca1c97))
* **deps:** update module github.com/ibm/sarama to v1.48.1
([#47](#47))
([93ccf3a](93ccf3a))
* **deps:** update module github.com/ibm/sarama to v1.48.2
([#54](#54))
([e84d868](e84d868))
* **deps:** update module github.com/ibm/sarama to v1.49.0
([#64](#64))
([fd61bd7](fd61bd7))
* **deps:** update module github.com/oapi-codegen/runtime to v1.4.1
([#65](#65))
([a3a3e9f](a3a3e9f))
* **deps:** update module github.com/prometheus/common to v0.67.5
([#61](#61))
([095dd6f](095dd6f))
* **deps:** update module github.com/slack-go/slack to v0.24.0
([#75](#75))
([6e86d5b](6e86d5b))
* **deps:** update module golang.org/x/sys to v0.44.0
([#42](#42))
([a245730](a245730))
* **deps:** update module golang.org/x/sys to v0.45.0
([#67](#67))
([49c3d90](49c3d90))
* **deps:** update module golang.org/x/term to v0.43.0
([#43](#43))
([4a934f1](4a934f1))
* **deps:** update module google.golang.org/grpc to v1.81.0
([#36](#36))
([1be183a](1be183a))
* **deps:** update module google.golang.org/grpc to v1.81.1
([#55](#55))
([6bfac2d](6bfac2d))
* status lifecycle improvements and created/running result handling
([#5](#5))
([fc64c7d](fc64c7d))
* **status0:** white page header and de-duplicated footer
([#48](#48))
([77506a7](77506a7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
This was referenced Sep 8, 2026
fclairamb added a commit that referenced this pull request Nov 12, 2026
… issues) (#848)

Closes fclairamb/solidping-business#63
Closes fclairamb/solidping-business#64
Closes fclairamb/solidping-business#65
Closes fclairamb/solidping-business#67
Closes fclairamb/solidping-business#68

## What changed
- #66 (demo session renewal) was dropped: a demo session should not be
renewed more often than any other. Spec 07 moved to `specs/cancelled/`.
- #63: the watchdog no longer WARNs for contact types the server can
never deliver to. Check leases are now sized on the check timeout plus a
margin (`SP_CHECKERS_LEASE_MARGIN`, default 30s). Lost leases and claim
timeouts are measured (new Prometheus metrics, WARN logs), on the
in-process and HTTP worker paths.
- #64: the "Checks at a glance" strips follow the 24h / 7d / 30d window.
- #65: the status page form shows the server's slug error and a toast
instead of an unhandled rejection.
- #67: sign in with Telegram, for users who already linked the same
Telegram account only, off by default (`SP_TELEGRAM_LOGIN_ENABLED`; the
bot's domain must be set with @Botfather `/setdomain`).
- #68: a "Failures" toggle on the check page lists only failed runs.
- Batch gate: one fix, the documented-defaults test now knows
`SP_TELEGRAM_LOGIN_ENABLED`.

## Decided by autopilot
- Spec 06, lease: size it up front, not extended during the run
(recommended answer).
- Spec 08, Telegram: only users who already linked that account may sign
in; worth shipping now behind the default-off switch (recommended
answers).

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant