Where state actually lives, and the correctness problems that appear the moment two requests touch the same row.

  1. Databases in the Backend — [Intermediate] — modelling, querying, and the ORM tradeoff from the application’s side

Go deeper elsewhere

This section is deliberately thin because the depth already exists:

The backend-specific parts

  • Transaction boundaries belong in the service layer, not the repository — the service knows what must succeed together. → layers
  • Concurrent writes are a correctness problem: optimistic locking (@Version), pessimistic (SELECT … FOR UPDATE), or an atomic conditional UPDATE … WHERE qty > 0. Know which your isolation level requires.
  • The connection pool is usually your real concurrency limit — and smaller is often faster. Time spent waiting for a connection is invisible unless you instrument it.
  • N+1 queries are the most common performance regression, and they exhaust the pool, which makes them a service-wide incident. → production debugging
  • Migrations must be backwards-compatible with the currently-running code — expand, migrate, contract.
↑ Back to Backend