Last Updated on July 9, 2023 by KnownSense
11. How can we test the Microservices based architecture?
One should have unit and integration tests where all the functionality of a microservice can be tested. One should also have component based testing.
One should have contract tests to assert that the expectations by the client is not breaking. End-to-end test for the microservices, however, should only test the critical flows as these can be time-consuming. The tests can be from two sides, consumer-driven contract test and consumer-side contract test.
You can also leverage Command Query Responsibility Segregation to query multiple databases and get a combined view of persisted data.
12. What is cohesion and coupling?
The degree to which the elements inside a module belong together is said to be cohesion.
The measure of the strength of the dependencies between components is said to be coupling. A good design is always said to have High Cohesion and Low Coupling.
13. How to scale a Microservices based system?
Assuming that the majority of providers using microservices architecture,
- One can scale the system by increasing the number of instances of service by bringing up more containers.
- One can also apply to cache at microservice layer which can be easy to manage as an invalidation of the cache can be done very easily as the microservice will be the single source of truth.
- Caching can also be introduced at the API Gateway layer where one can define caching rules like when to invalidate the cache.
- One can also shut down some containers when the requirement is less. That is, scale down.
14. Explain Bounded Context in terms of Microservices?
Bounded Context is a central pattern in Domain-Driven Design. In Bounded Context, everything related to the domain is visible within context internally but opaque to other bounded contexts. DDD deals with large models by dividing them into different Bounded Contexts and being explicit about their interrelationships.
Monolithic Conceptual Model Problem
A single conceptual model for the entire organization is very tricky to deal with. The only benefit of such a unified model is that integration is easy across the whole enterprise, but the drawbacks are many, for example:
- At first, it’s very hard to build a single model that works for the entire organization.
- It’s hard for others (teams) to understand it.
- It’s very difficult to change such a shared model to accommodate the new business requirements. The impact of such a change will be widespread across team boundaries.
- Any large enterprise needs a model that is either very large or abstract.
- Meaning of a single word may be different in different departments of an organization, so it may be really difficult to come up with a single unified model. Such a model, even if created, will lead to a lot of confusion across the teams.
15. What are the types of testing for Microservices?
Unit testing – testing the individual functional modules/units
Performance testing
Acceptance test
Exploratory test – experimental testing aimed at learning how an application works
Acceptance tests and performance tests are for the stakeholders. They are usually performed when presenting or giving your end product. They just test the working of an application, thus, they occur less compared to the other two tests.
16. What are distributed transactions?
When you have a number of applications or services, these services will commit changes. Thus, the need to make changes to a particular plan request. There is a need to make sure that all the applications are on the same page.
There is a managing entity that ensures that there is a commitment for a particular service from all the applications and all the services. When that commitment arrives, it is then that a transaction is completed and this kind of transaction is referred to as a distributed transaction
17. What is Idempotence and its uses?
There are certain results where you would want uniformity. That means if there would be a particular application that would execute 10 times, that should not vary my end result. This implies that no matter how many times the application executes, the end result should be the same each time.
To guarantee this, we have something called an Idempotence law which ensures that uniformity.
18. Explain Microservices Architecture?
- 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.
19. What are smart endpoints?
Smart endpoints just meaning actual business rules and any other validations happens behind those endpoints which are not visible to anyone to the consumers of those endpoints think of it as a place where actual Magic happens.
20. What are dumb pipelines?
Dumb pipelines means any communication means where no further actions e.g validations are taken place, it simply carries the data across that particular channel and it may also be replaceable if need be. The infrastructure chosen is typically dumb (dumb as in acts as a message router only). It just means that routing is the only function the pipes should be doing.
Authored by codingknownsense.com