Skip to content
Non-⁠profit · 2022–2024

A major non-⁠profit foundation: donation reports thousands of times faster

A major non-⁠profit foundation publishes its donation reports openly. We made its public report pages fast and proved it with load tests.

0.71 msaverage API response, down from 1.9 s
When
2022–2024
Client
Major non-⁠profit foundation
Scope
Database and API performance

Challenge

Report pages summed millions of transactions by date, project, source and currency on every request. As the number of donations grew, data and filters began to take more than 5 seconds to load, and the reports needed to keep up with big fundraising campaigns, when the most people are watching.

What we built

  • Profiling and indexes. We found the slow queries and added composite and full-text indexes.
  • Ready-made totals. A PostgreSQL materialised view with daily precision, grouped by source, project, currency and amount range, plus an hourly read model, so totals are read instead of recalculated.
  • A lighter API. Dates travel in ISO 8601 (UTC), and sums and averages are calculated in the browser.
  • A cache in front of the API with nginx.
  • Proof, not promises: k6 load tests, charts, correct local-time day boundaries and automated tests for the numbers.

Results

  • Reports opened in 0.5 s instead of more than 5 s, ten times faster, even before the cache.
  • On a 5-million-record test set the table shrank from 444 MB to 23 MB, and the indexes became an order of magnitude smaller.
  • With the cache, the average response time of the report API fell from 1.9 s to 0.71 ms (k6, 20 virtual users).
  • The same load test served almost three times more requests.
Let’s talk

Planning something similar?

Describe your project in the form below, and we’ll reply in writing with how we would approach it. Or book a 30-⁠minute call with our founder about scope, timeline and the team we’d put on it.

Wrocław, Poland · Central European Time

Prefer to write? Describe the task in two or three lines and we’ll reply by email.

    We use your details only to reply. Privacy

    Thank you! Your message is with us, and we’ll reply by email.

    Test mode: the form works, but this preview sends nothing.

    Book a 30-⁠min call