Rate limits
Published Updated
publira server limits what it can tell apart: password attempts, the mail it sends, and each reader action, such as posting a comment or using a wait-for-free ticket, as Rate limits describes. It limits anonymous reads too, but only loosely, as What publira server limits itself describes: under that limit, one client can still fetch every page of every free episode, or run the search until the database falls behind, and the first sign of it is /readyz failing. Those requests have to be limited per client in front of it as well: by a managed WAF or CDN, or by the proxy at the edge.
What to limit
Limit each reader's address, the one The client address has the edge record, on a tenant's domain and its image host:
- The public API,
/rpc/publira.v1., which the mobile app calls. - The search, which runs the most expensive query a reader can ask for: the search procedures of the public API,
/rpc/publira.v1.CatalogService/SearchPublished…, and the site's search page,/searchor/<locale>/search, which runs the same search on the server. Give it a lower limit than the rest of the API. - The images,
/images, which every page of an episode is. A reader opening an episode loads all of its pages at once, so allow a burst of several hundred.
Answer a request over the limit with 429 Too Many Requests. Each limit counts per address, so readers behind one address, such as a carrier's NAT or an office network, share it: set them for the busiest address you expect a legitimate reader to come from, not for one reader.
The console hosts are left to the limits publira server keeps, their images among them: their traffic is your staff's, and the episode uploads and editing screens there are the heaviest an install serves.
What never to limit
- The webhooks under
/api/v1/webhook/, which Webhooks lists. A provider refused there retries, and a payment is recorded late, or a reader's reply never reaches the console. - The health checks,
GET /readyzandGET /livez, which a load balancer or an orchestrator sends to each process. A health check refused for its rate takes a healthy process out of service.
A bot challenge or a sign-in prompt in front of a path refuses the mobile app and the webhook providers as well, as Bot challenges describes.
In a managed WAF or CDN
An install on a cloud platform almost always has a managed load balancer or a CDN in front of it, and the web application firewall that comes with it is where the limit belongs. AWS WAF on CloudFront or an Application Load Balancer, Cloud Armor on a Google Cloud load balancer, and Cloudflare's rate limiting rules each count a reader by the address that connected to them and refuse a request before it reaches anything you run. With the paths above limited there, the proxy behind it needs no limits of its own. Remove them, or trust the hop first: a proxy that does not trust the hop counts every reader as the hop's address, and refuses all of them together.
A managed WAF counts a reader's requests over a window, such as 10 seconds or a minute, and refuses the rest of that window once the count is reached. Write one rule per row below, matching its paths on a tenant's domain and image host, so that nothing else is counted, the webhooks and the health checks included. The counts are the most the sample configurations admit from one client in that time:
| Requests | In 10 seconds | In a minute |
|---|---|---|
The public API, /rpc/publira.v1., except the search | 320 | 1,320 |
The search procedures, /rpc/publira.v1.CatalogService/SearchPublished… | 40 | 140 |
The search page, /search or /<locale>/search | 40 | 140 |
The images, /images | 1,200 | 4,200 |
A window admits its whole count at once, so prefer the shortest one your WAF offers.
- AWS WAF: a rate-based rule per row in the web ACL of the CloudFront distribution or the load balancer, with a scope-down statement matching the host and the path, the source IP address as the aggregation key, and an evaluation window of 60 seconds, its shortest, with the minute's count as the limit. Give its Block action a custom response with the status code
429; it answers403otherwise. - Google Cloud Armor: a rate limiting rule per row in the security policy of the load balancer's backend services, with the
throttleaction, a match expression onrequest.headers['host']andrequest.path,IPas the key, an interval of 10 or 60 seconds with the count for it as the threshold, anddeny(429)as the action past it. Preferthrottletorate_based_ban: a ban keeps refusing a reader for its whole duration, even once they have slowed down. - Cloudflare: a rate limiting rule per row, matching the hostname and the URI path and counting by IP, with a period of 10 seconds or a minute, and the Block action, which answers
429. The plan sets how many rules a zone has, one on the Free plan, which counts over 10 seconds only, two on Pro, and five on Business; with fewer than four, limit the search first, since it costs the database the most.
In the proxy you run
A proxy you run limits requests when nothing in front of it does. The Traefik and nginx sample configurations limit the paths above as they ship, and the Caddy one carries its limits commented out, since they need a module the caddy image does not include.
What publira server limits itself
Behind the edge, publira server keeps a limit of its own on the same reads, so that an edge that limits nothing, such as the stock caddy image of the Docker Compose install, leaves an install less protected rather than unprotected. It counts each reader's address over windows of 10 seconds, sharing the count between every instance through Redis when PUBLIRA_REDIS_URL names one. Until you change it, it allows twice the 10-second column of the table above:
| Requests | In 10 seconds, built in | In 10 seconds, at least | publiractl policy set flag |
|---|---|---|---|
The public API, /rpc/publira.v1., except the search | 640 | 320 | --anonymous-read-public-api-per-10-seconds |
The search procedures, /rpc/publira.v1.CatalogService/SearchPublished… | 80 | 40 | --anonymous-read-search-per-10-seconds |
The images of a tenant's domain and image host, /images | 2,400 | 1,200 | --anonymous-read-images-per-10-seconds |
The images of a tenant's console host are counted against the images limit too, apart from those of its domain and image host, so a member of staff who has spent one still has the other. An editing screen loads every page of an episode at once, as a reader opening one does.
A call past it is refused with resource_exhausted, and an image with 429, each with a Retry-After header naming the wait. Behind an edge with the limits above, a reader is refused by the edge first. The server's limit applies whatever the edge allows, so an edge allowance raised past it, for readers who share one address such as a carrier's NAT, admits requests the server then refuses. Raise the server's limit along with it: it is part of the platform policy, and the Platform Console's Security page or the flags above change it. A saved change reaches every instance within ten seconds, without a restart. A value below the least one, which is what the sample configurations admit in 10 seconds, is refused naming its field or its flag, so that the edge stays the first to refuse a reader. Readers behind one address share the server's limit as they share the edge's.
The server cannot count what reaches it from inside the install. A request whose every hop is one of the trusted proxies is a web app calling as itself for all of its readers at once, so it is not counted. That covers the site's search page, which web-storefront runs on the server, so web-storefront limits that page itself, as What web-storefront limits itself describes. A call web-storefront makes for one reader outside its cache, such as for a signed-in reader or to record a page view, carries that reader's address and is counted as theirs. The webhooks and the health checks are not counted either, and of a console host only the images are.
What web-storefront limits itself
web-storefront limits the site's search page, /search or /<locale>/search, per reader's address, which it finds in the forwarded headers the way publira server does. It allows 80 requests in 10 seconds, twice the 10-second column of the table above, so that a reader behind an edge with the limits above is refused by the edge first, and answers a request past it with 429 and a Retry-After header naming the wait. Every instance of web-storefront counts a reader together through the Valkey or Redis its PUBLIRA_REDIS_URL names, which is the server's. Without that variable, and while that server cannot be reached, each instance counts on its own, so the limit loosens to one per instance rather than going away. A page published at /search in place of the search page is counted the same way.
It limits the page view a detail page records as it opens, sent to /api/v1/views, in the same way, at 30 requests in 10 seconds per reader's address. The edge does not limit that path. A view refused for its rate is not counted, and the page it came from is not affected. Readers behind one address, such as a carrier's NAT, share the allowance, so on an install whose readers do, some of their views go uncounted.
Neither limit has a setting. An edge allowance for the search page raised past it, for readers who share one address, admits requests web-storefront then refuses.
Distributed denial of service
Protecting an install from a distributed denial of service is the hosting provider's job, not the edge's: a limit per address does nothing against requests from many addresses.