Solve hotspotting in a database

You can for sure scale up. Otherwise, see below.

Either give up consistency (1), or make writes slower (2), or use a version number (3). Or break the data down into smaller consistent chunks (4), which is usually not feasible.

  1. Give up consistency and expose clients to stale writes. Add a cache between the client and the datastore. The staleness can be bound by cache expiry. 99% staleness can be improved by invalidation.
  2. Add more readonly replicas to the datastore. Make writes notify all of them before returning. Limits the concurrency of writes. Require changing the datastore.
  3. Also add a cache, but make the cache read the version number before serving cached results. Writes always increases the version number in a transaction. Requires transaction at least within a row.
  4. Break down different component of the hotspotting data and spread the load. Often we don’t need to read a huge chunk of data at the same time.

What is the limiting factor of hot spotting ? Locks? TCP connection? Memory bandwidth? Queue depth and thus availability memory volume ? All of these can be mitigated by a few proxy servers in front of the datastore, Which allows batching.