Introduction
Eclipse Vert.x is a polyglot, event-driven application toolkit for the JVM. It uses an event loop model similar to Node.js but leverages JVM performance and multi-core scalability. Vert.x is not a framework — it is a toolkit that gives developers building blocks for reactive network applications.
What Vert.x Does
- Provides non-blocking APIs for HTTP, TCP, UDP, WebSocket, gRPC, and DNS
- Runs event loops on multiple CPU cores for scalable concurrency without thread-per-request
- Supports polyglot development in Java, Kotlin, Groovy, JavaScript, and Ruby
- Includes a distributed event bus for communication between verticles and cluster nodes
- Offers reactive clients for PostgreSQL, MySQL, Redis, MongoDB, Kafka, and AMQP
Architecture Overview
Vert.x runs one event loop per CPU core by default. Application logic is deployed as verticles — lightweight units of deployment that process events sequentially on their assigned event loop. The event bus provides asynchronous messaging between verticles, both locally and across a cluster using Hazelcast, Infinispan, or Apache Ignite. Netty serves as the underlying network I/O layer.
Self-Hosting & Configuration
- Add via Maven: io.vertx:vertx-core:4.x or use vertx-stack-depchain for BOM management
- Deploy verticles programmatically or via the vertx command-line launcher
- Configure event loop pool size, worker pool size, and cluster settings in VertxOptions
- Enable clustering with vertx-hazelcast or vertx-infinispan for distributed event bus
- Use vertx-config to load configuration from files, environment variables, Consul, or Vault
Key Features
- Event-loop concurrency model handles thousands of connections per thread without callbacks nesting
- Distributed event bus enables microservice communication without external message brokers
- Reactive SQL clients for PostgreSQL and MySQL with connection pooling and prepared statements
- Built-in support for HTTP/2, server-sent events, and WebSocket at the framework level
- Lightweight core (~650 KB) with modular dependencies added as needed
Comparison with Similar Tools
- Spring WebFlux — reactive stack in Spring; larger ecosystem but heavier and less control over the event loop
- Netty — lower-level networking library; Vert.x uses Netty internally and adds application-level abstractions
- Quarkus — can use Vert.x internally; Quarkus is a higher-level framework with build-time optimization
- Node.js — similar event-driven model; Vert.x benefits from JVM performance, typing, and multi-core event loops
FAQ
Q: Is Vert.x a framework or a library? A: Vert.x is a toolkit. It provides building blocks without imposing application structure, so you can use as much or as little as needed.
Q: Can Vert.x use multiple CPU cores? A: Yes. Vert.x runs one event loop per core by default, unlike Node.js which uses a single event loop.
Q: Does Vert.x work with GraalVM native image? A: Yes. Vert.x applications can be compiled to native executables, and Quarkus uses Vert.x internally for its reactive layer.
Q: How do I handle blocking operations? A: Use executeBlocking() to offload blocking code to a worker thread pool, keeping the event loop free.