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

Clarify peer replication setup of eureka servers #1251

Closed
william-tran opened this issue Aug 11, 2016 · 18 comments
Closed

Clarify peer replication setup of eureka servers #1251

william-tran opened this issue Aug 11, 2016 · 18 comments

Comments

@william-tran
Copy link

In order for peer replication to work properly, all eureka servers need to know about all other peers. Given servers peer1, peer2, peer3, this won't work.


---
spring.profiles: peer1
eureka.instance.hostname: peer1
eureka.client.serviceUrl.defaultZone: http://peer2/eureka/

---
spring.profiles: peer2
eureka.instance.hostname: peer2
eureka.client.serviceUrl.defaultZone: http://peer3/eureka/

---
spring.profiles: peer3
eureka.instance.hostname: peer3
eureka.client.serviceUrl.defaultZone: http://peer1/eureka/

This is because a server receiving a peer replication request will not further replicate that request to the other peers it knows about: https://github.com/Netflix/eureka/blob/v1.4.10/eureka-core/src/main/java/com/netflix/eureka/registry/PeerAwareInstanceRegistryImpl.java#L610 This can result peers having different views and leases expiring because a particular peer hasn't received the heartbeats it was expecting from a client.

This passage in the docs seems to suggest that the above setup would be sufficient though:

You can add multiple peers to a system, and as long as they are all connected to each other by at least one edge, they will synchronize the registrations amongst themselves. If the peers are physically separated (inside a data centre or between multiple data centres) then the system can in principle survive split-brain type failures.

@ryanjbaxter
Copy link
Contributor

I agree with your analysis of the documentation, I am interpreting it the same way. When you implement the above configuration what is the result on each peer?

@william-tran
Copy link
Author

If all clients have the same property value:

eureka.client.serviceUrl.defaultZone: http://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/

peer1 and peer2 will have the full registry, and peer3 will be empty.

@ryanjbaxter
Copy link
Contributor

So if each server has

eureka.client.serviceUrl.defaultZone: http://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/

peer3 is empty?

What is the result when you have the configuration in your issue description above?

---
spring.profiles: peer1
eureka.instance.hostname: peer1
eureka.client.serviceUrl.defaultZone: http://peer2/eureka/

---
spring.profiles: peer2
eureka.instance.hostname: peer2
eureka.client.serviceUrl.defaultZone: http://peer3/eureka/

---
spring.profiles: peer3
eureka.instance.hostname: peer3
eureka.client.serviceUrl.defaultZone: http://peer1/eureka/

@ccit-spence
Copy link

@william-tran @ryanjbaxter I am using this approach eureka.client.serviceUrl.defaultZone: http://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/

All three are showing the same information. Is that what is expected?

@william-tran
Copy link
Author

william-tran commented Aug 11, 2016

@ryanjbaxter maybe I wasn't clear in my messages, I was describing the setup where the servers have this configuration

---
spring.profiles: peer1
eureka.instance.hostname: peer1
eureka.client.serviceUrl.defaultZone: http://peer2/eureka/

---
spring.profiles: peer2
eureka.instance.hostname: peer2
eureka.client.serviceUrl.defaultZone: http://peer3/eureka/

---
spring.profiles: peer3
eureka.instance.hostname: peer3
eureka.client.serviceUrl.defaultZone: http://peer1/eureka/

And the clients have

eureka.client.serviceUrl.defaultZone: http://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/

The clients are only sending requests to peer1 and have no need to fall back to peer2 or peer3.
peer2 has all the registry information because peer1 is replicating to it. peer3 has no information because neither the clients are sending anything to it, nor are the other peers sending anything to it.

@william-tran
Copy link
Author

william-tran commented Aug 11, 2016

If the servers have this configuration:

eureka.client.serviceUrl.defaultZone: http://peer1/eureka/,http://peer2/eureka/,http://peer3/eureka/

---
spring.profiles: peer1
eureka.instance.hostname: peer1

---
spring.profiles: peer2
eureka.instance.hostname: peer2

---
spring.profiles: peer3
eureka.instance.hostname: peer3

Each peer knows the complete list of all peers, and so all peers will have the same information. Any client can use any peer and get the same up to date information. The point I'm trying to make is that this requirement is not clear in the documentation.

@ryanjbaxter
Copy link
Contributor

OK makes more sense now. @spencergibb asked someone from the netflix OSS team to comment on the issue so lets see what the intended behavior is and then we can adjust the docs accordingly.

@spencergibb
Copy link
Member

netflix uses dns so their "static" list isn't truly static and can be updated eventually.

@qiangdavidliu
Copy link
Contributor

From an architectural point of view, each eureka server needs to know all other peers for replication to fully work. Currently in eureka there are two methods exposed to allow for this, one via config (the method described above), and another via a txt type dns record that allows for a bit more flexibility (the txt based dns record can be changed dynamically and be picked up by the servers if configured to do so).

@william-tran
Copy link
Author

Thanks for confirming that behaviour @qiangdavidliu.

@spencergibb
Copy link
Member

Some of the difference is that at netflix there is one eureka per zone, so peering happens accross zones. So clients in zone1 have the zone1 eureka first, then zones 2 & 3. Clients in zone 2 have zone 2 first then 1 & 3, etc... @qiangdavidliu tell me if I'm wrong.

@qiangdavidliu
Copy link
Contributor

@spencergibb you are not wrong, though we have since moved away from a strict zonal configuration since. Today we run multiple eureka server per zone, and all eurekaClients can talk to any eureka server, however this is code that ensures clients in a zone preferentially connect to (a random) server in the same zone.

@spencergibb
Copy link
Member

@qiangdavidliu thanks for the update

@spencergibb
Copy link
Member

@ryanjbaxter
Copy link
Contributor

@william-tran based on what we know if we updated the docs to state something like

You can add multiple peers to a system, and as long as they are all connected to each other, they will synchronize the registrations amongst themselves. If the peers are physically separated (inside a data centre or between multiple data centres) then the system can in principle survive split-brain type failures.

Would that be clearer? Welcome to suggestions...

william-tran pushed a commit to william-tran/spring-cloud-netflix that referenced this issue Aug 17, 2016
Example uses the same value of eureka.client.serviceUrl.defaultZone for all peers. The eureka server knows who it is and doesn't attempt to replicate to itself [1], so this simplification will work.

[1]https://github.com/Netflix/eureka/blob/v1.4.10/eureka-core/src/main/java/com/netflix/eureka/registry/PeerAwareInstanceRegistryImpl.java#L616-L619
ryanjbaxter added a commit that referenced this issue Aug 26, 2016
 Clarify peer replication setup of eureka servers (Fixes #1251)
@spencergibb
Copy link
Member

Closed via 4b40a45

@bsushant-athena
Copy link

bsushant-athena commented Jun 7, 2018

@qiangdavidliu is it possible for you share an example repo for DNS based peer awareness across zones?

denniseffing added a commit to denniseffing/spring-cloud-netflix that referenced this issue Sep 26, 2018
Example uses the same value of eureka.client.serviceUrl.defaultZone for all peers. The eureka server knows who it is and doesn't attempt to replicate to itself [1], so this simplification will work.

[1]https://github.com/Netflix/eureka/blob/v1.4.10/eureka-core/src/main/java/com/netflix/eureka/registry/PeerAwareInstanceRegistryImpl.java#L616-L619

Cherry picked from commit 4b40a45
denniseffing added a commit to denniseffing/spring-cloud-netflix that referenced this issue Sep 26, 2018
Example uses the same value of eureka.client.serviceUrl.defaultZone for all peers. The eureka server knows who it is and doesn't attempt to replicate to itself [1], so this simplification will work.

[1]https://github.com/Netflix/eureka/blob/v1.4.10/eureka-core/src/main/java/com/netflix/eureka/registry/PeerAwareInstanceRegistryImpl.java#L616-L619

Cherry picked from commit 4b40a45
ryanjbaxter pushed a commit that referenced this issue Sep 26, 2018
Example uses the same value of eureka.client.serviceUrl.defaultZone for all peers. The eureka server knows who it is and doesn't attempt to replicate to itself [1], so this simplification will work.

[1]https://github.com/Netflix/eureka/blob/v1.4.10/eureka-core/src/main/java/com/netflix/eureka/registry/PeerAwareInstanceRegistryImpl.java#L616-L619

Cherry picked from commit 4b40a45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants