What Quarkus is and why

Junior Always asked 7 min

On this page

The question

What is Quarkus, and why was it created?

30-second answer

Quarkus is a Java framework built for containers and Kubernetes. It moves framework work, such as scanning annotations, wiring beans and generating proxies, from startup to the build. Apps start faster and use less memory, in JVM (Java Virtual Machine) mode and even more as a GraalVM native image. It builds on standards, such as CDI, Jakarta REST and MicroProfile, and adds a fast dev mode.

Understand it

Where the framework work happens

Compare

Spring Boot compiles at build, then does the framework work at every start: scanning, reading annotations, evaluating conditions, creating proxies and wiring beans.

View as text

Two lanes of steps for a small REST service in JVM mode. The top lane is the build, done once. The bottom lane is the startup, done every time the app starts. A mark below says what each start does.

Spring Boot: Spring Boot compiles at build, then does the framework work at every start: scanning, reading annotations, evaluating conditions, creating proxies and wiring beans. Build: 2 steps. Startup: 6 steps.

Quarkus: Quarkus does that work once, at build. Extensions index the classes, resolve injection and generate proxies as bytecode, so a start only replays recorded steps and opens the server. Build: 7 steps. Startup: 2 steps.

Two lanes of steps for a small REST service in JVM mode. The top lane is the build, done once. The bottom lane is the startup, done every time the app starts. A mark below says what each start does.

Spring Boot: Spring Boot compiles at build, then does the framework work at every start: scanning, reading annotations, evaluating conditions, creating proxies and wiring beans. Build: 2 steps. Startup: 6 steps.

Quarkus: Quarkus does that work once, at build. Extensions index the classes, resolve injection and generate proxies as bytecode, so a start only replays recorded steps and opens the server. Build: 7 steps. Startup: 2 steps.

Takeaway: Both frameworks do the same work. Spring Boot does it at every start; Quarkus does most of it once, at build, so a start only replays the result.

Work moved from startup to build

Step by step

A traditional framework does all eight steps at every start. The classes have not changed since the build, so each start recomputes the same answer.

Step 1 of 7
View as text

Two columns: the build, done once, on the left, and the startup, done every time, on the right. Eight steps start in the startup column, and each state moves one or two of them to the build.

A traditional framework does all eight steps at every start. The classes have not changed since the build, so each start recomputes the same answer.

At build, Jandex indexes every class once. Extensions query the index for annotations such as @Path or @Entity instead of scanning at startup.

Settings that shape the app, such as the database kind, are read at build and fixed. Changing them later means rebuilding.

ArC matches every injection point to a bean at build. A missing or ambiguous bean fails the build, not the first request.

Proxies and bean factories become generated classes. Startup creates them with no reflection, which a native image also needs.

Hibernate builds its entity model, and REST builds its routes, during the build. Recorders save the results as bytecode to replay.

Only work that needs the real environment stays: opening connections and the HTTP port. That is why startup is short, in JVM mode too. The startup column ends with two steps, and the build column with six.

Two columns: the build, done once, on the left, and the startup, done every time, on the right. Eight steps start in the startup column, and each state moves one or two of them to the build.

A traditional framework does all eight steps at every start. The classes have not changed since the build, so each start recomputes the same answer.

At build, Jandex indexes every class once. Extensions query the index for annotations such as @Path or @Entity instead of scanning at startup.

Settings that shape the app, such as the database kind, are read at build and fixed. Changing them later means rebuilding.

ArC matches every injection point to a bean at build. A missing or ambiguous bean fails the build, not the first request.

Proxies and bean factories become generated classes. Startup creates them with no reflection, which a native image also needs.

Hibernate builds its entity model, and REST builds its routes, during the build. Recorders save the results as bytecode to replay.

Only work that needs the real environment stays: opening connections and the HTTP port. That is why startup is short, in JVM mode too. The startup column ends with two steps, and the build column with six.

Takeaway: Quarkus moves every step whose answer cannot change after the build into the build. Startup keeps only what needs the real environment: connections and ports.

Where Quarkus does the workYour classes and configuration go into the build, where augmentation runs the build steps of every extension. It produces generated bytecode and recorded steps, and each start only replays them and opens connections.Your classes andconfigurationBuild: augmentationruns every extensionGenerated bytecodeand recorded stepsEach start replaysthe steps andopens connections
Where Quarkus does the workYour classes and configuration go into the build, where augmentation runs the build steps of every extension. It produces generated bytecode and recorded steps, and each start only replays them and opens connections.Your classes andconfigurationBuild: augmentationruns every extensionGenerated bytecodeand recorded stepsEach start replaysthe steps andopens connections
Where Quarkus does the work

In code

@Path("/orders")
public class OrderResource {

    @Inject
    OrderService orders; // package-private: injected with no reflection

    @GET
    @Path("/{id}")
    public Order get(@RestPath Long id) {
        return orders.find(id);
    }
}

@ApplicationScoped
public class OrderService {

    Order find(Long id) {
        return new Order(id, "OPEN");
    }
}
A REST (Representational State Transfer) resource and the bean it injects
# Fixed at build: chooses the driver and Hibernate setup
quarkus.datasource.db-kind=postgresql

# Runtime: can change in each environment without a rebuild
quarkus.datasource.jdbc.url=jdbc:postgresql://db:5432/orders
%dev.quarkus.log.level=DEBUG
Fixed at build, or set per environment
./mvnw package
java -jar target/quarkus-app/quarkus-run.jar
Build once, then run in JVM mode
What the build writes to target/quarkus-appThe fast-jar folder holds quarkus-run.jar, the launcher, an app folder with your classes, a lib folder with dependencies, and a quarkus folder with the bytecode generated at build.target/quarkus-app/quarkus-run.jar:the launcherapp/: your classeslib/: dependenciesquarkus/: bytecodegenerated at build
What the build writes to target/quarkus-appThe fast-jar folder holds quarkus-run.jar, the launcher, an app folder with your classes, a lib folder with dependencies, and a quarkus folder with the bytecode generated at build.target/quarkus-app/quarkus-run.jar:the launcherapp/: your classeslib/: dependenciesquarkus/: bytecodegenerated at build
What the build writes to target/quarkus-app

Solve it

Choose a framework for a scale-to-zero function

A team runs a pricing function on Knative that scales to zero at night. The first request after idle waits for a cold start, and the bill depends on memory per instance. The current Spring Boot jar starts in about 4 seconds. Should the team move to Quarkus?

  1. Name what matters. Cold-start time and memory per instance, because instances start often and are billed by size. Peak throughput matters less.
  2. Explain where Quarkus saves. It does annotation scanning, configuration parsing and dependency wiring at build time, so less work is left for startup.
  3. Add native as an option. A native executable starts in tens of milliseconds and uses less memory, at the cost of longer builds and reflection configuration.
  4. Weigh the alternatives. Spring Boot also has AOT processing and native images. Team knowledge and the libraries used may matter more than framework choice.
  5. Measure, do not guess. Build both, start each in the same container image and limits, and compare time to first response and resident memory.
java -jar target/quarkus-app/quarkus-run.jar       # the log ends with "started in ...s"
./target/pricing-1.0.0-runner                      # the native executable: compare the same log line
ps -o rss= -p "$(pgrep -f pricing)"                # resident memory in KB, after the first request
Measure startup and memory the same way for every build

How to answer

  • Build-time processing means extensions do their framework work during the build and record the result as bytecode.
  • Startup time and memory matter when containers scale out, restart often or scale to zero.
  • Two outputs come from one code base, a fast-jar for the JVM or a native executable.
  • It uses standard APIs, such as CDI (Contexts and Dependency Injection) through ArC, Jakarta REST, and JPA (Jakarta Persistence API) through Hibernate ORM (object-relational mapping).

Common mistakes

  • Saying Quarkus only matters for native images. Build-time processing speeds up JVM mode too.
  • Calling it a fork of Spring Boot. It is a separate framework on standard APIs.

Follow-up questions

What is the difference between build-time and runtime processing?

Runtime processing, as in a classic Spring Boot app, reads annotations, evaluates conditions and creates proxies with reflection at every start. Quarkus extensions do this during the build: they read a Jandex index, resolve injection, generate bytecode and record initialization steps. At run time, the app only replays those steps and opens connections, so it starts faster and keeps less metadata in memory.

  • Augmentation is the build phase that runs the build steps of every extension.
  • Recorders turn initialization code into bytecode that runs when the app starts.
  • Classes used only to analyze the app are never loaded at run time.
  • A missing or ambiguous bean fails the build, not the first request.

See it in the infographic: Work moved from startup to build

How does Quarkus compare with Spring Boot?

Both are full Java stacks for REST, data and messaging. Spring Boot configures the app at startup and has the larger ecosystem and community. Quarkus does that work at build, so it starts faster and uses less memory, with native images and a fast dev mode built in. Quarkus uses standard APIs, such as CDI and Jakarta REST, and offers Spring compatibility extensions.

  • Spring Boot 3 also builds native images, through Spring AOT and GraalVM.
  • For long-running services on the JVM, throughput is close; the clear gaps are startup and memory.
  • Team skills and the libraries you need matter as much as startup numbers.

See it in the infographic: Where the framework work happens

What is a Quarkus extension, and why not just add any library?

An extension is a library plus a deployment module that runs at build. The deployment part tells Quarkus what the library needs: which classes to index, which beans to register, what a native image must keep for reflection, and what to initialize ahead of time. A plain library still works in JVM mode, but its scanning and reflection run at startup, and it may break in a native image.

  • Each extension has a runtime module and a deployment module.
  • Add one with quarkus ext add, or as a Maven or Gradle dependency.
  • Extensions also provide Dev Services and the panels of the Dev UI.

See it in the infographic: Work moved from startup to build

You set quarkus.datasource.db-kind to another database at run time, and the app ignores it. Why?

Some properties are fixed at build, because extensions use them during augmentation. The database kind chooses the JDBC (Java Database Connectivity) driver and how Hibernate is set up, and both were decided and recorded when the app was built. Changing it at run time has no effect, and Quarkus logs a warning that a build-time property differs. Rebuild with the new value; keep the URL and credentials as runtime settings.

  • The configuration reference marks build-time properties with a lock icon.
  • Runtime properties, such as the JDBC URL and credentials, can change per environment.
  • Profiles such as %dev. and %prod. choose values per environment.

See it in the infographic: Work moved from startup to build

Your team runs 40 small services on Kubernetes, and many scale to zero at night. Why might Quarkus fit?

Each instance starts in a fraction of the time and uses less memory, so cold starts are short and more pods fit on each node. Scaling to zero only works if the first request does not wait long, which a native image makes practical. Keep the JVM where peak throughput matters more, and weigh how much Spring experience the team already has.

  • Memory per pod sets how many pods fit on a node, and so the cost.
  • Fast startup helps scaling out, rolling deployments and scaling to zero.
  • Native builds take minutes, so most teams build native images only in CI (continuous integration).

See it in the infographic: Where the framework work happens

Does Quarkus still run on a normal JVM?

Yes, and that is the default. mvn package builds a fast-jar under target/quarkus-app, which you run with java -jar quarkus-run.jar. A native executable is an extra build. JVM mode keeps the JIT (just-in-time) compiler, so it often reaches higher peak throughput, and it builds in seconds rather than minutes.

Check yourself

1. In Quarkus, when are injection points matched to beans?
Show answers
  • At build time, during augmentation: Correct. ArC resolves injection during the build, so a missing bean fails the build.
  • At startup, by scanning the classpath: Incorrect. That is what a runtime framework does. Quarkus reads an index during the build instead.
  • On the first request: Incorrect. Creating the instance can be lazy, but the matching was settled at build.
2. Does build-time processing help an app that runs in JVM mode, not as a native image?
Show answers
  • Yes. Startup does less work and loads fewer classes.: Correct. The work done during the build is skipped at every start, on the JVM too.
  • No. Only native images benefit.: Incorrect. Native images gain the most, but the work moved to the build is skipped in JVM mode too.
  • It makes JVM startup slower.: Incorrect. The build takes longer, not the startup. Startup replays results that are already computed.
3. In production, an environment variable changes a property that is fixed at build time. What happens?
Show answers
  • The built value stays, and Quarkus logs a warning.: Correct. The value was used during the build and recorded. Only a rebuild changes it.
  • The new value applies at the next restart.: Incorrect. That is true for runtime properties, not for those fixed at build.
  • Quarkus rebuilds the app at startup.: Incorrect. A packaged app does not rebuild itself. Only dev mode rebuilds on change.