How dev mode differs from a production application
This document explains how the dev mode in Quarkus differs from a production application.
Diferencias arquitectónicas
Feature sets aside, the Quarkus application that is run under dev mode differs architecturally from the production application (i.e. the one that is run using java -jar …
).
In dev mode, Quarkus uses a ClassLoader hierarchy (explained in detail here) that enables the live reload of user code without requiring a rebuild and restart of the application.
En una aplicación de producción, la mencionada infraestructura de carga de clases está totalmente ausente - hay un único ClassLoader construido a propósito que carga (casi) todas las clases y dependencias.
Características del modo de desarrollo
In keeping with the mantra of providing developer joy, Quarkus provides a host of features when dev mode is enabled. The most important features are:
Recarga en vivo
This mightily important feature needs no introduction and has already been mentioned in the architectural differences section.
Interfaz de usuario
Quarkus provides a very useful UI accessible from the browser at /q/dev-ui
. This UI allows a developer to see the state of the application, but
also provides access to various actions that can change that state (depending on the extensions that are present).
Examples of such operations are:
-
Modificación de los valores de configuración
-
Ejecución de scripts de migración de bases de datos
-
Borrado de cachés
-
Ejecución de operaciones programadas
-
Construir un contenedor
A new Dev UI has been implemented in Quarkus 3.x. Not all the features are available yet. You can still access the previous version of the Dev UI using: http://localhost:8080/q/dev-ui/. |
Páginas de error
In an effort to make development errors very easy to diagnose, Quarkus provides various detailed error pages when running in dev mode.
Scripts de importación de bases de datos
The quarkus-hibernate-orm
extension will run the import.sql
script in src/main/resources
when Quarkus is running in dev mode. More details can be found here.
Servicios de desarrollo
When testing or running in dev mode Quarkus can even provide you with a zero config database out of the box, a feature we refer to as Dev Services. More information can be found here.
Interfaz de usuario de Swagger
The quarkus-smallrye-openapi
extension will expose the Swagger UI when Quarkus is running in dev mode. Additional information can be found here.
GraphQL UI
The quarkus-smallrye-graphql
extension will expose the GraphQL UI when Quarkus is running in dev mode. More details can be found here.
IU de la Salud
The quarkus-smallrye-health
extension will expose the Health UI when Quarkus is running in dev mode. This section provides additional information.
Simulacro de envío de correo
The quarkus-mailer
extension will enable an in-memory mock mail server when Quarkus is running in dev mode. See this for more details.
gRPC
-
El servicio gRPC Reflection está activado por defecto en el modo dev. Esto le permite utilizar herramientas como
grpcurl
. En el modo de producción, el servicio de reflexión está desactivado. Puedes habilitarlo explícitamente usandoquarkus.grpc-server.enable-reflection-service=true
. -
In dev mode,
quarkus.grpc.server.instances
has no effect.
Implicaciones del rendimiento
In dev mode, minimizing the runtime footprint of the application is not the primary objective (although Quarkus still starts plenty fast and consumes little memory) - the primary objective is enabling developer joy. Therefore, many more classes are loaded and build time operations also take place every time a live-reload is performed.
In contrast, in a production application the main objective for Quarkus is to consume the least amount of memory and startup in the smallest amount of time. Thus, when running the production application, build time operations are not performed (by definition) and various infrastructure classes needed at build time are not present at all at runtime. Furthermore, the purpose built ClassLoader that comes with the fast-jar package type ensures that class lookup is done as fast as possible while also keeping the minimum amount of jars in memory.
Since optimal performance is never an objective of dev mode, in the interest of improving startup time, the JVM’s C2 compiler is disabled in dev mode. |
Implicaciones de seguridad
Perhaps the most important reason why dev mode applications should not be run in production is that the dev mode allows reading information that could be confidential (via the Dev-UI) while also giving access to operations that could be destructive (either by exposing endpoints that should not be available in production application or via the Dev-UI).
Ejecución nativa
Cuando se crea un ejecutable nativo (explicado en detalle aquí), siempre se construye a partir de una aplicación de producción.