Microservices
Microservices
Refer to the above diagram. Here, each hexagonal shape represents an individual service component.
Similar to the working of bees, each agile team builds an individual service component with the available
frameworks and the chosen technology stack. Just as in a beehive, each service component forms a
strong microservice architecture to provide better scalability. Also, issues with each service component
can be handled individually by the agile team with no or minimal impact on the entire application.
Decoupling – 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
Each microservices focuses on single capability Increases delay due to remote calls
Ensures security of each service Tough to track data across various boundaries
Fig 6: Comparison Between Monolithic SOA & Microservices – Microservices Interview Questions
Monolithic Architecture is similar to a big container wherein all the software components of an
application are assembled together and tightly packaged.
A Service-Oriented Architecture is a collection of services which communicate with each other.
The communication can involve either simple data passing or it could involve two or more
services coordinating some activity.
Microservice Architecture is an architectural style that structures an application as a collection
of small autonomous services, modeled around a business domain.
Q8. What are the challenges you face while working Microservice
Architectures?
Developing a number of smaller microservices sounds easy, but the challenges often faced while
developing them are as follows.
Automate the Components: Difficult to automate because there are a number of smaller
components. So for each component, we have to follow the stages of Build, Deploy and, Monitor.
Perceptibility: Maintaining a large number of components together becomes difficult to deploy,
maintain, monitor and identify problems. It requires great perceptibility around all the components.
Configuration Management: Maintaining the configurations for the components across the
various environments becomes tough sometimes.
Debugging: Difficult to find out each and every service for an error. It is essential to maintain
centralized logging and dashboards to debug problems.
Q9. What are the key differences between SOA and Microservices
Architecture?
The key differences between SOA and microservices are as follows:
SOA Microservices
Follows “share-as-much-as-possible” architecture Follows “share-as-little-as-possible” architecture
approach approach
Importance is on business functionality reuse Importance is on the concept of “bounded context”
They focus on people collaboration and freedom of
They have common governance and standards
other options
Uses Enterprise Service bus (ESB) for
Simple messaging system
communication
They use lightweight protocols such
They support multiple message protocols
as HTTP/REST etc.
Single-threaded usually with the use of Event Loop
Multi-threaded with more overheads to handle I/O
features for non-locking I/O handling
Maximizes application service reusability Focuses on decoupling
Traditional Relational Databases are more often
Modern Relational Databases are more often used
used
A systematic change requires modifying the
A systematic change is to create a new service
monolith
DevOps / Continuous Delivery is becoming
Strong focus on DevOps / Continuous Delivery
popular, but not yet mainstream
Q10. What are the characteristics of Microservices?
You can list down the characteristics of microservices as follows:
Fig 7: Characteristics of Microservices – Microservices Interview Questions
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.
Explore Curriculum
Microservices can be implemented with or without RESTful APIs, but it’s always easier to build loosely
coupled microservices using RESTful APIs.
Spring Boot is the solution to this problem. Using spring boot you can avoid all the boilerplate code and
configurations. So basically consider yourself as if you’re baking a cake spring is like the ingredients that
are required to make the cake and spring boot is the complete cake in your hand.
The complexity associated with distributed systems – This includes network issues, Latency
overhead, Bandwidth issues, security issues.
Ability to handle Service Discovery – Service discovery allows processes and services in a
cluster to find each other and communicate.
Solved redundancy issues – Redundancy issues often occur in distributed systems.
Load balancing – Improves the distribution of workloads across multiple computing resources,
such as a computer cluster, network links, central processing units.
Reduces performance issues – Reduces performance issues due to various operational
overheads.
WebMvcTest annotation is used for unit testing Spring MVC Applications in cases where the test
objective is to just focus on Spring MVC Components. In the snapshot shown above, we want to launch
only the ToTestController. All other controllers and mappings will not be launched when this unit test is
executed.
Microservices
Microservices is an architecture wherein all the components of the system are put into
individual components, which can be built, deployed, and scaled individually. There are certain principles
and best practices of Microservices that help in building a resilient application.
At the bottom level, we have technology-facing tests like- unit tests and performance tests.
These are completely automated.
At the middle level, we have tests for exploratory testing like the stress tests and usability
tests.
At the top level, we have acceptance tests that are few in number. These acceptance tests help
stakeholders in understanding and verifying software features.
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.
So suppose a user has to enter only username and password, then that’s considered a single-factor
authentication.
Fig 12: Types of Credentials of Two Factor Authentication – Microservices Interview Questions
Q29. What are Client certificates?
A type of digital certificate that is used by client systems to make authenticated requests to a remote
server is known as the client certificate. Client certificates play a very important role in many mutual
authentication designs, providing strong assurances of a requester’s identity.
Usage in Microservices:
Next
Q32. What is Conway’s law?
“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
Fig 13: Representation of Conway’s Law – Microservices Interview Questions
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.
Also, contract testing does not test the behavior of the service in depth. Rather, it tests that the inputs &
outputs of service calls contain required attributes and the response latency, throughput is within allowed
limits.
In layman terms, you can say that end to end testing is a kind of tests where everything is tested after a
particular period.
Fig 14: Hierarchy of Tests – Microservices Interview Questions
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.
1. Quarantine
2. Asynchronous
3. Remote Services
4. Isolation
5. Time
6. Resource leaks
For example, for an empty stack, you can create a stub that just returns true for empty() method. So, this
does not care whether there is an element in the stack or not.
Mock
As per pyramid, the number of tests at first layer should be highest. At service layer, the number of tests
should be less than at the unit test level, but more than at the end-to-end level.
So, this packaged product is called a Container and since it is done by Docker, it is called Docker
container!
Microservices Architecture Training
Weekday / Weekend BatchesSee Batch Details
Decides broad strokes about the layout of the overall software system.
Helps in deciding the zoning of the components. So, they make sure components are mutually
cohesive, but not tightly coupled.
Code with developers and learn the challenges faced in day-to-day life.
Make recommendations for certain tools and technologies to the team developing microservices.
Provide technical governance so that the teams in their technical development follow principles of
Microservice.
For Example, we can define an Order microservice. An Order can have different states. The transitions of
Order states can be independent events in the Order microservice.
Q50. What are Reactive Extensions in Microservices?
Reactive Extensions also are known as Rx. It is a design approach in which we collect results by calling
multiple services and then compile a combined response. These calls can be synchronous or
asynchronous, blocking or non-blocking. Rx is a very popular tool in distributed systems which works
opposite to legacy flows.