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

Method isThisMyUrl returns false in setup configured with DNS, is there a workaround? #1087

Closed
mgtriffid opened this issue Jun 21, 2018 · 6 comments

Comments

@mgtriffid
Copy link
Contributor

In our setup Eureka replication is configured following this guide. DNS records are resolved into AWS ELBs. And looks like this method returns false for ELB which actually belongs to stack where this instance is running. Because of that, heartbeats which were sent by clients to particular Eureka instance are replicated to this instance again. And because of that self-preservation can't trigger properly: there are more heartbeats than expected.

Has anybody face this issue? As possible workaround, maybe there is a way to configure instanceInfo.hostName somehow to make it match ELB?

Thanks in advance for advice!

@pparth
Copy link

pparth commented Jun 26, 2018

Any news here?

@mgtriffid
Copy link
Contributor Author

In our custom build we ended up with following solution.
Each Eureka node generates random UUID, and exposes an endpoint which just returns this UUID.
Custom implementation of PeerEurekaNodes overrides method isThisMyUrl, and in this method it first calls mentioned endpoint of passed host. And if this call returns the same UUID this node has generated, it means "this is my url", and Eureka remembers that host and always thinks it is it's own host. But I'm not sure how to implement similar functionality in original Eureka, as can't foresee all possible cases. Just sharing an idea here.

@qiangdavidliu
Copy link
Contributor

Thanks @mgtriffid for the proposed solution, that would work. In effect what's required is for eureka servers to have an identity that it can match on. When using hostnames directly, this works, but not when servers are fronted by an ELB. The custom changes by @mgtriffid may be something that can be generalised into something that can work with both hostnames and custom UUIDs, and we would welcome such a PR for this project.

@mgtriffid
Copy link
Contributor Author

mgtriffid commented Jul 13, 2018

Submitted a PR, @qiangdavidliu .

With this PR Eureka still first tries to perform regular check, and only if it fails, we try to fetch peer id.

Also, I've added check only for replications and not for initial resolving peers, because in common scenario (when several instances are starting at the same time) we can't contact peers, as they are not open for traffic yet. Also wanted to perform calls to peers through common mechanism of EurekaHttpClient, hence, had to add method to PeerEurekaNode, and we don't have instances of PeerEurekaNode during initial URLs resolution.

@holy12345
Copy link
Contributor

Hi @mgtriffid
I face the issue which maybe the same to you.
When I start a eureka server in local, and start a eureka client, I see the server log has two register log. By the debug the source code , I found isThisMyUrl is check not total right

In my mind I think when a eureka client start It will register to eureka server and eureka server will replicate to peer node(In replicate logic, it should skip itself).

But I found it not skip itself : (

@mgtriffid
Copy link
Contributor Author

@holy12345 , PR #1107 is merged and included in 1.9.4, please see if new config parameter fits your needs.
I guess we can close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants