On Netflix Eureka
Deploying a new mid-tier service on AWS without Eureka
This means our service is not facing client on the internet,i.e, edge service. Instead, their customers are other services.
-
Add DNS entry ,i.e., in route 53, so that traffic within the same AZ can be routed within AZ,e.g., inter-service calls from within the same AZ. The name is the single endpoint exposed to other services, the value is the internal load balancer name.
-
Add an internal load balancer, whose endpoint is the value of the DNS name in the previous step. This serves the standard LB purposes within the AZ
-
Add an auto scaling group (ASG) to host all service instances, so that # of instances can be scaled based on traffic
Note that such steps must be performed on EVERY SINGLE service, i.e., each service will have 3 fix points (DNS, LB, ASG) the service’s team has to manage.
Deplying a new mid-tier service on AWS with Eureka
-
After Eureka is up, the service just use Eureka’s API to register the instance. Moreover, given the spring-cloud-netflix suite, such registration is automatically handled by client => the service team don’t need to worry about any fix point, except its own stable service name!
-
The only fix points Eureka ops need to maintain is the directly eureka related, and has nothing to do with registered service,i.e., Eureka is like a service database, and ops don’t worry about the data inside ops except database params
Notes
- Eureka client uses client-side load balance, whereas ELB is a traditional proxy-based load balancing,i.e., all traffic goes through ELB
- Netflix prefers stateless servers, i.e., centralize all state (“fix point”) into DBs
- Registrations may happen in an orphaned server and some clients may reflect new registrations while the others may not.
- Seems that Eureka doesn’t maintain persistant state itself, instead, it is constructed purely from heatbeats of services, both between eureka servers, and applicaion servers.
- Zookeeper is a CP/BASE system. As a comparsion, Eureka is AP system, since service discovery is a fundmental service.
HA Eureka in AWS
- One ASG for a Eureka cluster within a region
- One Elastic IP (EIP) for every server in the cluster. Eureka server will find unused EIP and binds it to itself during the start up, after you config Eureka with the last of EIP address
- Add a DNS TXT record name for the whole region, the record should be of format
txt.region1.eurika-server-domain-name="az1.eurika-server-domain-name" "az2.eurika-server-domain-name" "az3.eurika-server-domain-name"
txt.az1.eurika-server-domain-name="domain-with-EIP1-in-zone1" "domain-with-EIP2-in-zone2"
txt.az2.eurika-server-domain-name="domain-with-EIP3-in-zone2"
txt.az3.eurika-server-domain-name ="domain-with-EIP4-in-zone3"
By default, Eureka client searches for the property file eureka-client.properties in the classpath.In all eureka-client.properties
eureka.shouldUseDns=true
eureka.eurekaServer.domainName=mydomaintest.netflix.net
eureka.eurekaServer.port=7001
eureka.eurekaServer.context=eureka/v2
Note that space as separate in TXT record
You can also hardcode Eureka instances in Eureka config files, but this means the file content will be in AMI and distributed to ALL instances!