Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Boost throughput with RESTEasy Reactive in Quarkus 2.2

November 4, 2021
Daniel Oh
Related topics:
JavaMicroservicesQuarkus
Related products:
Red Hat OpenShift

    Quarkus has, from its beginning, provided core features for coding Java programs in both imperative and reactive style. With the new 2.2 release, Quarkus continues to improve in terms of network-related features, reactive programming, and integration with the Eclipse Vert.x event bus. For example, RESTEasy Reactive in Quarkus is a new JAX-RS implementation based on the Vert.x layer that achieves much higher throughput by handling reactive events on the non-blocking I/O thread.

    The Red Hat build of Quarkus 2.2 provides production support for the RestEasy Reactive extensions, with additional features:

    • Multipart/form-data request handling
    • Executing a non-blocking method by default
    • Determining the dispatch strategy by method signatures
    • Providing a performance score dashboard for reactive endpoints

    These new features deliver improved performance improvements when developing reactive applications.

    This article demonstrates how you can improve the performance of a Quarkus reactive application by using RESTEasy Reactive features and the Quarkus Dev UI. Download the repository from GitHub to follow along with this tutorial.

    Check REST reactive endpoints in the Quarkus Dev UI

    First things first: Run Quarkus Dev Mode using the following Maven command in your project directory where you cloned the example:

    $ ./mvnw quarkus:dev

    Press d after the example application starts and displays the following messages:

    --
    Tests paused
    Press [r] to resume testing, [o] Toggle test output, [h] for more options>

    A new web browser will open to access the Quarkus Dev UI, shown in Figure 1. In the RESTEasy Reactive box, click Endpoint scores.

    In the Quarkus Dev UI, the RESTEasy Reactive tile offers an "Endpoint scores" link.
    Figure 1. In the Quarkus Dev UI, the RESTEasy Reactive tile offers an "Endpoint scores" link.

    You will then be taken to the Quarkus REST scores console, which shows the behavior of four REST reactive endpoints with scores and colors (see Figure 2).

    The REST scores console shows the performance of endpoints through scores and colors.
    Figure 2. The REST scores console shows the performance of endpoints through scores and colors.

    Note that two endpoints have a score of 100 with the color green, but the /hello() endpoint has a score of only 33 in red and the /hello/stream/{count}/{name} endpoint has a score of 66 in yellow. Before we investigate why two endpoints are not performing well, let's do a local test to see whether they work properly.

    Execute the following curl commands to invoke the two REST reactive endpoints. For the /hello endpoint, enter:

    $ ​​curl localhost:8080/hello
    hello 

    For the /hello/stream/{count}/{name} endpoint, enter:

    $ curl localhost:8080/hello/stream/3/daniel 
    data:hello daniel - 0 
    data:hello daniel - 1 
    data:hello daniel - 2

    These commands should complete without errors. Go back to the scores dashboard in the Quarkus Dev UI and click GET /hello. The detail scores will appear as shown in Figure 3.

    The detailed view of an endpoint breaks scores down into Resource, Writer, and Execution.
    Figure 3. The detailed view of an endpoint breaks scores down into Resource, Writer, and Execution.

    Three measurements show whether a REST reactive application can be optimized further. For example, the hello endpoint is optimized only for resource measurement. This means the endpoint is accessible and returns a successful output, which you already tested locally. In contrast, the Writer and Execution measurements show failures with 0% scores.

    Tune the slow endpoints to optimize performance

    Open the ReactiveGreetingResource.java file in the src/main/java/org/acme/getting/started directory and take a look at the hello() method:

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public Object hello() {
    return "hello";
    }

    The return type of the method is currently defined with a type of Object. It needs to be specified as a String to avoid unnecessary object conversion during reactive application execution. Therefore, update the return type as shown in the following snippet (the change is highlighted in bold):

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
    return "hello";
    }

    Save the ReactiveGreetingResource.java file, then reload the scoreboard page in the Dev UI. You should find that the performance has improved, because the Writer measurement has been fixed and the score has increased to 66 as shown in Figure 4.

    The Writer score is now 100%.
    Figure 4. The Writer score is now 100%.

    Non-blocking I/O

    Let's fix the remaining performance issue in the hello() method, shown by the Execution measurement. RESTEasy Reactive, in the Red Hat build of Quarkus 2.2, automatically determines whether a particular method runs on a non-blocking I/O thread asynchronously or on a worker thread synchronously, based on the method's signature. The hello() method returns a String signature that dispatches a blocking worker thread. The blocking thread reduces reactive processing performance compared to the non-blocking I/O thread.

    Therefore, you need to override the default dispatch strategy to make it use a non-blocking I/O thread, using the @NonBlocking annotation. Go back to the ReactiveGreetingResource.java file and add a @NonBlocking annotation as follows:

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @NonBlocking
    public String hello() {
    return "hello";
    }

    Save the ReactiveGreetingResource.java file, then reload the scoreboard page in the Dev UI. You should now have 100 scores everywhere, thanks to optimizing the hello() method's performance (Figure 5).

    All three scores are now 100%.
    Figure 5. All three scores are now 100%.

    Now let's fix the other endpoint, /hello/stream/{count}/{name}. Move to the greetingsAsStream() method in the ReactiveGreetingResource.java file:

    @GET
    @Produces(MediaType.SERVER_SENT_EVENTS)
    @RestSseElementType(MediaType.TEXT_PLAIN)
    @Path("/stream/{count}/{name}")
    @Blocking
    public Multi<String> greetingsAsStream(int count, String name) {
    return service.greetings(count, name);
    }

    The method signature is already specified with Multi to dispatch a non-blocking I/O thread. However, an unnecessary @Blocking annotation appears in the method, overriding the default dispatch strategy. Therefore, you need to remove that annotation or comment it out. Update the greetingsAsStream method as shown in the following example:

    @GET
    @Produces(MediaType.SERVER_SENT_EVENTS)
    @RestSseElementType(MediaType.TEXT_PLAIN)
    @Path("/stream/{count}/{name}")
    // @Blocking
    public Multi<String> greetingsAsStream(int count, String name) {
    return service.greetings(count, name);
    }
    

    Save the file and reload the scores page in the Dev UI. You should now have 100% scores everywhere because the greetingsAsStream() method has been optimized, as shown in Figure 6.

    The second endpoint now has three 100% scores.
    Figure 6. The second endpoint now has three 100% scores.

    Figure 7 shows that you have optimized the performance of all endpoints.

    The REST scores console shows 100% scores for all endpoints.
    Figure 7. The REST scores console shows 100% scores for all endpoints.

    How to get started with Quarkus

    This article has shown how developers optimize reactive applications with Quarkus in the inner-loop development phase. Release 2.2 also provides awesome features to improve developers' productivity, including continuous testing, improvements in the Quarkus command-line interface (CLI) and the Dev UI, and Dev Services.

    To learn more, check out the following resources:

    • Read the article Red Hat build of Quarkus 2.2: Simplified Kubernetes-native Java.
    • Get started with Red Hat build of Quarkus.
    • Download our free guide Quarkus for Spring Developers.
    Last updated: October 6, 2022

    Related Posts

    • Red Hat build of Quarkus 2.2: Simplified Kubernetes-native Java

    • RESTEasy Reactive and more in Quarkus 2.0

    • Quarkus for Spring developers: Getting started

    Recent Posts

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.