Skip to content

This project demonstrates Java 21 Virtual Threads with Quarkus to achieve better performance in I/O-intensive applications.

Notifications You must be signed in to change notification settings

anmiralles/quarkus-virtualthreads-example

Repository files navigation

Quarkus Virtual Threads Example

This project demonstrates Java 21 Virtual Threads with Quarkus to achieve better performance in I/O-intensive applications.

About Virtual Threads & Quarkus

Virtual Threads (Project Loom) are lightweight threads that dramatically reduce the cost of blocking operations. Unlike traditional platform threads, virtual threads are managed by the JVM and can scale to millions of instances with minimal overhead.

Quarkus makes virtual threads simple to use with the @RunOnVirtualThread annotation, automatically executing your REST endpoints on virtual threads for improved throughput in blocking scenarios.

This example shows a REST API managing application entities with PostgreSQL database operations, demonstrating how virtual threads improve performance under load.

For detailed information about Virtual Threads in Quarkus, see the official guide.

Quick Start

1. Package and Build Container Image

First, package the application and build the container image:

# Package the application
./mvnw package

# Build the container image
podman build -f src/main/docker/Dockerfile.jvm -t quay.io/rh-ee-amiralle/quarkus-applications:1.0 .

2. Start Complete Stack

Start all services including the application container:

cd deployment
podman-compose up -d

This will start:

  • PostgreSQL database
  • Quarkus application container
  • Prometheus (metrics)
  • Grafana (dashboards)
  • Jaeger (tracing)

3. Monitor Performance

Performance Results

Load testing with JMeter demonstrates the benefits of virtual threads. The following captures show system performance under load:

Metric Image
HTTP Endpoints HTTP Endpoints
CPU Usage CPU Usage
JVM Memory JVM Memory
Thread Usage Threads
JMeter Report JMeter Report

Virtual threads enable handling more concurrent requests with lower resource consumption compared to traditional platform threads.

Related Guides

  • Virtual Threads: Complete guide to using Virtual Threads in Quarkus applications

About

This project demonstrates Java 21 Virtual Threads with Quarkus to achieve better performance in I/O-intensive applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published