Alias Service and Discovery

Hello! I’m trying to create a low-cost cluster. I do not have much knowledge, I am learning. I will use the Digital Ocean $ 10 plan for the hosts.

I did not quite understand the concept of service alias. Does it make any sense to put Nginx as load balancer and server cache in front and use the alias service as discoverer of hosts? The service passes alias for Nginx the list of hosts?

I do not want to use the haproxy to enjoy the proxy cache of Nginx. I could use them, but I want to decrease the overhead since I have not much money.

That makes sense?
Internet -> nginx load balancer + Cache -> Service Alias -> Hosts APP -> Service Alias -> Mongo DB Replicas.

How would Nginx configuration to allow this? I’m not asking to do the work for me, just to show me the way. Thank you!

Using Google Translator.

A service alias works like a pointer in programming or sort of like a symbolic link in a filesystem. It allows you to create a service name like “app” and change the service that it points to whenever you want. Any service that depends on “app” only needs to know about the alias, not the service it is currently pointed at.

So with what you’ve described you could use an alias called “mongo” that points to a service called “mongo-v1” and point the “hosts app” to “mongo”. Then when you want to upgrade the version of mongodb you can create a new service “mongo-v2”, test it out, and then change the target of the “mongo” service to “mongo-v2”. The “hosts app” will automatically start using mongo-v2, without having to know anything directly about it.

If you’re doing your own load balancing with nginx you will need to point the server directive to the name of the service alias (e.g. “hosts”) and use the resolve parameter on it so that it responds to changes in the list of IP addresses that “hosts” resolves to.


Thank you so much!!!