Skip to content

Budget the diagram exporters, on the paths production already has - #288

Open
adamjohnwright wants to merge 2 commits into
mainfrom
feat/render-rate-limit
Open

adamjohnwright wants to merge 2 commits into
mainfrom
feat/render-rate-limit

Conversation

@adamjohnwright

Copy link
Copy Markdown
Contributor

CURATOR-REPORT.md listed rate limiting in front of the render service as the outstanding condition before it fronts reactome.org. Doing that turned up something worth more.

The Java exporters have no budget either — and they're the ones with a history

/ContentService/exporter/* is where crawlers exhausted Tomcat's heap and took the origin down. Today it is covered only by the site-wide 100r/s, which is sized for page assets, not for a process drawing a diagram. Verified: no limit_req on /ContentService/ at all, and the path answers 200 on both beta and production right now.

Both, sharing one zone

2r/s, burst 8 — the node service's own queue depth (RENDER_CONCURRENCY=2, RENDER_QUEUE=8); past that it is rejecting anyway, so a deeper burst only buys a larger pile of work to throw away.

They share the zone deliberately: the budget belongs to the work — drawing a diagram — rather than to which implementation serves it, so a caller cannot spend it twice by alternating between the Java exporter and the node renderer.

Why the ContentService path is the point

Those URLs exist in production today, and #273 moves those exports to node under the same names. So the budget is already where it needs to be when the implementation changes underneath it, and /RenderService stops being the only protected way in.

Verified against the running services

  • exporter still returns a PNG through the new block
  • an ordinary /ContentService/data/database/version is unaffected
  • the node renderer still returns a 11952×6700 PNG, and an SVG (the inline detail-page case)
  • both budgets refuse past the burst: 8 through, then 503

nginx -t passes for dev, production and release.

🤖 Generated with Claude Code

adamjohnwright and others added 2 commits September 21, 2026 21:05
CURATOR-REPORT.md listed rate limiting in front of the render service as the
outstanding condition before it fronts reactome.org. Doing that turned up
something worth more: the Java exporters have no budget either, and they are
the ones with a history. `/ContentService/exporter/*` is where crawlers
exhausted Tomcat's heap and took the origin down, and today it is covered only
by the site-wide 100r/s, which is sized for page assets rather than for a
process drawing a diagram.

So the budget goes on both, and they share a zone. It belongs to the work --
drawing a diagram -- rather than to which implementation serves it, so a caller
cannot spend it twice by alternating between the Java exporter and the node
renderer. 2r/s with a burst of 8, which is the node service's own queue depth
(RENDER_CONCURRENCY=2, RENDER_QUEUE=8); past that it is rejecting anyway, so a
deeper burst only buys a larger pile of work to throw away.

Putting it on the ContentService path is also the point rather than a
coincidence. Those URLs exist in production today and are what #273 moves to
node, under the same names -- so the budget is already where it needs to be
when the implementation changes underneath it, and `/RenderService` stops being
the only protected way in.

Verified rather than reasoned, against the running services: the exporter still
returns a PNG through the new block, an ordinary /ContentService/ path is
unaffected, the node renderer still returns a 11952x6700 PNG and an SVG, and
both budgets refuse past the burst -- 8 through then 503.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The prefix version of this would have throttled reaction pages to protect
something they do not use. `/ContentService/exporter/` is not one kind of
thing: `/exporter/reaction/{id}/diagram` is a 2.9 KB JSON document served in
0.17s and it is on the critical path for every reaction page, while a render of
R-HSA-109606 on the same prefix is 454 KB, and 7 MB at full quality.

Measured both before changing it, which is the only reason the difference was
visible: I had written the prefix, tested that it refused past the burst, and
that test passed exactly as happily on the endpoint that must not be refused.

A regex location now names the four that draw -- diagram, fireworks, document,
event -- so it is tried before the /ContentService/ prefix and everything else,
the reaction JSON included, falls through unbudgeted.

Verified: fifteen rapid reaction-diagram requests all 200, the render path
refuses past the burst, and a real render returns its 454 KB PNG once the
budget refills. That last check matters because the run before it returned 503
-- my own flood had spent the budget -- and stopping there would have shipped
on a failure I had caused.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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