Creative Writing | Bold
Espresso: Brewing PDFs at Zomato, Faster Than You Can Say “Cappuccino”
ST
By Shalini Trivedi (Blogger)

March 31, 2025

| 4 Min read

Espresso: Brewing PDFs at Zomato, Faster Than You Can Say “Cappuccino”
Espresso is our open-source PDF generation and signing solution. It delivers PDFs in under 200 milliseconds while reducing server costs by 90%. Built on Go and Chromium, it’s fast, scalable, and now available to the community at large.

Introduction

At Zomato, we love food and we love data. And sometimes, those two passions collide in the creation of beautiful, portable, and secure PDFs. From invoices and receipts to detailed reports, PDFs are a cornerstone of our operations and a staple across the industry. However, our existing PDF generation process, powered by a PHP-based library, was starting to show its age. We encountered latency issues, especially during the peak hours and the situation worsened with complex, multi-page PDFs that included significant graphical content.

We needed a solution that could sustain our growing demands – something faster, more efficient, and scalable.

The Perfect Blend: Chromium and Golang

In pursuit of a more tailored and efficient approach, we decided to develop our in-house PDF generation solution. We chose Go as our programming language, given its performance and our team’s familiarity with it.

For rendering, we leveraged Rod, a go library for controlling headless Chromium. For PDF signing, we integrated Go PDF (digitorus/pdf), allowing us to generate and sign PDFs directly from HTML templates. This approach gave us full control over layout, styling, and security.

Custom Certificate Signing

To ensure the authenticity and integrity of our PDFs, we implemented digital signing using a custom certificate. This adds a layer of security and trust to our documents, which is especially important for sensitive information like financial transactions.

Optimizations: Squeezing Every Last Drop of Performance

We’re always looking for ways to improve performance, and Espresso is no exception. We implemented several optimizations to make our PDF generation process as fast and efficient as possible:

  • Pre-Paint PDF Generation: We generate the PDF before the paint step of the rendering process, saving valuable time.
  • Chromium Flags: We fine-tuned various Chromium flags to further improve the start time of the application.
  • DataURI Image Prefetching: We prefetch HTML images from the template and save them as dataURIs, reducing the rendering cost by eliminating the need for the browser to download images on page load.
  • Streamlined Processing: By combining PDF generation and signing into a single application, we can work with streams instead of files, improving performance and reducing disk I/O.

Brewing PDFs for Everyone

We developed a small front-end application to accompany this system, allowing anyone at Zomato to create and customize PDF templates effortlessly. This tool empowers users to modify existing templates or design new ones from scratch, all while receiving real-time feedback on the appearance of their final PDF output.

Benchmarks: The Proof is in the Pudding

Espresso isn’t just fast – it’s incredibly fast. Espresso has been successfully deployed across the majority of our PDF generation workflows, delivering consistently impressive performance metrics.

  • Rendering and Signing Times Under 200ms: Espresso can render and sign PDFs in under 200 milliseconds, making it ideal for high-traffic applications.
  • Peak Load Handling: Espresso can handle peak loads of 120K requests per minute (RPM), ensuring your users never have to wait for their PDFs.
  • Massive Signing Capability: We recently signed 1.6 million PDFs in just 19 minutes – approximately 1,400 PDFs per second.

These numbers were witnessed when running espresso as an AWS ECS service with 4vcpu and 4G memory. This scaled to a hundred containers at peak load.

Espresso’s efficiency is truly remarkable. Compared to our prior system, it demands significantly less infrastructure, drastically reducing resource consumption. This translates directly into substantial cost savings, resulting in a 90% deduction in server costs for generating the same volume of PDFs.

Prev Post

10 AI Tools That Replace a Full Dev Team (Almost)

Next Post

The Power of UI/UX: Designing for Better Digital Experiences

5 Comments
Riya Jain

By Riya Jain

ok

Posted on: 8 May, 2025
Raghav Sharma

By Raghav Sharma

Very Nice Content

Posted on: 31 March, 2025
Raghav Sharma

By Raghav Sharma

Very Good

Posted on: 31 March, 2025
Raghav Sharma

By Raghav Sharma

Nice Content

Posted on: 31 March, 2025
Raghav Sharma

By Raghav Sharma

Very Good

Posted on: 1 April, 2025
©Copyright 2025 KidsChaupal. All rights reserved.