Skip to content

Hydrate from the public AppView instead of users' sessions - #15

Draft
ngerakines wants to merge 1 commit into
mainfrom
nick/public-appview-hydration
Draft

ngerakines wants to merge 1 commit into
mainfrom
nick/public-appview-hydration

Conversation

@ngerakines

Copy link
Copy Markdown

Hydration now reads profiles and posts from Bluesky's public AppView, unauthenticated, instead of resuming stored account sessions. Startup no longer fetches session strings from the Graze API.

  • One client against PUBLIC_APPVIEW_URL (default https://public.api.bsky.app) makes the same getProfiles / getPosts calls, 25 per page, into the same models and caches.
  • Retries. 429, 5xx and network failures are retried with exponential backoff and jitter. Each wait is at least what Retry-After / ratelimit-reset asks, capped by APPVIEW_MAX_RETRY_AFTER_SECONDS. A page that still fails leaves that metadata empty, and the records go out as before.
  • New counters: jetstream_turbo_appview_requests_total{endpoint,status_class}, _rate_limited_total, _retries_total and _failures_total. They measure the public AppView's rate limits, which are not known yet.
  • Removed: graze_api.py, session loading, CLIENT_BANDWIDTH, TURBO_CREDENTIAL_SECRET and graze_api_base_url.

Behaviour change

Results are viewer-neutral. Viewer fields are no longer populated; for example, hydrated_metadata.user.viewer.known_followers.count is now null.

Checks

pytest: 47 passed, including tests/test_public_appview.py (backoff, Retry-After, batching, and no credentials in settings).

Rollout

Merging deploys. Run it first beside the current deployment and compare output, then switch over.

Startup no longer fetches account session strings from the Graze API, and
hydration no longer resumes (and refreshes) those sessions to call
getProfiles/getPosts through users' PDSes. One unauthenticated client
against PUBLIC_APPVIEW_URL (default https://public.api.bsky.app) makes the
same calls, 25 per page, into the same models and caches.

429, 5xx and network failures are retried with exponential backoff and
jitter, waiting at least what Retry-After / ratelimit-reset asks (bounded
by APPVIEW_MAX_RETRY_AFTER_SECONDS). A page that still fails leaves that
metadata empty and the records go out as before.

New counters: jetstream_turbo_appview_requests_total{endpoint,status_class},
_rate_limited_total, _retries_total and _failures_total.

Removed: graze_api.py, session loading, CLIENT_BANDWIDTH,
TURBO_CREDENTIAL_SECRET and graze_api_base_url. Viewer fields are no longer
populated (e.g. hydrated_metadata.user.viewer.known_followers.count).
@ngerakines

Copy link
Copy Markdown
Author

Production has been hydrating from the public AppView since 2026-12-02 13:45Z, through an overlay rather than a build of this branch.

What is running: an image built FROM the previous production digest (d5978999…, tag 20261101-hydration-retry-overlay). It replaces three files with this PR's change ported onto the running code:

  • bluesky_api.py: unauthenticated client against PUBLIC_APPVIEW_URL, retries on 429/5xx/network errors.
  • turbocharger.py: one public client instead of borrowed sessions, plus a stream-only audit mode used for the comparison.
  • config.py: graze_api_base_url and turbo_credential_secret removed.

graze_api.py is deleted, so nothing calls /api/v1/turbo-tokens/credentials any more. The running digest is sha256:eda5b5c8…, and rollback is set image back to d5978999….

Before main can be rolled: main only writes to S3 and Redis when OUTPUT_TO_S3 / OUTPUT_TO_REDIS are set. Production sets neither, so a build of main would hydrate and write nothing. Both settings are read with bool(os.getenv(...)), so any non-empty value, including false, turns egress on.

Comparison before the switch: audit mode ran this code on a shard of the firehose into a separate stream.

  • Users and quotes matched the borrowed-session output.
  • Parent and reply posts matched, except a handful found only on one side. Those were just-created posts read through the CDN cache.
  • Counts drift within cache age, and viewer is null by design.
  • Load: 0 × 429 at about 500 req/min for 30 min. After the switch, about 900 req/min, all 2xx.

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