Skip to content
All posts

What a PDF render costs: compute is the cheap part

We measured where the cost of producing a PDF goes. Compiling turned out to be the cheap part and moving the finished PDF the expensive one. Here is the breakdown and why 2 GB of memory is the sweet spot.

  • cost
  • infrastructure
  • typst

We wanted to know, not guess, what producing one PDF costs. This post is the measurement we did on 3 November 2026, using list prices for serverless compute in Mumbai. Prices will drift, but the shape of the result is what matters, and it surprised us.

The setup being priced

Rendering runs on a native Typst 0.15.1 compile service in Mumbai, on arm64 serverless compute with 2 GB of memory and a 70 second ceiling. In front of it sits the API itself, which handles authentication, quotas, the database, 24-hour PDF storage and the async queue. The compile service is the part that scales with every render, so that is what we measured first.

Three documents, three very different renders

DocumentPagesPDF sizeCompute timePeak memory
Invoice214 KBabout 4 ms46 MB
Report30539 KBabout 305 ms109 MB
Long report3005.4 MBabout 3.6 s690 MB

Compute is billed by memory multiplied by time, so a two-page invoice costs almost nothing to compute. The 300-page report costs about a thousand times more to compute.

Picking the memory size

Serverless compute allocates CPU in proportion to memory, so the memory setting is really a speed setting. We swept it:

  • 1 GB was about 3.3 times slower than 2 GB. Less CPU, and the long report was close to the memory limit.
  • 4 GB was only about 8% faster than 2 GB, at twice the price per second. Typst is mostly single-threaded, so extra cores sit idle.

2 GB is the sweet spot, and it is what the service runs at.

The cost per render

A render has three costs: the compute, a fixed fee per request, and moving the finished PDF out of the compute provider. This is how each render's cost splits between them:

DocumentComputeRequestMoving the PDF outRelative to the invoice
2-page invoiceabout 5%about 15%about 80%1×
30-page reportabout 13%under 1%about 87%about 35×
300-page reportabout 14%under 1%about 86%about 350×

The result we did not expect: moving the PDF out is 85 to 90% of the cost of a larger document, not compiling it. Cost is close to proportional to PDF size, with compute included. A template with embedded photos or many fonts produces a bigger PDF and costs more than this text-heavy test, regardless of how fast it compiles.

Two lessons we took from this

First, a 300-page render costs over 300 times a two-page one, so plans that count renders rather than pages quietly subsidise long documents. Since November 2026 a PDF counts once for every 50 pages started, so a 120-page report counts as three. Short documents, which are most of them, still count as one.

Second, since PDF size drives cost, the most effective optimisation is not a faster compiler but smaller output: subsetting fonts, compressing images, and not embedding a 2 MB logo on every invoice. Typst already subsets fonts. The other two are up to the template.