Frequently asked Microservices Interview Questions
In this post, questions from microservices Interviews will be answered for Experienced and Freshers. We're trying to share our experience and learn how to help you make progress in your career.
Q: What is Service?
Ans:
a service is a piece of software, which basically provides functionality to to these applications. It basically provides a service to other pieces of software.
So, for example in the shopping website context, when a user places an order on the website, the website talks to the service, and the service actually carries out the creation, the update, the deletion, and the retrieval of what is from the database, so it provides functionality to the website application.
Q: What is monolithic?
Ans:
"a monolithic application describes a single-tiered software application in which the user interface and data access code are combined into a single program from a single platform. A monolithic application is self-contained, and independent from other computing applications."
Q: Explain monolithic application?
Ans:
Monolithic basically the type of system that came before the microservices movement. These are large systems that almost do the opposite of what microservices are trying to achieve. Okay, so the typical monolithic system is basically your typical enterprise application, and this application might be in the form of a large website with all the modules packaged in together into one package, or it could be in the form of a service which talks to a website and the service itself is a large service with all the modules packaged together as one executable.
The key characteristic is as you add stuff to your application, it keeps growing. There's no restriction in size. There's no division. There's always one package which basically contains everything, and therefore, you also end up with a large codebase, and because the codebase is so large, it might also take the team longer to develop new functionality within the application. It might be the code is so intertwined, that it's difficult to make a change without affecting other parts of the system, and therefore, testing takes longer.
Deployment of a large system can also be challenging, because even for a small bug fix you are having to deploy a new version of the entire system, and therefore, that creates greater risk. And because there's so much code and so much intertwined code, there might be functionality in one of our modules within our overall package that might be useful to an external system, but because it's hidden within a monolithic application, it might not be exposed via the service, and you might have features in there which are not accessible. And because it's one large codebase, we're also stuck with one technology stack that might be a new technology.
Q: What are Pro and Cons of Monolithic?
Ans:
Pro:
- Simple to develop
- Simple to build
- Simple to test
- Simple to deploy
- Simple to scale
Cons:
- New team members productivity
- Code harder to understand
- Code harder to understand
- No emerging technologies
- Scale for bad reasons
- Overloaded container
- Huge database
Q: What is Microservice ?
Ans:
"The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms."
-James Lewis and Martin Fowler, Thoughtworks
Q: What is your understanding of Microservices ?
Ans:
- SOA done Well : Microservices architecture is basically service oriented architecture done well
- After years of doing service oriented architecture people have realized what service oriented architecture should be.
- It's an evolution of service oriented architecture
- Microservices basically introduced a new set of additional design principles which teach you how to size a service correctly, because there was no guidance in the past on how to size a service and what to include in a service.
- Traditional service oriented architecture resulted in monolithic large services. And, because of the size of the service, these services became inefficient to scale up and to change in a reliable way.
- Smaller services, i.e. microservices. basically provide services which are more efficiently scalable, which are flexible. and we can provide high performance in the areas where performance is required.
- An application which is based on microservices architecture is normally an application which is powered by multiple microservices. And, each one of these microservices will provide a set of functions, a set of related functions to specific part of the application.
What is the need of microservices?
Ans:
- One of the reasons for the microservices architecture now is, is the need to respond to change quickly. The software market is really competitive nowadays. If your product can't provide a feature that's in demand, it will lose market share very quickly.
- Microservices can split a large system into parts, so we can upgrade and enhance individual parts in line with the market needs.
- Enable frequent updates to give you a competitive advantage in the business.
- The microservices architecture also allows us to decouple changeable parts. For example if we know, UI for our system, our user interface for our system changes quite often, if it uses the microservices architecture, the UI is most likely decoupled from all the services in the background, and therefore you can change it independently from all the services.
- Each microservice can also have its own security mechanism, therefore making the data distributed, and making the data even more secure.
- Microservices architecture also offers you increased uptime, because when it comes to upgrading the system, you will probably deploy one microservice at the time without affecting rest of the system. And because the system is split up into business domains and business functions, when a problem arises, we can probably quickly identify which service is responsible for that specific business function, and therefore resolve the problem within that microservice.
- Microservices architecture also make the system highly scalable, and it gives the system better performance. When there's a specific part of the system which is in demand, we can just scale that specific part up instead of scaling the whole system up. So if for example the inventory service is in demand, we can create many instances of that microservice without duplicating the entire system. We can also give the ownership of a microservice to a particular development team, so that there's better ownership and knowledge about the microservice.
- Microservices allow us to use the right technology for specific parts in the system.
- Microservice is separate from the other microservice, they don't share databases, and they have their own codebase, you can easily have microservices being worked on concurrently by distributed teams.
Q: What are benefits of microservices ?
Ans:
let's now highlight the key benefits of the microservices architecture - Shorter Development time : Microservices are split into smaller moving parts, which ensures that they have fewer development times
- Reliable and faster deployment : Microservices are loosely coupled, developers can rework, change, and deploy individual components, without deploying or affecting the entire system, and therefore deployment is more reliable and faster.
- Enable frequent updates : Shorter development times and reliable and faster deployment also enable frequent updates.
- Decouple the changeable parts
- Security : Microservices provide this reliability by having your system in many parts, so if one part of the system breaks, it won't break the entire system.
- Increase uptime
- Faster issue resolution
- Highly scalable and better performance
- Better ownership and knowledge
- Right technology : Need to adopt new technology, Because our system is now in several moving parts, we can easily change one part to get a competitive edge
- Enables distributed teams : microservices are small in size, and they have a single focus, and the team have less to worry about in terms of scope, they know the one thing they're working on has a certain scope, and there's no need to worry about the entire system
Checkout our related posts :
Q: What is Spring Cloud ?
Ans:
Spring Cloud was released in March of 2015. The idea's it build common distributed system pattern into this code, so instead of building the scaffolding yourself, instead using annotations, things to be empowered by Spring Boot
Click on Spring Cloud Tutorial to learn more about Spring Cloud