Skip to content

Zoned ServiceInstanceListSupplier #658

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

Merged
merged 7 commits into from
Dec 18, 2019

Conversation

OlgaMaciaszek
Copy link
Collaborator

Fixes gh-632

Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a few little things, LGTM.

* @return The {@link String} value from instance metadata corresponding to the
* {@link ServiceInstance#ZONE} key.
*/
default String getZone() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not pollute ServiceInstance with shortcuts for metadata. I think this can go safely in the ZonePreferenceServiceInstanceListSupplier

zone = environment.getProperty("spring.cloud.loadbalancer.zone");
}
if (zone != null) {
List<ServiceInstance> filteredInstances = serviceInstances.stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See @dsyer's comment #652 (comment) about stream(). Let's change to a loop here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realise Stream API had performance issues. Hope they improve as it's so much more readable to me. Will switch it here, however.

Copy link
Contributor

@ryanjbaxter ryanjbaxter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, but I do have one question.

I might be confusing concepts here, but with Ribbon I believe we always got all instances across all zones but if there was an instance within the same zone Ribbon would select that instance above the others (and only try the others if it failed and we retried). With this implementation if we only return instances within the same zone we would loose the functionality of trying services in another zone when retrying wouldn't we?

@OlgaMaciaszek
Copy link
Collaborator Author

This LGTM, but I do have one question.

I might be confusing concepts here, but with Ribbon I believe we always got all instances across all zones but if there was an instance within the same zone Ribbon would select that instance above the others (and only try the others if it failed and we retried). With this implementation if we only return instances within the same zone we would loose the functionality of trying services in another zone when retrying wouldn't we?

That's probably something to think about. Ribbon has a whole logic of verifying whether the instances are up and running. We, however, re-query the SR to get the running instances. In the cached version, this might be slightly affected, but reducing the TTL should work.

We don't also really provide any retry support OOTB here, but it might be a good idea to add it. We could then do the first execution on a filtered subset and then retry on the entire set. I think we could provide sth like a RetrySILS that could have two different delegates - primary and fallback- (say, zoned and simple discovery service) and would retry on the second one (with a broader scope) when the request has failed with the first one. That seems like something for another issue, though; WDYT?

@spencergibb
Copy link
Member

Yes, it would be another issue

@OlgaMaciaszek OlgaMaciaszek merged commit 75338cd into master Dec 18, 2019
@spencergibb spencergibb modified the milestones: 2.2.1.SR1, 2.2.1.RELEASE Dec 21, 2019
@OlgaMaciaszek OlgaMaciaszek deleted the gh-632-zoned-serviceinstance-list-supplier branch January 22, 2020 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] consider zone aware loadbalancer
3 participants