audit: ~110 ms from request arrival to first application code on campus.audit (campus.auth/admin: ~5–7 ms)

Open
#1,245 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
flask, python

Research direction

Start at campus/audit/__init__.py:53-54, where _authenticate_audit_api_key timestamps after _extract_request_context parses the body — an upper bound on the delay. Timestamp at WSGI entry before Flask dispatch, then compare GET vs POST and direct vs gateway to separate pre-Flask time from hook time. Compare campus.auth's first before_request hook and both start commands for worker class and backlog. Done means a root cause or bounded explanation naming the remaining measurement, plus a fix or documented reason to accept it.

Written by the indexing model from the issue text.

Description

perf

Part of #1243 (campus.audit metrics & telemetry).

Observation

From a read-only sample of the 200 newest development traces (2026-11-24, 10:17–15:31 UTC). Elapsed time is from request arrival (X-Request-Start, set by Railway's edge) to the span's started_at.

Service p50 p90 max n
campus.audit, via the gateway 105 ms 240 ms 390 ms 120
campus.audit, direct domain 116 ms 339 ms 376 ms 44
campus-admin, direct domain 6.6 ms 12 ms 30 ms 17
campus.auth, direct domain 5.5 ms 19 ms 24 ms 15

Caveats

  • One day, one environment, light traffic (0.64 rows per minute), and small samples for two of the four rows.
  • For campus.audit the timestamp is taken in _authenticate_audit_api_key (campus/audit/__init__.py:53-54), after _extract_request_context has read and parsed the JSON body. For the other two services it is taken in the first before_request hook. The audit figure is therefore an upper bound on queueing alone.
  • The two clocks are on different machines (edge and service). The 5 ms floor on campus.auth suggests skew is small.

Hypotheses, none tested

  1. Reading the POST body inside the hook. An ingest body is 2–15 KB, which should not take 100 ms, but connection behaviour (keep-alive, Nagle) might.
  2. Worker pickup. The gunicorn worker class and arguments of campus.audit may differ from campus.auth's; start commands are per-service settings and are not in the repo.
  3. The edge-to-service hop behaving differently for this deployment.
  4. Hook ordering — something registered before the authentication hook.

How to investigate

  • Timestamp at WSGI entry, before Flask dispatch, and compare with the hook timestamp. That separates "before Flask" from "inside the hook".
  • Compare GET against POST, small against large bodies, direct against gateway.
  • Read both services' start commands and compare worker class, threads and backlog.
  • Once the metrics epic lands queue_ms, this becomes a continuous per-service signal instead of a one-off sample.

Acceptance

A root cause, or a bounded explanation with the remaining measurement named; and a fix, or a documented reason to accept it.

Dominant language
Python
Stars
0
Forks
2
Avg merge
39m
Merged PRs (30d)
235

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nyjc-computing/campus

All issues in nyjc-computing/campus

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.