Search code examples
dnsdockercloudrabbitmqdistributed

IP addresses in distributed systems


I have three situations and think they have common solution:

1) I have heavy background tasks on my only vps machine and decided to distribute them over several vps.

Depending on load I want dynamically add new machines using cloud providers.

2) I decided to move the rabbitmq server to other machine. First of all, I need to change ip address in my producers and my consumers.

3) I decided to dockerize my infrastructure. Docker containers can be located across diferrent networks. Docker containers can be created dynamically. Sometimes I will move docker master mysql, rabbitmq, search engine, etc. containers on different hosts.

Problems:

  • before creating new machines I do not know their IP addresses;
  • I do not want manually edit ip address in my apps, conf files;
  • if Mysql server changes its location, I want my apps do not depend on ip address mysql location.

I think my problems can be solved using DNS server. But I do not know how DNS server can be updated automatically if I decided move mysql server/rabbitmq/search engine to other machine.

I'm sure there are concepts how to solve my problems.


Solution

  • Although the scope of your question is pretty broad, you might want to look into various solutions:

    1. Regarding dynamic addition of new machines, you might want to look into something like AutoScaling groups if you are using AWS. Even other cloud providers support auto scaling of VMs. For autoscaling to work, you would have to configure monitoring thresholds (refer CloudWatch if you are using AWS) so that workloads get scaled out/in according to the load. You can refer to any platform of your choice.
    2. Regarding the IPs address issue, you should bind services to a virtual IP instead of server IP. And, in case of distributed systems, you might want to use service discovery tools like Zookeeper, consul etc to avoid hard coupling and discover services dynamically.

    Hope these pointers help!