Eclipse Vert.x and reactive in just a few words
Eclipse Vert.x is a tool-kit for building reactive applications on the JVM. Reactive applications are both scalable as workloads grow, and resilient when failures arise. A reactive application is responsive as it keeps latency under control by making efficient usage of system resources, and by protecting itself from errors.
Vert.x is backed by a large ecosystem of reactive modules with just anything you need when writing modern services: a comprehensive web stack, reactive database drivers, messaging, event streams, clustering, metrics, distributed tracing and more.
Vert.x is a tool-kit and not a framework that ships with black magic: what you write is actually what you get to execute, as simple as that.
So what makes Vert.x a great option for writing your next cloud-native or twelve-factor app?
In the beginning, there were threads…
The classic approach to concurrency is to use threads. Multiple threads can live within a single process, perform concurrent work, and share the same memory space.
Most application and service development frameworks are based on multi-threading. On the surface, the model of having 1 thread per connection is reassuring because developers can rely on traditional imperative style code.
This is fine, especially if you forget about those silly mistakes you can make with multi-threading and memory access …
Multi-threading is “simple” but limited
What happens as the workload grows beyond moderate workloads? (see the C10k problem)
The answer is simple: you start making your operating system kernel suffer because there is too much context switching work with in-flight requests.
Some of your threads will be blocked because they are waiting on I/O operations to complete, some will be ready to handle I/O results, and some will be in the middle of doing CPU-intensive tasks.
Modern kernels have very good schedulers, but you cannot expect them to deal with 50 000 threads as easily as they would do with 5 000. Also, threads aren’t cheap: creating a thread takes a few milliseconds, and a new thread eats about 1MB of memory.
Asynchronous programming: scalability and resource efficiency
Processing more concurrent connections with less threads is possible when you use asynchronous I/O. Instead of blocking a thread when an I/O operation occurs, we move on to another task which is ready to progress, and resume the initial task later when it is ready.
Vert.x multiplexes concurrent workloads using event loops.
Code that runs on event loops should not perform blocking I/O or lengthy processing. But don’t worry if you have such code: Vert.x has worker threads and APIs to process events back on an event loop.
Pick the best asynchronous programming model for your problem domain
We know that asynchronous programming requires more efforts. At the core of Vert.x, we support callbacks and promises/futures, the latter being a simple and elegant model for chaining asynchronous operations.
Advanced reactive programming is possible with RxJava, and if you prefer something closer to traditional imperative programming, then we are happy to provide you with first-class support of Kotlin coroutines.
Vert.x supports many asynchronous programming models: choose what works best for each problem you need to solve!
Don’t let failures ruin responsiveness
Failures happen all the time. A database will go down, the network will go down, or some service you depend on will become unresponsive.
Vert.x offers tools to keep latency under control, including a simple and efficient circuit breaker.
A rich ecosystem
The Eclipse Vert.x stack contains modules for building modern, end-to-end reactive services. From efficient reactive database clients to event streaming, messaging and web stacks, the Eclipse Vert.x project has you covered:
Can’t find what you are looking for?
- The Reactiverse is a larger community around the reactive ecosystems where you can find more client and modules.
- The Vert.x Awesome repository provides links to even more interesting projects from the larger open-source community!
Ready to code?
Follow along with our getting started page!