In the print dialog, choose “Save as PDF”.
Adservio

Reactive programming architecture across platforms

Reactive programming and R2DBC: Reactive Streams, backpressure, Spring Data R2DBC, Hasura, PostGraphile, MongoDB Atlas, benefits, limits and an evaluation method.

ADSERVIO INSIGHTS · DEVSECOPS

CATEGORYDevSecOps
READING TIME7 min
DATE1 October 2021
FORMATAdservio Insights article
CONTACThello@adservio.fr

KEY POINTS

  • Reactive programming responds to asynchronous events and data streams to gain availability and performance under high concurrency.
  • R2DBC connects SQL databases via reactive drivers, with a minimal SPI surface and native backpressure handling; Spring Data R2DBC is now its reference implementation.
  • Gains (CPU, memory, throughput, latency) are real but concentrated on high-concurrency workloads: at low concurrency, the complexity overhead is not worth it.
  • Hasura GraphQL, PostGraphile Realtime and MongoDB Atlas each provide a different building block for constructing an end-to-end reactive architecture.
  • Adopting reactivity requires rethinking monitoring, error handling and testing: a methodical upfront evaluation avoids costly anti-patterns.

SECTION 1

Introduction: why reactivity is becoming strategic again

Reactive programming architecture offers real advantages to developers seeking to improve the availability and performance of their systems. Here we focus on R2DBC (Reactive Relational Database Connectivity), a specification designed to integrate SQL databases through reactive drivers, without sacrificing the transactional guarantees of the relational world.

R2DBC's goal is to keep a minimal SPI surface while remaining fully reactive and backpressure-aware across the whole database layer. In 2026, this topic is back at the centre of attention: event-driven architectures, real-time APIs and high-volume AI inference workloads have put non-blocking concurrency back at the heart of architecture decisions, well beyond the historic Java-only world.

SECTION 2

The fundamentals of reactive programming

### The Reactive Streams model

Reactive programming rests on a paradigm that looks simple on the surface: components respond to asynchronous events and data streams instead of blocking a thread while waiting for a response. The Reactive Streams specification, implemented by Project Reactor, RxJava or Akka Streams, standardises four interfaces (Publisher, Subscriber, Subscription, Processor) that guarantee interoperability between reactive libraries, regardless of vendor.

### Backpressure in practice

The key mechanism is backpressure: the consumer of a stream signals to the producer how much data it can absorb, preventing a slow service from being overwhelmed by a fast one upstream. Without this flow control, a traffic spike translates into a buffer memory explosion and, ultimately, a cascade of failures. This property is what sets reactivity apart from simple async/await usage: it natively protects the system against saturation, something no purely asynchronous model guarantees by construction.

SECTION 3

R2DBC: reconciling SQL with end-to-end non-blocking

### A minimal SPI surface

R2DBC starts from an observation: JDBC is blocking by design, forcing reactive applications to isolate their database access in dedicated thread pools, a costly workaround that breaks the end-to-end promise of non-blocking. R2DBC defines a deliberately small service provider interface surface, leaving it to database vendors to implement a native reactive driver rather than adapting an existing JDBC driver.

### The Spring Data R2DBC ecosystem and available drivers

Spring Data R2DBC, now folded into the broader Spring Data Relational module alongside Spring Data JDBC, remains the reference implementation on the JVM and exposes streams through Mono and Flux from Project Reactor. Mature R2DBC drivers now exist for PostgreSQL, MySQL, MariaDB, Microsoft SQL Server, Oracle and H2, covering most enterprise relational backbones. That maturity changes the picture compared to 2021: R2DBC is no longer a curiosity but a production-grade option for teams building end-to-end reactive APIs.

SECTION 4

Measurable benefits, concentrated on high concurrency

### CPU, memory and throughput

The core advantage lies in the system's capacity to respond to asynchronous events and data streams, letting developers gain availability and performance. On top of that come several benefits measured in load benchmarks: reduced CPU and memory consumption per request thanks to the absence of threads blocked waiting on I/O, significantly faster response times under high concurrency, and improved throughput at those same load levels, gains typically observed fall between 20% and 40% more requests handled at equal CPU resources, in high-contention scenarios.

### When reactivity brings nothing

One notable point: you do not need a fully non-blocking stack to implement R2DBC. The technology proves most valuable for high-concurrency applications; organisations with low-concurrency workloads will see only limited gains, while still paying the real cost of the added complexity, code that is harder to read, less intuitive debugging, and a significant learning curve for teams used to the synchronous model.

SECTION 5

Implementation platforms

### Hasura GraphQL

Hasura GraphQL provides out-of-the-box tools for asynchronous programming, acknowledging that a reactive architecture requires an atomic and reliable eventing system, with queue management and event-triggered listeners. Native GraphQL subscriptions build on this foundation to expose real-time streams directly to the client, without extra wiring code.

### PostGraphile Realtime

PostGraphile Realtime, for its part, offers baseline subscriptions and live queries in its core, with extensibility through plugins, whether community-created or custom-developed. The approach appeals to teams that want to derive a reactive GraphQL schema directly from the PostgreSQL schema, without an extra abstraction layer to maintain.

### MongoDB Atlas and Reactive Streams

MongoDB Atlas simplifies adoption by automatically providing access to a GraphQL API, which removes the usual migration complexity. The MongoDB Reactive Streams Java Driver supports non-blocking backpressure, in line with R2DBC standards, and integrates natively with Project Reactor for teams already invested in the Spring ecosystem.

SECTION 6

Pitfalls and anti-patterns to avoid

The first pitfall is mixing blocking and reactive code in the same pipeline: a single synchronous JDBC call slipped into a Reactor chain is enough to block the shared thread and silently degrade the whole service. The second is underestimating the testing effort: classic assertions are no longer enough, dedicated tools like StepVerifier are needed to validate a stream's behaviour over time, including its error and cancellation cases.

The third pitfall concerns observability: context propagation (trace IDs, log MDC) does not cross thread boundaries as naturally as it does in synchronous mode, which complicates incident diagnosis if instrumentation was not designed from the start. These questions connect to broader architecture concerns, in particular how to properly decouple business logic from technical infrastructure.

@cite:architecture-hexagonale-principes-et-benefices

SECTION 7

How to evaluate the relevance for your system

The right question is not "should we adopt reactive programming?" but "at what concurrency level does my system operate today, and tomorrow?". A first filter is to profile the current load: if the number of simultaneous connections remains modest and response times are dominated by CPU-bound work rather than I/O waits, reactivity will not deliver a gain proportional to its complexity.

A second filter concerns the system's external exposure: APIs that aggregate several data sources, notably through a GraphQL layer, often benefit more from non-blocking than isolated CRUD services, since they multiply concurrent downstream calls. This directly connects to the trade-offs between REST and GraphQL when designing modern APIs.

@cite:api-design-rest-vs-graphql-et-au-dela

Finally, a reactive system in production needs to be monitored differently: latency by percentile, backpressure rejection rate and connection pool health become front-line indicators, alongside the classic pillars of distributed systems observability.

@cite:observabilite-et-resilience-systemes-distribues

SECTION 8

Key takeaways with Adservio

These platforms simplify setting up a reactive architecture, but they remain developer-intensive solutions: they require customisation through code rather than a drag-and-drop deployment. The real judgement lies in deciding when reactive programming brings a genuine gain, particularly with respect to the target concurrency level and the team's maturity with these patterns.

At Adservio, we help organisations assess the relevance of a reactive architecture and integrate it where it creates value, drawing on the current best practices of the R2DBC ecosystem and avoiding the costly pitfalls and anti-patterns that turn a performance promise into technical debt.

FAQ

Frequently asked questions

What is R2DBC?

R2DBC (Reactive Relational Database Connectivity) is a specification that makes it possible to integrate SQL databases via native reactive drivers. It aims for a minimal SPI surface while remaining fully reactive and backpressure-aware on the database layer. Spring Data R2DBC, now part of Spring Data Relational, is its reference implementation on the JVM, with mature drivers for PostgreSQL, MySQL, SQL Server and Oracle.

When is reactive programming genuinely useful?

Mainly for high-concurrency applications, where it reduces CPU and memory consumption per request and speeds up response times, with typical gains of 20 to 40% more requests handled at equal resources. Low-concurrency workloads see only limited gains, while the cost of code, testing and debugging complexity remains very real.

Which platforms let you implement a reactive architecture?

Hasura GraphQL, with its asynchronous tooling and native eventing system; PostGraphile Realtime, with its subscriptions and live queries extensible through plugins; and MongoDB Atlas, which provides a GraphQL API and a Reactive Streams driver compatible with R2DBC's backpressure standards.

ABOUT ADSERVIO

Adservio is an AI-native digital transformation partner: AI-augmented IT departments, software engineering, DevOps, MLOps, cybersecurity and AI governance.

Let's talk about your project: hello@adservio.fr · adservio.fr/contact