This is part 2 of Developing Instagram Clone series, other parts are linked below

  1. Developing Instagram Clone: Introduction.
  2. Developing Instagram Clone: Discovery Service.
  3. Developing Instagram Clone: Auth Service
  4. Developing Instagram Clone: Media Service.
  5. Developing Instagram Clone: Post Service.
  6. Developing Instagram Clone: Graph Service.
  7. Developing Instagram Clone: Newsfeed Service.
  8. Developing Instagram Clone: Gateway Service.
  9. Developing Instagram Clone: Front-end Service

Service Discovery

To avoid this we need a place where services can register itself and assign it a name, this place is “service discovery”, You can think of service discovery as DNS, it maps service IP and port to a name.

We will be using Spring Cloud Netflix Eureka, the reason I will not go deep into this is that we are planning to deploy our Instagram clone to K8s, and we don’t need a service discovery since we will be using K8s services.

Clone the Insta-discovery from GitHub, All you need to do is to enable eureka server

@SpringBootApplication
@EnableEurekaServer
public class InstaDiscoveryApplication {

	public static void main(String[] args) {
		SpringApplication.run(InstaDiscoveryApplication.class, args);
	}
}

Disable self-registration

spring:
  application:
    name: insta-discovery

server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

Now you have Eureka server running on

http://localhost:8761

#microservices #cloud #developer

Microservices In Practice: Developing Instagram Clone —Discovery Service
21.10 GEEK