retrystorm · Learn · Interview practice · Glossary · Components

Home › Interview practice › Export in the Background

Export in the Background

Turning a notebook into a PDF takes the better part of a second. Accept exports at once and render them on workers.

Inkwell's PDF exports are back, and bigger: every export is now rendered as a finished book, about 400 ms of CPU each. Writers don't need the PDF instantly; they need the app to say "we're on it" and the file to arrive a moment later. About 2% of renders fail and have to be tried again.

What it does

  • Read: a user opens a note.
  • Write: a user asks for a PDF export, which has to be rendered and saved.

Workload

A steady 1 000 rps for 30 seconds, 95% reads / 5% exports, against 10 000 notes. That's 50 exports a second.

How to build it

The app servers and the database are fixed. Exports go through a message queue to workers, which render each one and save it to the database. You choose the queue's settings and the workers' tier and instances.

  1. Build the path for reads: client, load balancer, app server, database.
  2. Send writes from the app server to a queue, connect the queue to a worker, and the worker to the database.
  3. Size the workers so exports are ready in seconds, for as little as you can. A job that fails its last attempt is lost, so give the queue enough attempts.

Part of Chapter 11: Queues and Workers.

About · Contact · Privacy · Terms of use