Reference
Operations and scale for document generation
Document generation has an unusual failure profile. The capability reference says what each option does. The troubleshooting pages start from a symptom you are looking at. These start from a decision made before the symptom exists.
Three properties shape all of it. Rendering is expensive per unit, so throughput matters in a way it does not for a read. The load is bursty rather than steady, because documents are produced on cycles: invoicing on the first, payroll at month end, statements overnight. And the artefact usually carries an identity, so a duplicate is not a harmless repeat the way a duplicated read is. That last one is why the correctness group below is the largest.
The single highest-value item, if you read one: allocate the document's identity before rendering it rather than during. It costs nothing, it makes retries safe, and it is the difference between a timeout producing one document and producing two with different numbers.
Correct under repetition
Documents frequently carry an identity, so a duplicate is not a harmless repeat. Everything in this group is about the same work arriving more than once: a retry, a double click, a redelivered message, a batch that half succeeded.
- Idempotency
Making a repeated request produce the same document rather than a second one, which matters more here than in most APIs because the artefact is often numbered.
- Retry safety
Deciding which failures should be retried and which should not, because a blanket retry on a document endpoint is a duplication mechanism.
- Deduplicating requests
Collapsing concurrent identical requests, which is a different problem from idempotency because both arrive before either has finished.
- Caching a rendered document
Serving a previously rendered document instead of making a new one, which is nearly free when the inputs are unchanged and wrong when they are not.
- What the cache key actually is
The full list of inputs a rendered document depends on, which is longer than the data and is the reason document caches serve stale output.
- Queue design for a document run
Structuring a job that produces thousands of documents at once, where the interesting decisions are about failure and progress rather than throughput.
- Batch sizing
Choosing how much work goes in a single call, which trades round trips against blast radius and against a real per-plan limit.
- Partial failure in a batch
The normal outcome of a large batch, which is neither success nor failure, and which most client code has no branch for.
- Dead letter documents
The handling for work that has exhausted its retries, which for documents means somebody is missing something they were promised.
- Synchronous against asynchronous
Whether the user waits for the document, which is a decision about the document's size and the user's expectation rather than about performance.
- Callbacks and webhooks
Being told when work finished instead of asking repeatedly, which removes polling and adds an endpoint that has to be correct about who is calling it.
- Scheduling a recurring run
Running a document job on a calendar, where the interesting failures are a run that did not happen and a run that happened twice.
- Backpressure
What the system does when demand exceeds capacity, which is a decision to make rather than a behaviour to discover.
- Rate limits in client design
Building the caller so it stays within a limit rather than discovering it, which is a different question from what to do when a 429 arrives.
Knowing what it is doing
A render that produced the wrong document does not fail, so ordinary error monitoring sees nothing. These pages are about the signals that do exist, and about being able to answer what happened to one specific document three weeks ago.
- What to log about a render
The fields that make a render diagnosable weeks later, and the one thing that must not be in the log at any level.
- Tracing a render end to end
Following a single document across the queue, the render and the delivery, which is the only way to answer where the time went or where it stopped.
- Measuring render latency
Recording the distribution rather than the mean, because document render times are skewed by document size and the tail is what people experience.
- Timeouts along the whole path
Making the timeouts at each hop consistent with each other, because a path whose timeouts disagree fails in the least useful way available.
- Alerting on document generation
Choosing signals that catch the failures that matter, which for documents includes several that produce no error at all.
- Auditing a document run
Keeping enough operational history that a specific document's story can be reconstructed, which log retention alone usually cannot do.
- Reprocessing after an incident
Re-running a set of documents that were produced wrongly, which is a recovery operation with its own risks and needs planning before it is needed.
- A runbook for a render outage
The decisions to make when rendering is unavailable, most of which are about what to tell people and what to preserve rather than about restoring service.
What it costs and what it can take
Rendering costs real money per unit and arrives in bursts rather than steadily, which makes capacity a different question here than for a read-heavy service. These pages are about the numbers and about what the system does when they are exceeded.
- Cost per document
Adding up the real per-document cost, which is more than the render and is the number every capacity and caching decision depends on.
- Capacity planning for a peak
Sizing for a workload that is idle most of the time and enormous occasionally, which is the normal shape for documents and the wrong shape for averages.
- Warm against cold latency
The latency difference between a pipeline that has been busy and one that has been idle, which for a monthly workload means every run starts cold.
- Concurrency limits
Picking a concurrency that uses the available capacity without exceeding it, which is a measured number rather than a guessed one.
- Storage lifecycle for generated files
Deciding what happens to a document after it is delivered, which is a policy question with a cost attached and a legal floor underneath it.
- Quota and usage monitoring
Tracking consumption against the allowance so a limit is a planned event rather than a failed monthly run.
- Graceful degradation
Producing something useful when the full document cannot be made, which is sometimes right and frequently worse than failing.