DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Service Discovery From Within the Kubernetes Cluster
  • Microservices With JHipster
  • The Principles of Planning and Implementing Microservices
  • Microservices Governance and API Management

Trending

  • Using Open Source for Data Integration and Automated Synchronizations
  • Microservices With Apache Camel and Quarkus
  • How To Simplify Multi-Cluster Istio Service Mesh Using Admiral
  • Graph Databases: Unleashing the Power of Relationships
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Service Discovery in a Microservices Architecture

Service Discovery in a Microservices Architecture

A discussion of how service discovery operates in a microsevices architecture and allows microservices to communicate.

Akash Verma user avatar by
Akash Verma
·
Updated Jul. 12, 19 · Analysis
Like (1)
Save
Tweet
Share
6.13K Views

Join the DZone community and get the full member experience.

Join For Free

What is service discovery?

In a microservices-based application, there are often many microservices communicating with each other to achieve some common outcome.

So, we inherently require some method by which a client can call any specific service at a given point of time.

For that to take place, we must have the URL (API endpoint) of that service configured somewhere (in some property file such as application.properties, appl.yml, or something like that).

But it' a very bad practice to keep URLs hard coded. We should not hard code the URL of any service in our application for multiple reasons:

  • Cloud-based application URLs are dynamic so they need to be updated every now and then.

  • Hard coded URLs need code change/code updates.

  • The basic requirement of an application to be run on multiple environments (e.g. local, QA, production, etc. (RFS/UAT/PAT)).

  • Load balancing. This implies that for similar kinds of service there are multiple URLs, so deciding which URL to hard code becomes a bottle neck.

And the list goes on!

...

Conclusion: we cannot keep URLs hard coded in our application.

This leads to a problem of being able to somehow 'discover' the updated and current URL of a service. This process is called "Service Discovery."

In other words, Service Discovery is the process used to get/deduce/trace/find/gather, i.e. 'DISCOVER,' the URL of a particular service. In a nutshell, Service Discovery, as the name suggests, means to discover (somehow) the endpoint for a particular service.

There are two types of service discovery:

  1. Client-side service discovery

  2. Server-side service discovery

Client-Side Service Discovery

Client ===> DISCOVERY SERVER ===> service 1

                                    service 2

                                    service 3


The client calls the discovery server to get the URL of, say, service 2. The discovery server fetchs the URL of service 2 and returns it to the client. Then the client makes the actual API call to service 2 with the aid of the URL it obtained via discovery server.

But there's an obvious disadvantage to this model: there's too much 'pinging' going on. And the client cannot actually make a call to the 'service 2' directly. It's calling the discovery server, then getting the URl and then making the actual API call to service 2.

This gives rise to server-side service discovery.

Server-Side Service Discovery

Here, there's no discovery server. Instead, there's some sort of directory server (containing the URLs of all the Services) between the client and the available services.

The client calls the directory, telling it to convert 'service 2' that I (the client) said "Hi."

In return, the directory server pings service 2 and relays the client's message to it.

So, this makes it possible for the client to avoid unnecessary pings to the discovery server, getting the URL and making the actual call to service 2.

microservice Discovery (law) Service discovery Architecture

Opinions expressed by DZone contributors are their own.

Related

  • Service Discovery From Within the Kubernetes Cluster
  • Microservices With JHipster
  • The Principles of Planning and Implementing Microservices
  • Microservices Governance and API Management

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: