Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to prefer connecting to locally running services? #5798

Closed
drdaeman opened this issue Aug 24, 2016 · 4 comments
Closed

Is there a way to prefer connecting to locally running services? #5798

drdaeman opened this issue Aug 24, 2016 · 4 comments
Assignees
Labels
kind/question Issues that just require an answer. No code change needd

Comments

@drdaeman
Copy link

What's the best way to achieve service location awareness?

Consider an example of small toy stack that consists of a load balancer and two services: a web server and a database server. Considering that intra-host communications are almost always cheaper than inter-host ones, what would be the best way to optimize the general performance?

From what I understand, right now, Rancher DNS basically returns all IPs it knows about, in no particular order. So, in theory, it may happen that request will be served by LB, web and database from three completely different hosts. Which sometimes may be a sensible scenario, but sometimes may be considered undesirable and only cause longer response times, especially if the hosts are more than few milliseconds away from each other. Ideally, I would prefer to have some optional mode in which requests would get routed to the same-machine containers (if healthy), but failover to other instances.

I see a few approaches I could try to take, but not sure which one makes sense and whenever I'm not missing something obvious:

  • One way I thought of, is creating per-host twin stacks. The obvious downside is that I'll have to manage multiple copies and keep them in sync (and manually tell about each other or hack some automatic discovery).
  • Another way seems to put everything in a single service and its sidekicks, but then things cannot be scaled independently. I.e. would I want to scale up webserver containers, I would have to spawn two databases as well, which may not always make sense.
  • Then, there's a hard option of not using built-in DNS but query rancher API (project/1aN/containers) instead to see which container's running where, and build configs (primaries and failovers lists) based on this information. Then somehow listen for updates, or, at least, poll periodically. The downsides are that this requires providing container access to Rancher API, and that this basically a kludge.

I believe, I must be not the one who had thought of possible latency issues, and there's probably an already established general approach for dealing with such things. If there is, can someone please suggest me something? If not - are there any plans for this?

Thanks a lot!

@drdaeman
Copy link
Author

drdaeman commented Sep 2, 2016

I'm curious - maybe there is way to configure Rancher networking to slice per-host subnets, say, /20s out of the 10.42/16 network?

This way RFC3484 default address selection policies may automagically do the trick.

@will-chan will-chan added the kind/question Issues that just require an answer. No code change needd label Oct 7, 2016
@will-chan will-chan added this to the Unscheduled milestone Oct 7, 2016
@aemneina
Copy link

aemneina commented Nov 7, 2016

@drdaeman have you explored the rancher-metadata service? You'd be able to query the container's info, namely the host it resides on. From there you could query the service local to your container you want to hit.

@aemneina
Copy link

aemneina commented Nov 7, 2016

currently the /16 subnet will span across hosts in an environment. there is no way to bound a segment to a host.

@aemneina
Copy link

aemneina commented Nov 7, 2016

closing this out for housekeeping, feel free to reopen or open a new issue for more questions.

@aemneina aemneina closed this as completed Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Issues that just require an answer. No code change needd
Projects
None yet
Development

No branches or pull requests

4 participants