Skip to content

Component

Bidding Engine

Reactive auction execution service responsible for bid intake, final state changes, stream publication, and live client updates.


Purpose

The Bidding Engine is the primary execution path for incoming bids. It accepts HTTP requests, delegates state updates to Redis, and streams the resulting changes back to connected clients. The service is built on Spring WebFlux so network I/O remains non-blocking during traffic spikes.

Responsibilities

  • Accept bid requests from clients
  • Execute atomic auction updates through Redis
  • Publish bid events to Redis Streams for downstream consumers
  • Push live price and log updates through Server-Sent Events
  • React to asynchronous fraud decisions without stalling the request path

Bid Execution Flow

sequenceDiagram
    participant C as Client
    participant E as Bidding Engine
    participant R as Redis
    participant X as Redis Stream
    participant S as Sentinel

    C->>E: POST /bid
    E->>R: Execute atomic auction script
    R-->>E: Updated price and version
    E->>X: Append bid event
    E-->>C: Server-Sent Events update
    S->>X: Consume bid batches

Each bid follows one write path. Redis performs the committed state transition. The Java service owns request handling, validation, event publication, and delivery to the client.

Design Notes

Reactive Request Handling

The service runs on Spring WebFlux and uses a small set of non-blocking event loop threads. That keeps request handling predictable even when many clients are connected at once.

Atomic Auction Updates

Auction state is updated inside Redis rather than across multiple application-side reads and writes. This removes timing windows around simultaneous bids and keeps the current price, version, and auction outcome consistent.

Event Publication

After a successful update, the engine writes a bid event to a Redis Stream. That keeps downstream processing loosely coupled and allows fraud analysis to run independently of the request-response cycle.

Live Delivery

Committed state changes are pushed to the browser through Server-Sent Events. This provides a simple one-way channel for prices, logs, and auction status changes.

Built-In Load Generation

The engine includes a reactive demo bot service for demonstration purposes.

Runtime Stack

Layer Technology
Language Java 25
Framework Spring Boot 4 / WebFlux
State Store Redis
Event Backbone Redis Streams
Streaming Server-Sent Events
Testing JUnit 5 / Testcontainers

Quick Start

docker compose up -d
./mvnw spring-boot:run

Local Development

Start Redis

docker run -d -p 6379:6379 --name bidstream-redis redis:7.2-alpine

Run the service

./mvnw spring-boot:run

API Documentation

When the service is running locally, the OpenAPI documentation is available at:

http://localhost:8080/swagger-ui.html

Created by Justin Walker