Prev Next

Spring / Spring cloud

Could not find what you were looking for? send us the question and we would be happy to answer your question.

What is Spring Cloud?

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems such as,

  • configuration management,
  • service discovery,
  • circuit breakers,
  • intelligent routing,
  • micro-proxy,
  • control bus,
  • one-time tokens,
  • global locks,
  • leadership election,
  • distributed sessions,
  • and cluster state.

Spring Cloud builds on Spring Boot by providing a bunch of libraries that enhance the behavior of an application when added to the classpath.

Features of Spring cloud.
  • Distributed/versioned configuration,
  • Service registration and discovery,
  • Routing,
  • Service-to-service calls,
  • Load balancing,
  • Circuit Breakers,
  • Global locks,
  • Leadership election and cluster state,
  • Distributed messaging,
Explain microservices architecture.

Microservices architecture is about breaking down large silo applications into more manageable fully decoupled pieces.

Difference: SOA vs Microservices.

Microservices are components while SOA is an architecture.

Microservices related to an application architecture while SOA (Service-oriented architecture) is about enterprise service exposure, that is, integration.

How microservices principles different from SOA?

In microservices, reuse is not a goal.

Making synchronous calls such as API or web services creates real-time dependencies. Messaging is used whenever possible between microservices.

Service discovery at runtime, components are assumed to be volatile, so it is often the client's responsibility to find and even load balance across the instances.

Data duplication is embraced.

What is an API Gateway?

An API gateway sits in front of an application programming interface (API) and acts as a single point of entry for a defined group of microservices. In addition to accommodating direct requests, gateways can invoke multiple back-end services and aggregate the results.

Other advantages of Using API gateway.

  • authentication,
  • load balancing,
  • security policy enforcement, contract and service level agreement (SLA) management,
  • cache management,
  • dependency resolution.
How to implement API Gateway using Spring cloud?

Spring cloud gateway, Netflix Zuul are gateway services that provide dynamic routing, monitoring, resiliency, security, and more.

Explain the Circuit Breaker design pattern.

In the microservice architecture, when one service synchronously invokes another there is always a chance that the other service is unavailable or having high latency. This might cause resource exhaustion, which would make calling service stall and prevent servicing other requests.

Circuit breaker pattern resolve this issue by having service clients invoke a remote service via a proxy. When the number of consecutive failures is more than a threshold, the circuit breaker trips (as in an electric circuit), and for a certain duration (timeout period) all the attempts to invoke the remote service will fail immediately. After the timeout duration expires the circuit breaker performs a limited number of test requests to pass through. If those requests succeed the circuit breaker resumes normal operation, otherwise, the timeout period begins again.

Explain SpringApplicationBuilder class in Spring boot.

The SpringApplicationBuilder is a fluent builder API that lets you chain together multiple method calls and includes parent and child methods that let you create a hierarchy, as shown in the following example:

new SpringApplicationBuilder()
Mention a few spring Cloud annotations and configuration.

@EnableEurekaServer annotation allows us to register microservices to the spring cloud.

@EnableDiscoveryClient annotation also allows us to query Discovery server to find microservices.

Spring provide smart RestTemplate for service discovery and load balancing by using @LoadBalanced annotation with RestTemplate instance.

What is Spring Cloud Netflix?

Spring Cloud Netflix provides Netflix OSS (Open Source Software) integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment. Using simple annotations, you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The patterns provided include Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon).

The features include:

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans. An embedded Eureka server can be created with declarative Java configuration.
  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator. An embedded Hystrix dashboard can be created with declarative Java configuration.
  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations.
  • Ribbon as Client Side Load Balancer.
  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions).
  • Router and Filter: automatic registration of Zuul filters and a simple convention over configuration approach to reverse proxy creation.
What is Netflix OSS?

Netflix Open Source Software (OSS) is a set of frameworks and libraries from Netflix to solve some interesting distributed-systems problems at scale. ItÂ’s pretty synonymous with developing microservices in a cloud environment. Patterns for service discovery, load balancing, fault-tolerance, etc are incredibly important concepts for scalable distributed systems and Netflix OSS provides solutions for these.

What is Eureka in Netflix OSS bundle?

Eureka is a Service Discovery Server and Client provided in the Netflix OSS platform. Service Discovery is one of the key components of a microservice-based cloud architecture.

What is Zuul?

Zuul is an L7 application gateway that provides capabilities for dynamic routing, monitoring, resiliency, security, and more. Zuul is a JVM-based router and server-side load balancer developed by Netflix and available in the Netflix OSS package.

What is Pivotal Cloud Foundry?

Cloud Foundry is an open-source, multi-cloud application platform as a service governed by the Cloud Foundry Foundation. The software was originally developed by VMware and then transferred to Pivotal Software.

It is a service (PaaS) on which developers can build, deploy, run, and scale applications.

Many Organizations provide the cloud foundry platform separately. For example, following are some cloud foundry providers.

  • Pivotal Cloud Foundry,
  • IBM Bluemix,
  • HPE Helion Stackato 4.0,
  • Atos Canopy,
  • SAP Cloud Platform.
What is Spring Cloud Bus?

Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (for example, configuration changes) or other management instructions.

Advantages of Spring cloud.
  • Spring cloud eliminates complexity associated issues with distributed systems.
  • Spring cloud provides service discovery.
  • It reduces redundancy.
  • Load balancing with scale up/down on the fly.
Mention a few common features of Spring Cloud.
  • Service registration and discovery,
  • Routing,
  • Service to service calls,
  • Distributed and versioned configuration,
  • and load balancing and circuit breakers.
What is meant by load balancing?

Load balancing is a technique used to manage the distribution of workloads across several computing resources, such as a computer clusters, CPUs, network lines, and disk drives.

How do we implement load balancing using Spring Cloud?

Using Netflix Ribbon we can implement load balancing.

What is Netflix feign?

Feign makes writing web service clients easier by providing annotation support that allows us to implement our clients with just interfaces.

Feign was originally created and released by Netflix as part of their Netflix OSS project, now it is a open source project.

What is PCF?

PCF stands for Pivotal Cloud Foundry. It is an open-source, multi-platform cloud foundry.

Mention a few Spring cloud annotations.
  • @EnableConfigServer
  • @EunableEurekaServer
  • @EnableDiscoveryClient
  • @EnableCircuitBreaker
  • @HystricCommand
Mention the uses of Eureka and Zookeeper.

Eureka guarantees high availability and usability while Zookeeper guarantees consistency and partition fault tolerance.

What is Zuul?

Zuul is a JVM-based router and server-side load balancer developed by Netflix and included in the Netflix OSS package.

What is Eureka?

Eureka is a Service Discovery Server and Client provided in the Netflix OSS platform. Service Discovery is one of the key tenets of a microservice-based cloud architecture.

Explain the way to implement service discovery in a microservices architecture.

There are many ways to set up service discovery, but Netflix's Eureka is the most efficient. This is a hassle-free procedure that doesn't add much overhead to the application. It also supports a wide range of web applications. A number of annotations are provided by Spring Cloud to make its use as simple as possible and to hide complex concepts.

Advantages of reports and dashboards in microservices.

Monitoring a system usually involves the use of reports and dashboards. Using reports and dashboards for microservices can help to,

  • review deployed component versions,
  • determine which microservices support which resources,
  • determine which services are impacted whenever changes are made or occur to components,
  • make documentation easy to access whenever needed,
  • and determine the level of maturity and compliance from the components.
What are Reactive Extensions in Microservices?

A reactive extension, also known as Rx, is basically a design approach that calls multiple services and then generates a single response by combining the results. The calls can either be blocking or not blocking, synchronous or asynchronous. A popular tool in distributed systems, Rx works exactly opposite to legacy flows.

Explain Spring cloud annotations.

Spring Cloud has mainly following 5 main Annotations:

@EnableConfigServer: This annotation converts the application into the server which is more applications use to get their configuration.

@EnableEurekaServer: This annotation used for Eureka Discovery Services for other applications can use to locate services using it.

@EnableDiscoveryClient: Helping of this annotation application register in the service discovery, it discovers other services using it.

@EnableCircuitBreaker: Use the Circuit Breaker pattern to continue operating when related services fail and prevent cascading failure. This Annotation is mainly used for Hystrix Circuit Breaker.

@HystrixCommand(fallbackMethod="fallbackMethodName"): it is used to mark the method for fall back to another method of they cannot success normally.

Spring Security

Comments & Discussions