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 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
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
Partner Zones AWS Cloud
by AWS Developer Relations
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
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Microservices Architecture: Introduction to Spring Cloud

Microservices Architecture: Introduction to Spring Cloud

In this article, we look at Spring Cloud, and the wide variety of microservices projects being created with it.

Ranga Karanam user avatar by
Ranga Karanam
CORE ·
May. 10, 19 · Tutorial
Like (17)
Save
Tweet
Share
30.88K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we focus on Spring Cloud. We talk about the various components under its umbrella.

You Will Learn

  • What Spring Cloud is.
  • The typical challenges in microservices architectures.
  • The challenges that Spring Cloud solves.
  • The important projects under the Spring Cloud umbrella.
  • How Spring Cloud helps you build your microservices architecture.

Introduction to Cloud and Microservices: Challenges and Advantages

This is the second article in a series of five articles on cloud and microservices. Part 1 can be found here:

  • Miroservices Architecture and a Quick Introduction to Cloud: Why, What, and How

Introducing Spring Cloud

If you go to the homepage of Spring Cloud, you'll see the following:

Spring Cloud Homepage

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state) - Spring Cloud Docs

Spring Cloud is not a single project, but rather a cluster of them.

Shown below is just a small sample of the projects present under this umbrella.

Spring Cloud Projects

Spring Cloud Projects

Let's give a quick introduction to some of the important projects under Spring Cloud umbrella

Spring Cloud Netflix

Netflix was one of the first organizations to play around with a microservices architecture. Under this project, a large number of projects have been open sourced for public use. Eureka, Hystrix, and Zuul are the more popular ones among them.

Spring Cloud Config

This project provides a framework for centralized configuration management, making use of a Git or a SVN repository.

Spring Cloud Bus

This enables the microservices and infrastructure components to communicate with each other, in a distributed setup.

Challenges in a Microservices Architecture

Let's now have a look at the challenges we face while developing microservices applications, and the solutions offered by Spring Cloud for them.

Configuration Management

In a system with a microservices architecture, there are a large number of small-sized microservices that communicate with each other:

Basic Microservice Architecture

Basic Microservices Architecture

Each of these microservices needs to execute across multiple environments. In a given environment, there could be multiple instances of that microservice running. This means the operations team needs to manage a lot of configuration information for each microservice.

The Spring Cloud Config Server provides a solution to such configuration management

Spring Cloud Config Server

Spring Cloud Config Server

Spring Cloud provides an approach where all the configurations across environments for all the microservices are stored in a Git repository. The Spring Cloud Config Server then exposes this information to all the microservices.

Storing the configurations in such a centralized location makes it easier for the operations team to manage the application/architecture.

Dynamic Scale Up And Down

Consider the following example.

The CurrencyCalculationService microservice talks to another microservice, the CurrencyExchangeService. Currently, three instances of CurrencyExchangeService are running. It is possible that at any point in time, more instances can be added in, or existing instances can be removed.

Ribbon Load Balancing

Ribbon Load Balancing

We need the CurrencyCalculationService to be able to distribute the load across the instances available at that point in time.

The need is to dynamically find out the number of instances of the CurrencyExchangeService at that time, and distribute the load across them.

The solution involves multiple components.

Service Registration

All microservices register with a naming server. One of the options Spring Boot provides is Eureka.

Service Discovery

When any microservice wants to talk to another microservice, it asks the naming server. In the example above, the CurrencyCalculationService can ask the Eureka naming server about the instances of the CurrencyExchangeService that are running. The naming service would, in turn, provide the URLs of those instances back to the CurrencyConversionService.

This helps establish a dynamic relationship between instances of the communicating microservices.

Load Balancing

When there are multiple instances of the same microservice, you want to distribute load between them. One of the options Spring Cloud provides is a client-side load balancing framework, Ribbon.

The CurrencyCalculationService uses Ribbon and distributes requests across instances of the CurrencyExchangeService.

The Feign framework helps us to write simpler RESTful clients.

Visibility and Monitoring

In microservices architectures, you will need to have complete visibility into what's happening in your microservices.

In order to trace a request, you need to assign it a unique identifier. Spring Cloud Sleuth helps in assigning an identifier to every request. You can use a distributed tracing solution like Zipkin to trace the request across multiple components.

API Gateway

All micorservices have a few common features — security, logging, analytics, and so on. What is best place to implement these common features?

An API Gateway provides a great solution to this kind of a challenge.

The Netflix Zuul API gateway is a great solution to implement an API Gateway.

Fault Tolerance

What if a microservice is down? How do other microservices respond to it?

Hystrix helps in improving fault tolerance of your microservices.

Summary

In this article, we had a look at the Spring Cloud project, and saw that it is an umbrella for a wide variety of projects. Each of these solves a particular problem associated with microservices. Important problems include service registration, service discovery, load distribution, event tracing, service monitoring and fault tolerance.

Spring Cloud Spring Framework microservice Architecture

Published at DZone with permission of Ranga Karanam, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Create Spider Chart With ReactJS
  • Microservices Testing
  • Choosing the Right Framework for Your Project
  • 11 Observability Tools You Should Know

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

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: