Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Service Registration and Discovery - Configuration Management

DZone's Guide to

Service Registration and Discovery - Configuration Management

Learn how proper service registration and discovery are crucial to the maintenance of microservices architecture and keeping the focus on development rather than upkeep.

· Microservices Zone ·
Free Resource

The new Gartner Critical Capabilities report explains how APIs and microservices enable digital leaders to deliver better B2B, open banking and mobile projects.

Scaling of distributed applications and infrastructure is very important in microservices architecture in an automated way. Without proper automation, a team just continuously struggles and wastes time on silly things like application configuration, gateway/load balancer configuration, and automation tools. Service registration and discovery and configuration management have become crucial to keeping architecture clean, and also for the team to focus on a core part of development rather than maintenance and resolving fires.

What Problem Are We Solving?

  • Routing traffic to the correct service (Hardcoded IP address approach & DNS Lookup)
  • Manual Intervention of Adding and Removing new services to/from the pool
  • Partnership with Third party consulting firms, while credentials are not secured.
  • Unraveling Configuration Management (Puppet, Chef, ..) issues every time you touch
  • Hassle of managing static Application and Nginx configuration files
  • Long-lived one-time generated API keys
  • Microservices scalability
  • Service failures

Overall, Microservices Architecture looks like this without Service Registry & Discovery

What Is Service Registry & Discovery?

"Service Registration — The process of a service registering its location in a central registry. It usually registers its host and port and sometimes authentication credentials, protocols, versions numbers, and/or environment details." - source: Open-Source Service Discovery by Jason Wilder
"Service Discovery — The process of a client application querying the central registry to learn of the location of services." - source: Open-Source Service Discovery by Jason Wilder

Benefits

  • Services can be started and stopped in any order
  • Servers may fail/be restarted
  • Better Scalability for TRUE distributed system
  • Consistent view of Reactive Configuration
  • Consistent view of services

Service Registry & Discovery Tools

Consul = Zookeeper + Nagios + DNSMasq + Scriptings. Consul brings it all in one package.

What Does Consul Offer?

  • Service Registration and Discovery
  • Health Checks
  • Dynamic Configuration — KV Store
  • Security:
    • TLS

    • Access Control List (ACL) — Fine Grained access to data & API

  • Key Generation
  • Dynamic Load Balancing
  • Support for Single & Multi Data Centers
  • Consul Template
  • Data Encryption
  • Integrates well with Containers
  • Simple REST API
  • CLI — Command Line Interface
  • Web-based Interface for administration
  • JSON
  • Support for any programming language
  • Gossip Protocol

Consul Dependency: Go

Available REST Endpoints

  • kv — key value
  • agent — API for dealing with an agent
  • catalog — dealing with datacenter catalog
  • health — service health checks
  • sessions — group operations and manage consistent view
  • events — fire fast gossip based events
  • acl — setup access control lists and security for Consul
  • status — check the status

Consul Enterprise Features

  • Automated Backups
  • Automated Upgrades
  • Enhanced Read scalability
  • Advanced network models
  • Redundancy Zones

You can get started with Consul using Docker Compose here.

Service Registration & Discovery Patterns

Source: Service Discovery in a Microservices Architecture — Nginx.

Source: Service Discovery in a Microservices Architecture — Nginx.

Source: Service Discovery in a Microservices Architecture — Nginx.

Source: Service Discovery in a Microservices Architecture — Nginx.

Best Consul Java library: consul-api — Java client for Consul HTTP API

Consul libraries and SDKs can be found at Libraries and SDKs — HTTP API — Consul by HashiCorp.

Desired Future Picture

  • Dynamic Configuration — Consul
  • Service Registry & Discovery — Consul
  • Credential Store — Vault
  • API Key Generation — Consul

Dynamic Configuration

Application configuration has always been a challenge in organizations without a DevOps mindset. This also opens up a risk of potential security issues when all kinds of credentials for different organizations get stored in source control in the form of plain text. Also, companies have been working with third-party consultants at large scale without any hesitations.

An Ideal Approach to Application Configuration

  • Key-Value storage tool with the ability to encrypt data.
  • Key-Value storage tool with the availability of HTTP REST API.
  • Key-Value storage tool with the availability of CLI.
  • Key-Value storage tool with the availability of Role-based access for the organization.
  • Key-Value storage tool with audit control.
  • Microservices should be able to pull configuration using HTTP REST API for specific application and environment at the startup without any extra dependencies without a Container Approach.
  • Ability to reload the configuration using a specific REST endpoint in the application context without a Bouncing API.

KV Subcommands

  • delete: Removes data from the KV store
  • export: Exports a tree from the KV store as JSON
  • get: Retrieves or lists data from the KV store
  • import: Imports a tree stored as JSON to the KV store
  • put: Sets or updates data in the KV store
I hope this post has helped you. If you enjoyed this article, please don’t forget to like, comment and share! I would love to know what you think and would appreciate your thoughts on this topic. You can also follow me on Medium, GitHub, and Twitter for more updates.

The new Gartner Critical Capabilities for Full Lifecycle API Management report shows how CA Technologies helps digital leaders with their B2B, open banking, and mobile initiatives. Get your copy from CA Technologies.

Topics:
microservices ,service registry ,service discovery ,configuration management

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}