Convert Figma logo to code with AI

Netflix logoeureka

AWS Service registry for resilient mid-tier load balancing and failover.

12,362
3,740
12,362
101

Top Related Projects

Integration with Netflix OSS components

28,222

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.

47,330

Distributed reliable key-value store for the most critical data of a distributed system

12,136

Apache ZooKeeper

29,954

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

Quick Overview

Netflix/eureka is an open-source, REST-based service discovery server and client. It is part of the Netflix OSS ecosystem and is used for the discovery and registration of services, providing load balancing and failover capabilities for distributed applications.

Pros

  • Service Discovery: Eureka provides a reliable and scalable service discovery mechanism, allowing services to register themselves and be discovered by other services.
  • Load Balancing: Eureka integrates with other Netflix OSS components to provide load balancing and failover capabilities for distributed applications.
  • Fault Tolerance: Eureka is designed to be highly available and fault-tolerant, with features like self-preservation mode and automatic service instance registration and deregistration.
  • Scalability: Eureka is designed to scale horizontally, allowing for the deployment of multiple Eureka server instances to handle increased traffic and service registrations.

Cons

  • Complexity: Integrating Eureka into a distributed application can add complexity to the overall system architecture, especially for smaller projects.
  • Dependency on Netflix OSS: Eureka is tightly integrated with other Netflix OSS components, which may limit its adoption in non-Netflix environments.
  • Learning Curve: Developers may need to invest time in understanding the Eureka ecosystem and how it fits into their overall application architecture.
  • Vendor Lock-in: By using Eureka, developers may become dependent on the Netflix OSS ecosystem, which could make it difficult to migrate to other service discovery solutions in the future.

Code Examples

Here are a few code examples demonstrating the usage of Eureka:

Registering a Service Instance

InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
    .setAppName("my-service")
    .setInstanceId("my-service-instance-1")
    .setHostName("my-service-host")
    .setPort(8080)
    .build();

EurekaClient eurekaClient = new EurekaClientBuilder()
    .withServiceUrl("http://eureka-server:8761/eureka")
    .build();

eurekaClient.registerInstance(instanceInfo);

This code demonstrates how to register a service instance with the Eureka server.

Discovering a Service Instance

EurekaClient eurekaClient = new EurekaClientBuilder()
    .withServiceUrl("http://eureka-server:8761/eureka")
    .build();

Application application = eurekaClient.getApplication("my-service");
InstanceInfo instanceInfo = application.getInstances().get(0);

String serviceUrl = "http://" + instanceInfo.getHostName() + ":" + instanceInfo.getPort();

This code shows how to discover a service instance using the Eureka client.

Handling Service Instance Deregistration

EurekaClient eurekaClient = new EurekaClientBuilder()
    .withServiceUrl("http://eureka-server:8761/eureka")
    .build();

eurekaClient.unregisterInstance("my-service", "my-service-instance-1");

This code demonstrates how to deregister a service instance from the Eureka server.

Getting Started

To get started with Eureka, you can follow these steps:

  1. Download and Run the Eureka Server: You can download the Eureka server from the Netflix/eureka repository and run it using the provided scripts or Docker images.

  2. Integrate Eureka Client into Your Service: Add the Eureka client dependency to your service's project and configure it to register with the Eureka server. You can find the necessary configuration details in the Eureka Client documentation.

  3. Discover Other Services: Use the Eureka client to discover other registered services and their instances. You can find examples of service discovery in the Eureka Client documentation.

  4. Implement Load Balancing and Failover: Integrate Eureka with other Netflix OSS components, such as Ribbon and Hystrix, to provide load balancing an

Competitor Comparisons

Integration with Netflix OSS components

Pros of spring-cloud/spring-cloud-netflix

  • Provides a more comprehensive set of features and tools for building microservices, including service discovery, load balancing, circuit breakers, and more.
  • Integrates well with other Spring Cloud components, allowing for a more cohesive and streamlined development experience.
  • Offers better support for advanced features like dynamic configuration, distributed tracing, and monitoring.

Cons of spring-cloud/spring-cloud-netflix

  • Requires a deeper understanding of the Spring ecosystem and its conventions, which may have a steeper learning curve for some developers.
  • Can be more complex to set up and configure, especially for smaller projects or teams.
  • May have a higher overhead and resource requirements compared to a standalone Eureka server.

Code Comparison

Netflix/eureka:

public class EurekaServerApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(EurekaServerApplication.class).web(true).run(args);
    }
}

spring-cloud/spring-cloud-netflix:

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

The key differences are that the spring-cloud/spring-cloud-netflix version uses the @EnableEurekaServer annotation to enable the Eureka server functionality, and it relies on Spring Boot's auto-configuration features to set up the application, whereas the Netflix/eureka version requires more manual configuration.

28,222

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.

Pros of Consul

  • Consul provides a more comprehensive service discovery and configuration management solution, including features like health checks, key-value store, and multi-datacenter support.
  • Consul has a more active community and ecosystem, with a wide range of integrations and plugins available.
  • Consul is designed to be highly available and fault-tolerant, with built-in support for service failover and load balancing.

Cons of Consul

  • Consul has a steeper learning curve compared to Eureka, with a more complex configuration and setup process.
  • Consul may have higher resource requirements, especially for larger deployments, due to its more comprehensive feature set.
  • Consul's multi-datacenter support, while a strength, can also add complexity to the deployment and management of the system.

Code Comparison

Eureka Client Registration:

DiscoveryClient discoveryClient = new DiscoveryClient(applicationInfoManager);
discoveryClient.registerHealthCheck(new HealthCheckCallback() {
    @Override
    public HealthCheckResult invoke() {
        return HealthCheckResult.healthy();
    }
});
discoveryClient.register();

Consul Client Registration:

client, err := api.NewClient(api.DefaultConfig())
if err != nil {
    panic(err)
}

registration := &api.AgentServiceRegistration{
    ID:      "my-service-id",
    Name:    "my-service",
    Address: "192.168.1.100",
    Port:    8080,
}

err = client.Agent().ServiceRegister(registration)
if err != nil {
    panic(err)
}
47,330

Distributed reliable key-value store for the most critical data of a distributed system

Pros of etcd-io/etcd

  • etcd is a distributed, reliable key-value store for the most critical data of a distributed system, while Eureka is a service discovery and registration framework.
  • etcd provides a strong consistency model and supports advanced features like transactions, watch, and lease, which can be useful for building highly available and fault-tolerant distributed systems.
  • etcd is written in Go, which is known for its performance, concurrency, and ease of deployment, making it a good choice for building scalable and reliable distributed systems.

Cons of etcd-io/etcd

  • Eureka is more focused on service discovery and registration, while etcd has a broader set of features and use cases, which can make it more complex to set up and configure.
  • Eureka is tightly integrated with the Netflix ecosystem, which can make it easier to use within the Netflix environment, while etcd is a more general-purpose tool.
  • Eureka has a simpler API and is generally easier to use for basic service discovery use cases, while etcd has a more complex API and may require more expertise to use effectively.

Code Comparison

Eureka client registration:

InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
    .setAppName("my-app")
    .setInstanceId("my-instance-id")
    .setHostName("my-host")
    .setPort(8080)
    .build();
eurekaClient.registerInstance(instanceInfo);

etcd key-value set:

resp, err := client.Put(context.Background(), "/my-key", "my-value")
if err != nil {
    // handle error
}
12,136

Apache ZooKeeper

Pros of Apache ZooKeeper

  • ZooKeeper is a mature and widely-used distributed coordination service, with a large and active community.
  • ZooKeeper provides strong consistency guarantees, ensuring that all clients see the same view of the data.
  • ZooKeeper has a rich set of features, including support for distributed locking, leader election, and configuration management.

Cons of Apache ZooKeeper

  • ZooKeeper can be more complex to set up and configure than Eureka, especially in a production environment.
  • ZooKeeper has a higher resource footprint than Eureka, requiring more CPU and memory to run.
  • ZooKeeper's API is more low-level than Eureka's, which may make it more difficult to use for some developers.

Code Comparison

Netflix Eureka:

InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
    .setAppName("myapp")
    .setInstanceId("myapp-1")
    .setHostName("myhost.example.com")
    .setPort(8080)
    .build();

Apache ZooKeeper:

ZooKeeper zk = new ZooKeeper("localhost:2181", 5000, new Watcher() {
    public void process(WatchedEvent event) {
        // Handle events
    }
});
zk.create("/mynode", "data".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
29,954

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

Pros of Nacos

  • Comprehensive Service Management: Nacos provides a comprehensive set of service management capabilities, including service registration, discovery, configuration management, and load balancing, making it a more feature-rich alternative to Eureka.
  • Multi-Language Support: Nacos supports multiple programming languages, including Java, Go, Node.js, and .NET, allowing for greater flexibility in your technology stack.
  • Scalability and High Availability: Nacos is designed to be highly scalable and available, with support for clustering and distributed deployment, making it suitable for large-scale, mission-critical applications.

Cons of Nacos

  • Steeper Learning Curve: Nacos has a more complex architecture and feature set compared to Eureka, which may require more time and effort to understand and configure.
  • Larger Footprint: Nacos has a larger footprint than Eureka, as it includes additional components like a configuration management system and a service management console, which may not be necessary for all use cases.
  • Vendor Lock-in: Nacos is primarily developed and maintained by Alibaba, which may raise concerns about vendor lock-in for some users.

Code Comparison

Here's a brief comparison of the code for registering a service in Eureka and Nacos:

Eureka:

InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
    .setAppName("my-service")
    .setInstanceId("my-service-instance-1")
    .setIPAddr("192.168.1.100")
    .setPort(8080)
    .build();

EurekaClient eurekaClient = new EurekaClientBuilder().build();
eurekaClient.registerInstance(instanceInfo);

Nacos:

NacosNamingService namingService = new NacosNamingService("127.0.0.1:8848");
Instance instance = new Instance();
instance.setServiceName("my-service");
instance.setIp("192.168.1.100");
instance.setPort(8080);
namingService.registerInstance("my-service", instance);

The main difference is that Nacos requires more explicit configuration of the service instance, while Eureka provides a more streamlined approach with the InstanceInfo.Builder.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Eureka

build

Eureka is a RESTful (Representational State Transfer) service that is primarily used in the AWS cloud for the purpose of discovery, load balancing and failover of middle-tier servers. It plays a critical role in Netflix mid-tier infra.

Building

The build requires java8 because of some required libraries that are java8 (servo), but the source and target compatibility are still set to 1.7. Note that tags should be checked out to perform a build.

Contributing

For any non-trivial change (or a large LoC-wise change), please open an issue first to make sure there's alignment on the scope, the approach, and the viability.

Support

Community-driven mostly, feel free to open an issue with your question, the maintainers are looking over these periodically. Issues with the most minimal repro possible have the highest chance of being answered.

Documentation

Please see wiki for detailed documentation.