Skip to content

Space-based architecture

Most systems eventually hit the same wall under heavy load: you can add application servers easily, but they all wait on one database. Space-based architecture removes the database from the request path. Each processing unit holds the application logic and the data it needs in an in-memory data grid, replicated between units. The database is updated asynchronously in the background.

The name comes from tuple spaces, a distributed shared-memory idea from the 1980s. Today the style is implemented with in-memory data grids such as Apache Ignite, Hazelcast, Oracle Coherence or GigaSpaces. It’s a specialized style for extreme and unpredictable load: ticket sales, flash sales, online auctions, bidding and trading platforms.

Processing units with a replicated in-memory grid1. A surge of requests arrives, and the messaging grid sends each one to an available processing unit. 2. The unit handles the request entirely in memory, with no database call on the way. 3. Changes are replicated between units' in-memory grids, so every unit sees the same data. 4. Updates flow asynchronously to the database through a data writer, usually via a queue. Clientsa sudden surge Messaging gridroutes requests Deploy manageradds, removes units Processing unitapp + in-memory data Processing unitapp + in-memory data Processing unitstarted for the peak Data readerloads data at start Data writerasynchronous Databaseoff the request path1234
Processing units with a replicated in-memory grid Requests are served from memory; units scale out and in with load; the database is written to in the background.
  1. A surge of requests arrives, and the messaging grid sends each one to an available processing unit.
  2. The unit handles the request entirely in memory, with no database call on the way.
  3. Changes are replicated between units' in-memory grids, so every unit sees the same data.
  4. Updates flow asynchronously to the database through a data writer, usually via a queue.
  • Processing units contain the business logic, an in-memory data grid with the data that logic needs, and a replication engine. They’re usually deployed as containers or virtual machines.
  • Replication between units keeps their grids consistent, either fully replicated (every unit has all data) or partitioned (each unit owns part of the data, with backups).
  • Virtualized middleware manages the units: a messaging grid that routes requests, a data grid that coordinates replication, a processing grid for requests that span units, and a deployment manager that starts and stops units with demand.
  • Data pumps send changes asynchronously, typically through a message queue, to data writers that update the database. Data readers load data into units when they start.
  • Elastic scale. Because no unit waits on the database, adding units adds throughput almost linearly, up to the limits of replication.
  • Extreme scalability and elasticity for read- and write-heavy spikes.
  • Very low latency, since requests are served from memory.
  • The database stops being the bottleneck, and can even be briefly unavailable without stopping requests.
  • Complex: replication, collisions between units, cache sizing and recovery all need expertise.
  • Data consistency is hard: concurrent updates to the same data in different units can collide, and the database lags behind memory.
  • Data loss risk if units fail before changes reach the database, unless the data pump is durable.
  • Memory limits and cost: the working data set must fit in memory across units.
  • Hard to test realistically, because the behavior that matters only appears at very high load.
  • Load that’s both very high and very spiky: concert ticket on-sales, flash sales, auctions, online betting, trading and bidding systems.
  • Workloads where a fixed working set (inventory, seats, bids, sessions) fits in memory and must be updated very quickly.
  • Most business applications. Caching, read replicas and queues usually solve the problem far more simply. See scenario: the database is the bottleneck.
  • Large data sets that don’t fit in memory, or analytics over long history.
  • Systems needing strict, immediate consistency across all data, such as core ledgers.
  • Reaching for it too early, before simpler fixes like indexing, caching and partitioning.
  • Ignoring collision rates: with full replication, more units and more updates to the same data mean more conflicts.
  • A non-durable data pump, so a crash loses updates that were never written.
  • Reporting from the database without accounting for its lag behind memory.

Glossary: eventual consistency, CAP theorem

  • Mark Richards and Neal Ford, Fundamentals of Software Architecture (O’Reilly, 2020), chapter on space-based architecture
  • Mark Richards, Software Architecture Patterns (O’Reilly report)
  • Apache Ignite, Documentation (opens in a new tab)

Written and edited by Abhinav Taduka, enterprise software architect.