Skip to content
Request full CV
All cases

Aerodisk

Background task service on FastAPI and PostgreSQL

Result

All writes of the new storage API

Task

Long operations on disks ran inside the web request and broke when the connection dropped. I designed and launched a service that runs them as tracked tasks, and every write of the new storage API goes through it.

Situation

Management operations on disks and volumes ran inside the HTTP request or in different background mechanisms. A client lost the connection or got a timeout while the change on the disks went on.

Cause

An operation had no identity, status or log of its own, apart from the request that started it.

What I did

I described the task model, its states and the API contract. The gateway saves a task and answers at once with its identifier, a processor takes the task and runs the action, and the client reads the status separately. Tasks live in PostgreSQL, with a local copy on the second controller through logical replication. A task is claimed by a conditional update, so two processors never take the same one, and one task runs at a time per cluster. I looked at ready message brokers first and chose a durable store with a simple processor, because a broker added operations work and did not solve consistency with the local devices.

Result

Long operations are separate from the HTTP request, and all writes of the new storage API go through the service. A refactoring of 33 days removed 587 lines while adding features; then I handed the service over with documentation to a team of 6.

Stack

  • Python
  • FastAPI
  • PostgreSQL
  • SQLAlchemy
  • Alembic
Request full CV

Try a question a recruiter asks