Search code examples
modulecluster-computingvert.x

When to use Vert.x cluster


I have a java (gradle) project with multiple modules. All of the modules run on the same server but I want them to be independent, i.e. module A should be started and stopped no matter if module B is running or stopped and vice versa. Each module is a vert.x verticle and the modules should be able to communicate with each other. I read that if the verticles run on the same machine, it's not a good practice to create a clustered vertx instance, but if I don't cluster them, then I got different instances and therefore different eventbusses.

What would you recommend?

(1) Cluster the verticles on the same machine

(2) let the verticles communicate via a router (is this a bad practice?)

(3) Restructure the project in some way


Solution

  • You can deploy verticles to get a deployment id and also undeploy them using the same id. That means they are already independent.

    The simplest way would be to have them running in the same process communicating via the event bus.

    Options 1 & 2 that you listed would introduce unnecessary latency and make your application perform worse.