Eureka is Netflix developed a REST-based services, component services of registration and discovery
It mainly consists of two components: Eureka Server and Eureka Client
Eureka Client: a Java client to simplify the interaction with Eureka Server (usually the client and server micro-service)
capacity (usually the micro registry service) to provide service registry and discovery: Eureka Server
When each micro service starts, it will register themselves by Eureka Client to Eureka Server, Eureka Server stores the service information
In other words, the client and server each micro services will register to Eureka Server, which spawned a micro-service mutual recognition topic
Synchronization: Eureka Client also (logically) Eureka Server each
complete registry between a plurality of services by way of Eureka Server replication synchronization, forming the Eureka availability
identification: Eureka Client Server caches information in the Eureka
even if all Eureka Server nodes shoot down, service consumers can still use the information cache find the service provider (the author has been pro-test)
contract: micro-services periodically (default 30s) sent to Eureka Server heartbeat to renew (renewal ) information (like heartbeat)
renewal: Eureka Server periodically (default 60s) performs a failure detection service
that checks over a certain time (default 90s) did not renew micro service, found that the micro-services node will be written off
Spring Cloud Eureka has already integrated in its children Spring Cloud Netflix inside
Best practices for Eureka configuration, refer to: https://github.com/spring-cloud/spring-cloud-netflix/issues/203
More description, refer to: http://cloud.spring.io/spring-cloud-static/Camden.SR4/#spring-cloud-eureka-server
Eureka Server Configuration deploy a single instance
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Registry, startup class
@SpringBootApplication @EnableEurekaServer public class EurekaApplication { public static void main(String[] args) { SpringApplication.run(EurekaApplication.class, args); } }
Registry profile
server: port: 8761 eureka: instance: hostname: localhost client: registerWithEureka: false fetchRegistry: false serviceUrl: defaultZone: http://localhost:${server.port}/eureka/ spring.cloud.config.discovery.enabled: true