VINGRADGmbH
Deutsch English

2026-10-26 · Architecture

A job queue and search in three languages without new services: what PostgreSQL can do

Five new features for a messenger that teams install on their own server with one command. Each could have dragged in a service of its own. In the end, none was added.

Email invitations, push notifications, search, webhooks and an import from Slack. Background jobs usually mean a message broker, search usually means Elasticsearch or Meilisearch. But for a self-hosted product, every extra service is one more duty for whoever runs the server.

The queue

Jobs live in PostgreSQL and are claimed with FOR UPDATE SKIP LOCKED. Retries use exponential backoff, a crashed worker’s job is picked up again, and imports that run for hours extend their lock with heartbeats. If a job contains a one-time link from an email, its payload is erased once it has run.

The one trap was the clock. The start time came from the application’s clock but was compared with the database’s NOW(). The database container’s clock was behind, so new jobs counted as “not due yet”. Now the database sets the time itself. If a rule compares with database time, the database should also write it.

Search in three languages

The teams write in German, English and Russian, often mixed. The index is a generated tsvector column: exact tokens of any language without diacritics at weight A, plus English, Russian and German stems at weight B. The query combines four websearch_to_tsquery calls. The GIN index is built CONCURRENTLY in a migration of its own, because the migration tool runs each file inside a transaction.

I do not hand-write access rights into the SQL. A test compares the search rule with the regular access check on a random configuration.

It is also written down in advance when to move on: above roughly 10 million messages, p95 above 500 milliseconds, or once typo tolerance or search inside files is needed. Until then all five features run on the PostgreSQL, Redis and storage that were already there, and the end-to-end check has grown from 22 to 57 scenarios.

All entries

Does this fit your project?

If you are looking for someone who works like this, book a first call or write to me.

Book a first call Write