jeffrey
jeffrey

Reputation: 3354

How can I communicate between ec2 instances without manually looking up their public dns?

I'm trying to find a way to automate the communication between amazon ec2 instances. For example, lets say I start 10 ec2 instances, one of which is the master node. The master node holds a queue of jobs. The other 9 instances pull jobs from the queue. The 9 instances need to connect to the master node to pull jobs from the queue. Currently I hard code the public dns name of the master node in the 9 ec2 instances' user_data when I start them.

However, what if the master node fails, or another master node is added or subtracted due to my auto-scaling configuration? My slave nodes would then have the wrong hard coded public dns, and could not connect. My main question is, how can my slave nodes be updated to reflect the new master node public dns automatically?

Upvotes: 0

Views: 103

Answers (1)

Eric J.
Eric J.

Reputation: 150198

Some queue solutions have built-in support for discovery (adding/removing nodes).

If yours does not, you could consider reading the configuration from an external source (perhaps an XML document hosted on S3), and have each participating instance periodically check for configuration changes.

If you use auto-scaling, you could instead have each participating instance parse the output of ec2-describe-instances to understand the current configuration.

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DescribeInstances.html

Upvotes: 1

Related Questions