Top Microservices Interview Questions and Answers, Part 2
We finish going through the top questions you're likely to encounter when interviewing for a microservices dev role. Read on to freshen up you microservices knowledge!
Join the DZone community and get the full member experience.Join For Free
Welcome back! If you missed Part 1, you can check it out here.
15. What Are Coupling and Cohesion?
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.
Interviewers will often ask about cohesion. It is also another measurement unit. More like a degree to which the elements inside a module remain bonded together.
It is imperative to keep in mind that an important key to designing microservices is a composition of low coupling along with high cohesion. When loosely coupled, a service knows very little about other services. 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.
16. What Is OAuth?
Open Authorization Protocol, otherwise known as OAuth, helps to access client applications using third-party protocols like Facebook, GitHub, etc., via HTTP. You can also share resources between different sites without the requirement of credentials.
OAuth allows the account information of the end user to be used by a third-party like Facebook while keeping it secure (without using or exposing the user’s password). It acts more like an intermediary on the user’s behalf while providing a token to the server for accessing the required information.
17. Why Do We Need Containers for Microservices?
To manage a microservice-based application, containers are the easiest alternative. It helps the user to individually deploy and develop. You can also use Docker to encapsulate microservices in the image of a container. Without any additional dependencies or effort, microservices can use these elements.
18. What Are the Ways to Access RESTful Microservices?
Another one of the frequently asked microservices interview questions is how to access RESTful microservices? You can do that via two methods:
- Using a REST template that is load balanced.
- Using multiple microservices.
19. What Are Some Major Roadblocks for Microservices Testing?
Talking about the cons, here is another one of the microservices interview questions you may be ready for, will be around the challenges faced while testing microservices.
- Testers should have a thorough understanding of all the inbound and outbound processes before they start writing the test cases for integration testing.
- When independent teams are working on different functionalities, collaboration can prove to be quite a struggling task. It can be tough to find an idle time-window to perform a complete round of regression testing.
- With an increasing number of microservices, the complexity of the system also increases.
- During the transition from monolithic architecture, testers must ensure that there is no disruption between the internal communication among the components.
20. Common Mistakes Made While Transitioning to Microservices
Not only on development, but mistakes also often occur on the process side. And any experienced interviewer will have this in the queue for microservices interview questions. Some of the common mistakes are:
- Often the developer fails to outline the current challenges.
- Rewriting the programs that are already existing.
- Responsibilities, timeline, and boundaries not clearly defined.
- Failing to implement and figure out the scope of automation from the very beginning.
21. What Are the Fundamentals of Microservices Design?
This is probably one of the most frequently asked microservices interview questions. Here is what you need to keep in mind while answering to it:
- Define a scope.
- Combine loose coupling with high cohesion.
- Create a unique service which will act as an identifying source, much like a unique key in a database table.
- Creating the correct API and taking special care during integration.
- Restrict access to data and limit it to the required level.
- Maintain a smooth flow between requests and response.
- Automate most processes to reduce time complexity.
- Keep the number of tables to a minimum level to reduce space complexity.
- Monitor the architecture constantly and fix any flaw when detected.
- Data stores should be separated for each microservice.
- For each microservice, there should be an isolated build.
- Deploy microservices into containers.
- Servers should be treated as stateless.
You can also follow this article explaining 9 Fundamentals to a Successful Microservice Design.
22. Where Do We Use WebMVC Test Annotation?
WebMvcTest is used for unit testing Spring MVC applications. As the name suggests, it focuses entirely on Spring MVC components. For example,
@WebMvcTest(value = ToTestController.class, secure = false):
Here, the objective is to only launch
ToTestController. Until the unit test has been executed, other mappings and controllers will not be launched.
23. What Do You Mean by Bounded Context?
A central pattern is usually seen in domain driven design. Bounded context is the main focus of the strategic design section of DDD. It is all about dealing with large teams and models. DDD works with large models by disintegrating them into multiple bounded contexts. While it does that, it also explains the relationship between them explicitly.
24. What Are the Different Types of Two-Factor Authentication?
There are three types of credentials required for performing two-factor authentication.
- A thing that you know – like password or pin or screen lock pattern.
- A physical credential that you have – like OTP or phone or an ATM card, in other words, any kind of credential that you have in an external or third-party device.
- Your physical identity – like voice authentication or biometric security, like a fingerprint or eye scanner.
25. What Is a Client Certificate?
This is a type of digital certificate usually used by client systems for making a request that is authenticated by a remote server. It plays an important role in authentication designs that are mutual and provides strong assurance of the identity of a requester. However, you should have a fully configured backend service for authenticating your client certificate.
26. What Is Conway's Law?
Conway’s Law states, “organizations which design systems … are constrained to produce designs which are copies of the communication structures of these organizations.”
The interviewer may ask a counter microservices interview question, like how is Conway's Law related to microservices. Well, some loosely coupled APIs form the architecture of microservices. The structure is well suited to how a small team is implementing components which are autonomous. This architecture makes an organization much more flexible in restructuring its work process.
27. How to Configure Spring Boot Application Logging?
Spring Boot comes with added support for Log4J2, Java Util Logging, and Logback. It is usually pre-configured as console output. They can be configured by only specifying logging.level in the application.properties file.
28. How Would You Perform Security Testing on Microservices?
Before answering this microservices interview question, explain to the interviewer that microservices cannot be tested as a whole. You will need to test the pieces independently. There are three common procedures:
Code scanning – To ensure that any line of code is bug-free and can be replicated.
Flexibility – The security solution should be flexible so that it can be adjusted as per the requirements of the system.
Adaptability – The security protocols should be flexible and updated to cope up with the new threats by hackers or security breaches.
You can also check out this article explaining the influence of Microservices architecture on security.
29. What Is Idempotence and How Is it Used?
Idempotence refers to a scenario where you perform a task repetitively but the end result remains constant or similar.
Idempotence is mostly used as a data source or a remote service in a way that when it receives more than one set of instructions, it processes only one set of instructions.
Published at DZone with permission of Arnab Roy. See the original article here.
Opinions expressed by DZone contributors are their own.