0

I put the web servers and db servers in different auto scaling group.

Those machines in auto scaling group will be added or removed dynamically.

Therefore, I have no idea about what's the db server IP address

What the common way to achieve this under AWS

1 Answers1

1

The general principle at work here is called "service discovery". There are any number of different ways of achieving it. Here are a few:

  • Query the EC2 APIs for the list of machines in the group at any particular time.
  • Have the machines register themselves in DNS (via any number of means) against a common RR name; when you retrieve the records for that name, voila! you get a list of all the machines.
  • Use one of the many "service discovery" services out there, like zookeeper, etcd, or (my personal favourite) consul, which keep lists of machines (and optionally do liveness checking, etc) to be queried by anyone who needs to know.
  • Use a higher-level, app-specific mechanism for determining membership. Many clustered data stores do something like this. You can also build your own, either using network APIs directly, or on top of some abstraction layer like ZeroMQ.
womble
  • 96,255
  • 29
  • 175
  • 230