“Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.” – Mel Conway
This law basically tries to convey the fact that, in order for a software module to function, the complete team should communicate well. Therefore the structure of a system reflects the social boundaries of the organization(s) that produced it.
Two-factor authentication enables the second level of authentication to an account log-in process.
Idempotence is the property of being able to do something twice in such a way that the end result will remain the same i.e. as if it had been done once only.
Usage: Idempotence is used at the remote service, or data source so that, when it receives the instruction more than once, it only processes the instruction once.
Specify the properties in application.properties.
Spring MVC applications need the suffix and the prefix to be specified. This can be done by:
* For suffix – spring.mvc.view.suffix: .jsp
* For prefix – spring.mvc.view.prefix: /WEB-INF/
CDCs (Consumer-driven contract) is a prototype to develop services and it is being used by external systems. When you work on microservices, there is a specific provider who builds it and there will be single or multiple consumers using microservice. Typically, providers will state the interfaces within an XML document. However, in CDCs, every consumer of service communicates the interface anticipated from the Provider.
Distributed Transaction is a situation where a single event leads to the transformation of two or more disconnected sources of data that could not be allocated atomically.
The actuator is primarily used to render operational information regarding the various parameters of a running application. These parameters are metrics, health, dump, info, env, etc. For smooth interaction, it makes use of JMX beans or HTTP endpoints.
1. You must use asynchronous communication while handling HTTP POST/PUT (anything that modifies the data) requests, using some reliable queue mechanism (RabbitMQ, AMQP, etc.)
2. It's fine to use synchronous communication for Aggregation pattern at API Gateway Level. But this aggregation should not include any business logic other than aggregation. Data values must not be transformed at Aggregator, otherwise, it defeats the purpose of Bounded Context. In Asynchronous communication, events should be published into a Queue. Events contain data about the domain, it should not tell what to do (action) on this data.
3. If microservice to microservice communication still requires synchronous communication for GET operation, then seriously reconsider the partitioning of your microservices for bounded context, and create some tasks in backlog/technical debt.
A good, albeit non-specific, rule of thumb is as small as possible but as big as necessary to represent the domain concept they own said by Martin Fowler
Size should not be a determining factor in microservices, instead bounded context principle and single responsibility principle should be used to isolate a business capability into a single microservice boundary.
Microservices are usually small but not all small services are microservices. If any service is not following the Bounded Context Principle, Single Responsibility Principle, etc. then it is not a microservice irrespective of its size. So the size is not the only eligibility criteria for a service to become microservice.
In fact, size of a microservice is largely dependent on the language (Java, Scala, PHP) you choose, as few languages are more verbose than others.
If you have to define the Ubiquitous Language (UL), then it is a common language used by developers and users of a specific domain through which the domain can be explained easily.
The ubiquitous language has to be crystal clear so that it brings all the team members on the same page and also translates in such a way that a machine can understand.
It depends upon your project needs. However, in most cases, developers use HTTP/REST with JSON or Binary protocol. However, they can use any communication protocol.
The coupling can be considered to be the measurement of strength between the dependencies of a component. A good Microservices application design always consists of low coupling and high cohesion.
Following the previous question, often the interviewer will ask about cohesion. It is also another measurement unit. More like a degree to which the elements inside a module remain bonded together.
If you are appearing for microservices interview questions then it is imperative to keep in mind that an important key to design microservices is a composition of low coupling along with high cohesion. When loosely coupled, a service knows very little about other. This keeps the services intact. In high cohesion, it becomes possible to keep all the related logic in a service. Otherwise, the services will try to communicate with each other, impacting the overall performance.
Mike Cohn's Test Pyramid explains the different types of automated tests needed for software development. The test pyramid is basically used to maximize automation at all levels of testing, including unit testing, service level testing, UI testing, etc. The pyramid also states that unit tests are faster and more isolated, while UI tests, which are at the top, are more time-consuming and are centered around integration.
In accordance with the pyramid, the number of tests should be highest at the first layer. At the service layer, fewer tests should be performed than at the unit test level, but greater than that at the end-to-end level
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.
Continuous monitoring is a method which is used for searching compliance and risk issues associated with a company’s operational and financial environment. It contains human, processes, and working systems which support efficient and actual operations.
Docker offers a container environment which can be used to host any application. This software application and the dependencies that support it which are tightly-packaged together.
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 weight 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.
Eureka Server, also referred to as Netflix Service Discovery Server, is an application that keeps track of all client-service applications. As every Microservice registers to Eureka Server, Eureka Server knows all the client applications running on the different ports and IP addresses. It generally uses Spring Cloud and is not heavy on the application development process.
The term 'idempotence' refers to the repeated performance of a task despite the same outcome. In other words, it is a situation in which a task is performed repeatedly with the end result remaining the same.
Usage: When the remote service or data source receives instructions more than once, Idempotence ensures that it will process each request once
Distributed transactions are an outdated approach in today's microservice architecture that leaves the developer with severe scalability issues. Transactions are distributed to several services that are called to complete the transaction in sequence. With so many moving parts, it is very complex and prone to failure.
Generally speaking, OAuth (Open Authorization Protocol) enables users to authenticate themselves with third-party service providers. With this protocol, you can access client applications on HTTP for third-party providers such as GitHub, Facebook, etc. Using it, you can also share resources on one site with another site without requiring their credentials.
>> Microservices always rely on each other. Therefore, they need to communicate with each other.
>> As it is distributed system, it is a heavily involved model.
>> If you are using Microservice architecture, you need to ready for operations overhead.
>> You need skilled professionals to support heterogeneously distributed microservices.
Reports and dashboards help in monitoring and upkeep of Microservices. Tons of Application Monitoring Tools assist in this.
Microservices architecture has replaced monolithic architecture for most large-scale websites like:
* Amazon, etc.
As the name implies, CDC (Consumer-Driven Contract) basically ensures service communication compatibility by establishing an agreement between consumers and service providers regarding the format of the data exchanged between them. An agreement like this is called a contract. Basically, it is a pattern used to develop Microservices so that they can be efficiently used by external systems.
The client certificate is a type of digital certificate that generally allows client systems to authenticate their requests to remote servers. In many mutual authentication designs, it plays a key role in providing strong assurance of the requestor's identity.
Communication between microservices can take place through:
* HTTP/REST with JSON or binary protocol for request-response
* Websockets for streaming.
* A broker or server program that uses advanced routing algorithms.
RabbitMQ, Nats, Kafka, etc., can be used as message brokers; each is built to handle a particular message semantic. You can also use Backend as a Service like Space Cloud to automate your entire backend.
A Bounded Context is a central pattern in DDD (Domain-Driven Design), which deals with collaboration across large models and teams. DDD breaks large models down into multiple contexts to make them more manageable. Additionally, it explains their relationship explicitly. The concept promotes an object-oriented approach to developing services bound to a data model and is also responsible for ensuring the integrity and mutability of said data model.
PACT is an open source tool. It helps in testing the interactions between consumers and service providers. However, it is not included in the contract, increasing the reliability of the application. The consumer service developer starts by writing a test which defines a mode of interaction with the service provider. The test includes the provider’s state, the request body, and the response that is expected. Based on this, PACT creates a stub against which the test is executed. The output is stored in a JSON file.
Reports and dashboards are mainly used to monitor and upkeep microservices. There are multiple tools that help to serve this purpose. Reports and dashboards can be used to:
* Find out which microservices expose what resources.
* Find out the services which are impacted whenever changes in a component occur.
* Provide an easy point which can be accessed whenever documentation is required.
* Versions of the components which are deployed.
* To obtain a sense of maturity and compliance from the components.
Domain-Driven Design is an architectural style based on Object-Oriented Analysis Design concepts and principles. It helps in developing a complex system by connecting the related components of the software system into a continuously evolving system. Domain-Driven Design is based on three core principles:
* Focus on the core domain and domain logic.
* Base complex designs on models of the domain.
* Regularly collaborate with the domain experts to improve the application model and resolve any emerging domain-related issues.
* Multiple Service Instance per Host: Run single or multiple service instances of the application on single/multiple physical/virtual hosts.
* Service Instance per Host: Run a service instance per host.
* Service Instance per Container: Run each service instance in its respective container.
* Serverless Deployment: Package the service as a ZIP file and upload it to the Lambda function.
The Lambda function is a stateless service that automatically runs enough micro-services to handle all requests.
* Improved Scalability
* Fault Isolation
* Localized Complexity
* Increased Agility
* Simplified Debugging & Maintenance
* Better correspondence of developers with business users.
* Smaller development teams
* Better scope for technology upgradation.
* Complicated as a whole.
* Requires accurate pre-planning
* Modular dependencies are hard to calculate.
* Less control over third party applications
* Modular Interdependencies are challenging to track.
* More opportunities for malicious intrusions.
* Complete end-to-end testing is difficult.
* Deployment Challenges.
End to End testing authenticates every process within the workflow to make sure everything works flawlessly. Also, it makes sure the system functions in an incorporated manner, and therefore, meeting the business needs. The corresponding tests can encompass the gaps during integration testing or unit testing. Also, it makes sure that the network parameters are properly configured and facilitates the advancement of microservices.
RESTful also known as REST (Representational State Transfer) web service is basically an architectural style that assists the computer systems to seamlessly communicate across the Internet. Such web services let it easier to understand and deploy microservices.
API Gateway is an exceptional class of microservices that fulfills the requirement of a single client application. Also, it serves the backend resources i.e. microservices with a single entry point. Hence, there are no more concerns related to monitoring, security, and flexibility. API Gateway uses a client-side load balancer library to spread load all over the instances depending on round-robin fashion.
Containers are the simplest and efficient method to handle all the microservice-based application. Moreover, it assists you to develop and implement separately. Microservice can utilize the containers without extra effort.
The majority of the large-scale websites such as Netflix, Uber, Amazon, eBay, Twitter, and Spotify have adopted microservices architecture.
Coupling is the extent of interdependence between software modules. In simple terms, it represents proximity connected to two modules or routines. The microservices are loosely coupled with one another.
Following are the cases where you need to implement microservice architecture:
1. You already use a monolith application and later it advances to a level where there are issues in scaling.
2. You cannot reutilize the modules or components or services over various platforms of projects.
3. Execution of new features is difficult and prone to errors.
The deployment of Microservice needs huge investment and a huge infrastructure setup. The management for application, configuration, and staff selection becomes difficult. Moreover, the communication is complex and there are several security threats. At times, it becomes difficult to test and debug the services. An organization needs extreme planning for managing operations overhead.
Monolithic architecture is generally tightly coupled whereas Microservices architecture is loosely coupled. Microservices focus on products rather than projects; the reverse is true for Monolithic. The service startup is faster in microservice than monolithic architecture. In a microservice architecture, any changes implemented in a single data model does not influence other microservices. But in monolithic architecture, any modifications in the data model influence the whole database.
It combines monitoring of the entire application along with automated tests. The primary benefit of Semantic Monitoring is to find out the factors which are more profitable to your business.
Semantic monitoring along with service layer monitoring approaches monitoring of microservices from a business point of view. Once an issue is detected, they allow faster isolation and bug triaging, thereby reducing the main time required to repair. It triages the service layer and transaction layer to figure out the transactions affected by availability or poor performance.
Reports and dashboards help in monitoring and upkeep of Microservices. Tons of Application Monitoring Tools assist in this.
Spring cloud is an Integration software that integrates with external systems. It allows microservices framework to build applications which perform restricted amounts of data processing.
By specifying properties in the application.properties file, it is possible to override the default properties of a spring boot project.
In Spring MVC applications, you need to specify a suffix and prefix. You can do this by adding the properties listed below in the application.properties file.
For suffix – spring.mvc.view.suffix: .jsp
For prefix – spring.mvc.view.prefix: /WEB-INF/
A spring boot actuator is a project that provides restful web services to access the current state of an application that is running in production. In addition, you can monitor and manage application usage in a production environment without having to code or configure any of the applications.
Some of the main components of microservices include:
* Containers, Clustering, and Orchestration
* IaC [Infrastructure as Code Conception]
* Cloud Infrastructure
* API Gateway
* Enterprise Service Bus
* Service Delivery
1.) Wiremock, 2.) Docker and 3.) Hysrix are important Microservices tool.
Microservice Architecture is an architectural development style which builds an application as a collection of small autonomous services developed for a business domain.