Microservices Interview Questions

Microservices are a software development technique—a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight. The benefit of decomposing an application into different smaller services is that it improves modularity. This makes the application easier to understand, develop, test, and become more resilient to architecture erosion. It parallelizes 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. Microservice-based architectures facilitate continuous delivery and deployment.

Microservices are gaining popularity fast hence there are many job opportunities available. Hence there is a need to prepare for microservices interview questions to get pass the interviews. Below are some of the top microservices interview questions that will help you prepare and clear the concepts.


Q1: As an architect if you have a task to convert any existing monolithic application to convert to new Microservice architecture. So, what should be followed.

a. Every microservice should be independent.
b. 12 factors rule should be applied.
c. Follow domain driven design and everything should be in shape automatically.
d. Implement continuous Integration and Continuous delivery for every broken service.

Answer: b

Q2: In microservices design which point should be considered on top?

a. Cache as much as possible data.
b. Minimize the database hits.
c. Services should make less network calls.
d. Make sure service returns the response as quickly as possible and free up the memory.

Answer: d

Q3: If there is a requirement to return 1 million records by a microservice, what would be the best design approach?

a. Ask user to provide a range and only return very few filtered records.
b. Create multiple instance for the microservice and have each service return the divided response.
c. Use pagination and send the data in chunks, also provide the link for next and previous pages.
d. 1 Million is not much, just return everything together.

Answer: c

Q4: There are some existing microservices which have some complexity issues, you have been assigned to fix those. What would be your approach to fix them?

a. Search for duplicate code and put everything in one place and call it.
b. First of all, make sure it is covered with 100% unit test cases, once it is covered make the changes to remove the duplicate code and make sure all tests are passing.
c. Read the comments in the code make the changes to reduce number of lines.
d. Use SOLID principals and optimize it.

Answer: b

Q5: You have to write a microservice which is printing some papers. What is the best input and output your service can have?

a. Service can except a pdf with printer name as an input and return success or failure with error code.
b. Service can take the input as an object, print it as a text on given printer.
c. Create some pre-defined templates and have client provide you the data in that format
for printing with printer name.
d. Printer is a hardware, so let each client have their own service to handle it.

Answer: a

Q6: As an architect if you 20 teams and each team show time in their application. Every application shows different time. You are tasked to fix this problem. What would be the action?

a. Ask everyone to follow thumb rule of getting client time.
b. Timing is not that much important so ignore it.
c. Create a microservice which give current time and have everyone call it to display the time.
d. Show everywhere UTC time.

Answer: c

Q7: If you are writing a microservice which is providing service for something which is changing frequently, like a chart, scorecard and cryptocurrencies etc. What would be the best approach?

a. Use the advance feature of streaming response and stream the response as an when it changes.
b. Let service return the latest value and client can hit the service again and again at every second.
c. Return the response to client once and also the formula of calculation, client can make the calculation to refresh the data every second and get the value from service once a while.
d. This can’t be achieved with microservices, need to use the hybrid applications.

Answer: a

Q8: You have a requirement to show price of an item in your application, you know that there are 3-4 microservices are available which gives price and also you are aware of the database tables as well to fetch it. Which route should be the best one?

a. Calling microservice will add extra overhead just directly fetch it from the database in your service.
b. Use one of the microservice from the list and see which one is trustworthy.
c. Write your own microservice and call that in your service.
d. Always go to the business owner for that pricing and have them provide you the microservice for pricing.

Answer: d

Q9: As we divide a big application into multiple microservice, it is tough to maintain them. What is the best way to handle this problem?

a. Assign one team member to one microservice and let them monitor their own service round the clock.
b. Create a metrics dashboard and display it in your area, also setup the alerts for failures.
c. Create a backup plan for each service and don’t bother of monitoring.
d. In the code always handle the exception and point to another zone if one service fails.

Answer: b

Q10: If heap memory is growing for your microservice and it is getting restarted once the emory is exhausted. How to fix it?

a. Increase the memory.
b. Create multiple instances for the service.
c. Monitor the memory and free it up manually as and when it grows.
d. Check the heap dump and fix the problem in code to free up the memory.

Answer: d

READ  5 Steps In The Selection Process You Never Knew About