Can you explain Microservices?
Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modelled around a business domain. Itis a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In microservices architecture, services should be fine-grained and the protocols should be lightweight. The benefit of decomposing an application into different smaller services is that it improves modularity and makes the application easier to understand, develop and test. It also parallelism development by enabling small autonomous teams to develop, deploy and scale their respective services independently. It also allows the architecture of an individual service to emerge through continuous refactoring. Microservices-based architectures enable continuous delivery and deployment.
What are the features of Micro services?
- Decoupling: These Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled
- Componentization: Microservices are treated as independent components that can be easily replaced and upgraded
- Business Capabilities :Microservices are very simple and focus on a single capability
- Autonomy: Developers and teams can work independently of each other, thus increasing speed
- Continous Delivery: Allows frequent releases of software, through systematic automation of software creation, testing, and approval
- Responsibility: Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible
- Decentralized Governance: The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems
- Agility: Microservices support agile development. Any new feature can be quickly developed and discarded again
How does Microservice Architecture work?
- Clients: Different users from various devices send requests.
- Identity Providers: Authenticates user or clients identities and issues security tokens.
- API Gateway: Handles client requests.
- Static Content: Houses all the content of the system.
- Management: Balances services on nodes and identifies failures.
- Service Discovery: A guide to find the route of communication between microservices.
- Content Delivery Networks: Distributed network of proxy servers and their data centers.
- Remote Service: Enables the remote access information that resides on a network of IT devices.
What are the pros of Spring Cloud?
Complexity associated with distributed systems: This overhead includes network issues, Latency overhead, Bandwidth issues, security issues.
Service Discovery: Service discovery tools manage how processes and services in a cluster can find and talk to one another. It involves a directory of services, registering services in that directory, and then being able to lookup and connect to services in that directory.
Redundancy: Redundancy issues in distributed systems.
Load balancing: Load balancing improves the distribution of workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units, or disk drives.
Performance issues: Performance issues due to various operational overheads.
Deployment complexities: Requirement of DevOps skills.
What Netflix projects did we use?
Eureka created by Netflix, it is the Netflix Service Discovery Server and Client. Netflix Ribbon, it provides several algorithm for Client-Side Load Balancing. Spring provide smart Rest Template for service discovery and load balancing by using @Load Balanced annotation with Rest Template instance.
How will you monitor multiple microservices for various indicators like Health?
Spring Boot provides actuator endpoints to monitor metrics of individual microservices. These end points are very special and helpful for getting information about applications like if they are up, if their components like database etc are working good. But a major drawback or difficulty about using actuator endpoints is that we have to individually hit the endpoints for applications to know their status or health. Imagine microservices involving 50 applications, the admin will have to hit the actuator endpoints of all 50 applications. To help us deal with this situation, we will be using open source project located at Built on top of Spring Boot Actuator, it provides a web UI to enable us visualize the metrics of multiple applications.
What is the difference between Service Registration and Discovery?
When we start a project, we usually have all the configurations in the properties file. As more and more services are developed and deployed, adding and modifying these properties become more complex. Some services might go down, while some the location might change. This manual changing of properties may create issues. Eureka Service Registration and Discovery helps in such scenarios. As all services are registered to the Eureka server and lookup done by calling the Eureka Server, any change in service locations need not be handled and is taken care of.
What are the Pros of Microservices?
There are many advantages in using microservices. Because these components are not dependent on the same coding language, developers can use the ones they are most familiar with.
- Smaller code base is easy to maintain.
- Easy to scale as individual component
- Technology diversity i.e. we can mix libraries, databases, frameworks etc
- Fault isolation i.e. a process failure should not bring whole system down
- Better support for smaller and parallel team
- The developers can make use of the latest technologies
- The code is organized around business capabilities
- Independent deployment
- Deployment time reduce
Can you explain the Design patterns for microservices?
Ambassador: It can be used to offload common client connectivity tasks such as monitoring, logging, routing, and security (such as TLS) in a language agnostic way.
Anti-corruption layer: This layer implements a façade between new and legacy applications, to ensure that the design of a new application is not limited by dependencies on legacy systems.
Backends for Frontends: It creates separate backend services for different types of clients, such as desktop and mobile. That way, a single backend service doesn’t need to handle the conflicting requirements of various client types. This pattern can help keep each microservice simple, by separating client-specific concerns.
Bulkhead: It isolates critical resources, such as connection pool, memory, and CPU, for each workload or service. By using bulkheads, a single workload (or service) can’t consume all of the resources, starving others. This pattern increases the resiliency of the system by preventing cascading failures caused by one service.
Gateway Aggregation: This aggregates requests to multiple individual microservices into a single request, reducing chattiness between consumers and services.
Gateway Offloading: It enables each microservice to offload shared service functionality, such as the use of SSL certificates, to an API gateway.
Gateway Routing: It routes requests to multiple microservices using a single endpoint, so that consumers don’t need to manage many separate endpoints.
Sidecar deploys helper components of an application as a separate container or process to provide isolation and encapsulation.
Strangler: It supports incremental migration by gradually replacing specific pieces of functionality with new services.
Read More:
Can you explain the spring batch framework with respect to Microservices?
It is a batch framework that is quite comprehensive and is light in weight on the application. Its lightweight nature is a great source of positivity in the realm of Microservices. This is so because it is designed in such a manner that it can facilitate the development of robust batch applications. It is that kind of a feature in the realm of Microservices that can easily build upon productivity. It is especially used in the development of enterprise applications that are necessary to make sure that the applications developed are able to meet the set standards of a particular organization.
How to achieve server side load balancing using Spring Cloud?
Server side load balancing can be achieved using Netflix Zuul. Zuul is a JVM based router and server side load balancing by Netflix. It provides a single entry to our system, which allows a browser, mobile app, or other user interface to consume services from multiple hosts without managing cross-origin resource sharing (CORS) and authentication for each one. We can integrate Zuul with other Netflix projects like Hystrix for fault tolerance and Eureka for service discovery, or use it to manage routing rules, filters, and load balancing across your system.
Can you explain Consumer-Driven Contract?
CDCs (Consumer driven contract) are a pattern for evolving services. It can be used by external systems. When we work on micro services, there is a particular provider who builds it and there are one or more consumers who use Microservice. Generally, providers specify the interfaces in an XML document. But in Consumer Driven Contract, each consumer of service conveys the interface expected from the Provider.
Can you define OAuth?
OAuth (Open Authorization Protocol) is allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as third-party providers Facebook, GitHub, etc. So with this, you can share resources stored on one site with another site without using their credentials.
Can you define SOA?
SOA (Service-Oriented Architecture) is a software design that comprises of software components providing service to meet the requirements of business processes and needs of software users
Can you define DRY?
DRY (Don’t Repeat Yourself) that promotes the concept of reusing the code. This results in developing and sharing the libraries which in turn result in tight coupling.
Can you define Eureka?
Eureka is the Netflix Service Discovery Server and Client. Eureka Server is using Spring Cloud.
Can you explain Spring Cloud?
Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with external systems. Spring Cloud Task, A short-lived microservices framework to quickly build applications that perform finite amounts of data processing.
Can you define CQRS?
CQRS (Command and Query Responsibility Segregation) is a pattern that segregates the operations that read data (queries) from the operations that update data (commands) by using separate interfaces. This means that the data models used for querying and updates are different. Or CQRS is simply the creation of two objects where there was previously only one. The separation occurs based upon whether the methods are a command or a query
Can you define Conway’s law?
Any different organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.”
Can you define service registry?
The service registry is a database populated with information on how to dispatch requests to microservice instances. A service registry needs to be highly available and up to date. Clients can cache network locations obtained from the service registry.
How do you setup Service Discovery?
Spring Cloud support several ways to implement service discovery but for this I am going to use Eureka created by Netflix. Spring Cloud provide several annotation to make it use easy and hiding lots of complexity.
Can you explain Continuous Monitoring?
CM (Continuous Monitoring) gets into the depth of monitoring coverage, from in-browser front-end performance metrics, through application performance, and down to host virtualized infrastructure metrics.
Can you explain Semantic monitoring?
Semantic monitoring is also known as Synthetic monitoring .It combines automated tests with monitoring the application (web application or mobile application) in order to detect business falling factors.
Can you explain Continuous Integration?
CI (Continuous Integration) is the process of automating the build and testing of code every time a team member commits changes to version control. This encourages developers to share code and unit tests by merging the changes into a shared version control repository after every small task completion.
Can you explain DDD?
DDD stands for Domain Driven Design. An interesting software design technique to understand and solve complexity is DDD. It provides an avenue to facilitate the development of highly cohesive systems through bounded contexts. Model Services based on Domain-driven Design. Microservices is an implementation approach that encourages you to focus your service boundaries on the business domain boundaries. DDD and microservices can be used together as you move your organization to a service-oriented design and reap the benefits of continuous integration and delivery.
What is Contract Testing?
Contract Testing is writing tests to ensure that the explicit and implicit contract of a microservice works as advertised. There are two perspectives when it comes to Contract Tests, consumer and provider. Contract testing is immediately applicable anywhere where you have two services that need to communicate – such as an API client and a web front-end.
Can you define pact?
It is a contract testing tool. Pact is an open source CDC testing framework. It also provides a wide range of language supports like Ruby, Java, Scala, .NET Framework, JavaScript, Swift/Objective-C. We will go through the two major steps with code examples.
Read More :
Can you explain Canary Releasing?
It is a technique to reduce the risk of introducing a new software version in production. This is done by slowly rolling out the change to a small subset of users before giving it out to the entire infrastructure, i.e. making it available to everybody.
Can you explain Cross-Functional testing?
Cross-functional testing is a verification of non-functional requirements, those requirements which cannot be implemented like a normal feature.
Can you explain Cross-Browser Testing?
Cross browser testing is simply what its name means- that is, to test your website or application in multiple browsers- and making sure that it works consistently and as in intended without any dependencies, or compromise in Quality. This testing is applicable to both web and mobile applications.
Can you explain Component testing?
Component testing is also known as program testing or module testing, is done after unit testing. In this type of testing those test objects can be tested independently as a component without integrating with other components for e.g. modules, classes, objects, and programs. This testing is done by the development team.
What is the importance of Web, RESTful APIs?
Microservice architecture is based on a concept wherein all its services should be able to interact with each other to build a business functionality. So, to achieve this, each microservice must have an interface. This makes the web API a very important enabler of microservices. Being based on the open networking principles of the Web, RESTful APIs provide the most logical model for building interfaces between the various components of microservice architecture.
How do you access a restful Microservice?
Load Balanced RestTemplate.
If there are multiple RestTemplate you get the right one.
It can used to access multiple microservices.
Can you explain service discovery in microservice architecture?
Service discovery is about finding the network location of a service provider. There are two types of service discovery patterns
Client-Side Discovery Pattern: The client is responsible for determining the network locations of available service instances and load balancing requests across them. The client queries a service registry, which is a database of available service instances. The client then uses a load-balancing algorithm to select one of the available service instances and makes a request.
Server side Discovery Pattern: Consumer send requests to a load balancer, the load balancer query from registry and decide which location of providers to send to
Can you explain shed light on Tasklet with reference to Spring Batch and Microservices?
It is important to note that Spring Batch easily provides a Tasklet interface with the help of which the application can perform a single task. It can also clean and delete the various types of resources that are needed before the final execution step.
Which companies are using Microservices?
- com
- Netflix
- Amazon
- Ebay
- Etsy
- Bestbuy
- Twitter
- Uber
- Nordstorm
- Sound cloud
- The guardian
- GILT
What are the cons of Microservices?
- Difficult to achieve strong consistency across services
- ACID transactions do not span multiple processes.
- Distributed System so hard to debug and trace the issues
- Greater need for end to end testing
- Required cultural changes in across teams like Dev and Ops working together even in same team.
- Developers have to put additional effort into implementing the mechanism of communication between the services
- Handling use cases that span more than one service without using distributed transactions is not only tough but also requires communication and cooperation between different teams
- The architecture usually results in increased memory consumption
- Partitioning the application into microservices is very much an art.