In AWS, If I want to add new server instance of Glassfish dynamically where my EJB project is deployed. In TomEE, we have multipoint discovery, where if I add new server it will automatically connect with the existing server cluster. Is any such thing available in Glassfish.
-
anyone done horizantal scaling in AWS for glassfish. – Vicky Rathee Sep 20 '17 at 05:08
2 Answers
Automatic discovery is not supported in GlassFish. You would need to write your own scripts to manage this by creating a new node in the DAS from the newly created EC2 instance and using the DAS to create a new instance on that machine. This can be made slightly easier by using an AMI which already has a known GlassFish configuration on it.
An alternative would be to use Payara Server, which is derived from GlassFish and adds Hazelcast as a clustering method.
To use Hazelcast for automatic discovery in AWS, you would need to supply your own hazelcast.xml
config file to Payara Server which contains settings to use the TCP/IP joiner, since multicast is not supported in EC2. An alternative would be to use the Hazelcast AWS plugin which can accept properties about your EC2 configuration and auto discover members that way.

- 4,852
- 1
- 29
- 48
-
-
1In theory, but not without a large amount of work. Payara Server has invested a lot of time and energy into getting Hazelcast to work as the clustering provider seamlessly, so I would imagine you would need detailed knowledge of the internals of TomEE to achieve anything similar with Hazelcast. – Mike Sep 20 '17 at 10:51
GlassFish provides the ability to auto-discover new instances in the cluster via Group Management Service (GMS)
$asadmin $das_host create-cluster --properties "GMS_DISCOVERY_URI_LIST=generate:GMS_LISTENER_PORT=$GMS_LISTENER_PORT" cluster1
You can find more details on this option at the official documentation.
However, you still need to find out how to connect your nodes to the cluster. We were able to automate this with containers: when a new node is provisioned it automatically connects to the cluster. We import DAS_HOST and DAS_PORT via env variables and mount SSH keys (that are required for the further remote management) via nfs volumes.
You can check how the final solution works in this article "GlassFish and Payara Auto-Clustering"

- 395
- 3
- 12