portcluster-computinghostvert.xvertxoptions

In Vertx clustering, what's the difference between cluster host/port and public cluster host/port?


I'm working on an application that is required to be clustered on multiple machines, so I have to configure VertxOptions object by setting the cluster host and port on each node (machine), but I came across different methods for setting hosts and ports: setClusterhost/port, setPublicClusterHost/port. What is the difference?


Solution

  • The clusterHost property tells Vert.x which host it should bind the socket to. The clusterPublicHost how other nodes should connect. By default the values are the same, but sometimes because of proxies you need a way to make them different.

    This is explained in the Javadoc:

    Set the public facing hostname to be used for clustering. Sometimes, e.g. when running on certain clouds, the local address the server listens on for clustering is not the same address that other nodes connect to it at, as the OS / cloud infrastructure does some kind of proxying. If this is the case you can specify a public hostname which is different from the hostname the server listens at. The default value is null which means use the same as the cluster hostname.