Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quarkus: Why compile to native?

 

March 29, 2019
Mark Little
Related topics:
KubernetesQuarkus
Related products:
Red Hat build of Quarkus

Share:

    Quarkus is Kubernetes native, and to accomplish that we’ve spent a lot of time working across a number of different areas, such as the Java Virtual Machine (JVM) and various framework optimizations. And, there’s much more work still to be done. One area that has piqued the interest of the developer community is Quarkus’s comprehensive and seamless approach to generating an operating system specific (aka native) executable from your Java code, as you do with languages like C and C++, which we believe will typically be used at the end of the build-test-deploy cycle.

    Although the native compilation is important, as we’ll discuss later, Quarkus works really well with vanilla OpenJDK Hotspot, thanks to the significant performance improvements we’ve made to the entire stack. The native executable aspect Quarkus offers is optional and, if you don’t want it or your applications don’t need it, then you can ignore it. In fact, even when you are using native images, Quarkus still relies heavily on OpenJDK. The well-received dev mode is able to deliver near-instantaneous change-test cycles all due to Hotspot’s rich dynamic code execution capabilities. Additionally, GraalVM internally uses OpenJDK’s class library and HotSpot to produce a native image.

    Still, there's the question: Why have native compilation at all if the other optimizations are so good? That's the question we'll look at more closely here.

    Let’s start with the obvious: JBoss and Red Hat have a long track record of knowing how to optimize the JVM, stacks, and frameworks including:

    • The first app server to run in the cloud on Red Hat OpenShift
    • The first app server to run on a plug computer.
    • The first app server to run on a Raspberry Pi.
    • Running many of our projects on Android.

    As this shows, we have been working on running Java in the cloud and on constrained devices (aka Internet of Things) for many years, always looking at how we could squeeze the next performance or memory optimization out of the JVM. We and others have long looked at the potential for compiled Java, whether through GCJ, Avian, Excelsior JET, or even Dalvik because we understood the trade-offs (e.g., lack of build-once-run-anywhere versus lower on-disk footprint or quicker startup time).

    Why are these trade-offs important? The answer is that, for some important scenarios, it makes complete sense:

    • Consider serverless/event-driven environments where we need to spin up a service in real time (soft or hard) to react to an event. Unlike a persistent service, cold start cost lengthens the response time to a request. Today the JVM still takes “a while” to start and although throwing hardware at the problem can help, in some situations, the difference between 1 second and 5 ms could be life or death. Yes, we can play tricks such as hot standby JVMs (we’ve been there with our Knative port of OpenWhisk, for example), but that doesn’t guarantee you’ll have enough JVMs waiting to field requests as they scale up, nor does it sound like a good way to save money when you’d be paying for processes that aren’t being used all the time.
    • Then there’s the multi-tenancy aspect we often hear about. Although the JVM has grown to duplicate many operating system capabilities, it still doesn’t have the kind of process isolation we take for granted in operating systems such as Linux, and the failure of a thread can take down the entire JVM. Many people get around this by only running a single user’s applications in a single JVM. That’s a legitimate thing to do: the unit of failure is, therefore, the JVM and failures for one user don’t necessarily impact any other users. However, running a JVM per user often presents problems at scale.
    • Density also matters to cloud-native applications. Embracing 12-factor app, microservices, and Kubernetes leads to many JVMs per app. While you gain elasticity and robustness, the cost of base memory footprint per service starts to add up, even though a portion of that cost isn’t strictly necessary. Statically compiled executables have the ability to benefit from closed-world optimizations, such as fine-grained dead-code elimination, where only the portions of frameworks (including the JDK itself) actually in use by the service are included in the resulting image. By tailoring the application to be native-friendly, Quarkus can be used to densely pack many service instances on a host, without compromising security.

    For these reasons alone, a native executable option presents a valid solution for us and others in our communities. There’s another less technical reason, which is no less important: Over the past few years, many Java developers and companies have abandoned it in favor of newer languages, often because they believe that the JVM, the stacks, and the frameworks are bloated, slow, etc.

    Trying to force-fit an existing hammer to a new nail isn’t always the best approach, and sometimes it’s best to take a step back and consider a new tool. If Quarkus makes people pause and rethink, then it's a good thing for the entire Java ecosystem. Quarkus takes an innovative view of how to deliver more efficient applications, making Java relevant to application architectures previously thought taboo (like serverless). Additionally, through its extension capability, we hope to see a Quarkus Java extension ecosystem that offers a large set of frameworks that can be natively compiled along with your application out of the box.

    Last updated: February 11, 2024

    Recent Posts

    • Introducing Red Hat build of Cryostat 4.0

    • How we improved AI inference on macOS Podman containers

    • How OpenShift Virtualization supports VM live migration

    • How SELinux deny rules improve system security

    • Advanced time manipulation with GDB

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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

    Red Hat legal and privacy links

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

    Report a website issue