The problem: everyone clicks at the same moment
Selling tickets looks like basic CRUD. A user picks seats, pays, gets a ticket. Insert a row, send an email, done.
Then a popular event goes on sale. Hundreds of people hit "Buy" within the same few seconds, and a lot of them want the same front rows. Now the boring CRUD app has to answer a hard question over and over: who actually got that seat?
At work I spent a good stretch on the backend of a SaaS ticketing platform built with FastAPI, PostgreSQL, Celery, Redis, Docker and Pytest. This post covers the parts that decided whether it was reliable: holding seats safely under concurrent requests, tuning PostgreSQL before reaching for a cache, moving slow work into background jobs that are safe to run twice, and the tests that let me change all of it without fear.
The flow, end to end
The short version: FastAPI validates the request and works out the price. PostgreSQL decides who gets the seat, inside one transaction.…