35 Microservices Interview Questions You Most Likely Can't Answer

Alex 👨🏼‍💻FullStack.Cafe - Sep 16 '19 - - Dev Community

35 Microservices Interview Questions You Most Likely Can't Answer
A survey by Nginx shows that 36% of enterprises are currently using microservices, while another 26% are doing research on how to implement them. Read through to refresh your knowledge about some important microservices interview questions you most likely didn't know how to answer.

🔴 Originally published on FullStack.Cafe - Kill Your Tech & Coding Interview

Q1: What is meant by Continuous Integration?

Topic: DevOps
Difficulty: ⭐

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

🔗 Source: edureka.co

Q2: What is Docker?

Topic: Docker
Difficulty: ⭐

  • Docker is a containerization platform which packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment be it development or test or production.
  • Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries etc. anything that can be installed on a server.
  • This guarantees that the software will always run the same, regardless of its environment.

🔗 Source: edureka.co

Q3: What does Containerization mean?

Topic: DevOps
Difficulty: ⭐⭐

Containerisation is a type of virtualization strategy that emerged as an alternative to traditional hypervisor-based virtualization.

In containerization, the operating system is shared by the different containers rather than cloned for each virtual machine. For example Docker provides a container virtualization platform that serves as a good alternative to hypervisor-based arrangements.

🔗 Source: linoxide.com

Q4: Define Microservice Architecture

Topic: Microservices
Difficulty: ⭐⭐

Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

🔗 Source: lambdatest.com

Q5: Explain Blue-Green Deployment Technique

Topic: DevOps
Difficulty: ⭐⭐⭐

Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic. For this example, Blue is currently live and Green is idle.

As you prepare a new version of your software, deployment and the final stage of testing takes place in the environment that is not live: in this example, Green. Once you have deployed and fully tested the software in Green, you switch the router so all incoming requests now go to Green instead of Blue. Green is now live, and Blue is idle.

This technique can eliminate downtime due to application deployment. In addition, blue-green deployment reduces risk: if something unexpected happens with your new version on Green, you can immediately roll back to the last version by switching back to Blue.

🔗 Source: cloudfoundry.org

Q6: What's the difference between a blue/green deployment and a rolling deployment?

Topic: DevOps
Difficulty: ⭐⭐⭐

  • In Blue Green Deployment, you have TWO complete environments.
    One is Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.

  • In Rolling Deployment, you have only ONE complete environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.

🔗 Source: stackoverflow.com

Q7: What are the differences between continuous integration, continuous delivery, and continuous deployment?

Topic: DevOps
Difficulty: ⭐⭐⭐

  • Developers practicing continuous integration merge their changes back to the main branch as often as possible. By doing so, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.
  • Continuous delivery is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated your testing, you also have automated your release process and you can deploy your application at any point of time by clicking on a button.
  • Continuous deployment goes one step further than continuous delivery. With this practice, every change that passes all stages of your production pipeline is released to your customers. There's no human intervention, and only a failed test will prevent a new change to be deployed to production.

🔗 Source: atlassian.com

Q8: What do you know about serverless model?

Topic: DevOps
Difficulty: ⭐⭐⭐

Serverless refers to a model where the existence of servers is hidden from developers. It means you no longer have to deal with capacity, deployments, scaling and fault tolerance and OS. It will essentially reducing maintenance efforts and allow developers to quickly focus on developing codes.

Examples are:

  • Amazon AWS Lambda
  • Azure Functions

🔗 Source: linoxide.com

Q9: What are the features of Microservices?

Topic: Microservices
Difficulty: ⭐⭐⭐

  • 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

🔗 Source: lambdatest.com

Q10: How does Microservice Architecture work?

Topic: Microservices
Difficulty: ⭐⭐⭐

  • 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.

🔗 Source: edureka.co

Q11: What is the difference between Monolithic, SOA and Microservices Architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐

  • 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.

🔗 Source: edureka.co

Q12: What are main differences between Microservices and Monolithic Architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐

Microservices

  • Service Startup is fast
  • Microservices are loosely coupled architecture.
  • Changes done in a single data model does not affect other Microservices.
  • Microservices focuses on products, not projects

Monolithic Architecture

  • Service startup takes time
  • Monolithic architecture is mostly tightly coupled.
  • Any changes in the data model affect the entire database
  • Monolithic put emphasize over the whole project

🔗 Source: edureka.co

Q13: What are the standard patterns of orchestrating microservices?

Topic: Microservices
Difficulty: ⭐⭐⭐

As we start to model more and more complex logic, we have to deal with the problem of managing business processes that stretch across the boundary of individual services.

  • With orchestration, we rely on a central brain to guide and drive the process, much like the conductor in an orchestra. The orchestration style corresponds more to the SOA idea of orchestration/task services. For example we could wrap the business flow in its own service. Where the proxy orchestrates the interaction between the microservices like shown in the below picture.

  • With choreography, we inform each part of the system of its job, and let it work out the details, like dancers all find‐ ing their way and reacting to others around them in a ballet. The choreography style corresponds to the dumb pipes and smart endpoints mentioned by Martin Fowler's. That approach is also called the domain approach and is using domain events, where each service publish events regarding what have happened and other services can subscribe to those events.

🔗 Source: stackoverflow.com

Q14: What are smart endpoints and dumb pipes?

Topic: Microservices
Difficulty: ⭐⭐⭐

  • 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.

  • 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.

🔗 Source: stackoverflow.com

Q15: Whether do you find GraphQL the right fit for designing microservice architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐

GraphQL and microservices are a perfect fit, because GraphQL hides the fact that you have a microservice architecture from the clients. From a backend perspective, you want to split everything into microservices, but from a frontend perspective, you would like all your data to come from a single API. Using GraphQL is the best way I know of that lets you do both. It lets you split up your backend into microservices, while still providing a single API to all your application, and allowing joins across data from different services.

🔗 Source: stackoverflow.com

Q16: How is container different from a virtual machine?

Topic: DevOps
Difficulty: ⭐⭐⭐⭐

  • Unlike a virtual machine, a container does not need to boot the operating system kernel, so containers can be created in less than a second. This feature makes container-based virtualization unique and desirable than other virtualization approaches.
  • Since container-based virtualization adds little or no overhead to the host machine, container-based virtualization has near-native performance
  • For container-based virtualization, no additional software is required, unlike other virtualizations.
  • All containers on a host machine share the scheduler of the host machine saving need of extra resources.
  • Container states (Docker or LXC images) are small in size compared to virtual machine images, so container images are easy to distribute.
  • Resource management in containers is achieved through cgroups. Cgroups does not allow containers to consume more resources than allocated to them.

🔗 Source: stackoverflow.com

Q17: How virtualization works at low level?

Topic: Docker
Difficulty: ⭐⭐⭐⭐

VM manager takes over the CPU ring 0 (or the "root mode" in newer CPUs) and intercepts all privileged calls made by guest OS to create illusion that guest OS has its own hardware. Fun fact: Before 1998 it was thought to be impossible to achieve this in x86 architecture because there was no way to do this kind of interception. The folks at VMWare were the first who had an idea to rewrite the executable bytes in memory for privileged calls of guest OS to achieve this.

The net effect is that virtualization allows you to run two completely different OS on same hardware. Each guest OS goes through all the process of bootstrapping, loading kernel etc. You can have very tight security, for example, guest OS can't get full access to host OS or other guests and mess things up.

🔗 Source: stackoverflow.com

Q18: What is Paravirtualization?

Topic: Docker
Difficulty: ⭐⭐⭐⭐

Paravirtualization, also known as Type 1 hypervisor, runs directly on the hardware, or “bare-metal”, and provides virtualization services directly to the virtual machines running on it. It helps the operating system, the virtualized hardware, and the real hardware to collaborate to achieve optimal performance. These hypervisors typically have a rather small footprint and do not, themselves, require extensive resources.

Examples in this category include Xen, KVM, etc.

🔗 Source: stackoverflow.com

Q19: What is Idempotence?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

Idempotence refers to a scenario where you perform a task repetitively but the end result remains constant or similar.

🔗 Source: lambdatest.com

Q20: What are the pros and cons of Microservice Architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

Pros:

  • Freedom to use different technologies
  • Each microservices focuses on single capability
  • Supports individual deployable units
  • Allow frequent software releases
  • Ensures security of each service
  • Mulitple services are parallelly developed and deployed

Cons:

  • Increases troubleshooting challenges
  • Increases delay due to remote calls
  • Increased efforts for configuration and other operations
  • Difficult to maintain transaction safety
  • Tough to track data across various boundaries
  • Difficult to code between services

🔗 Source: edureka.co

Q21: What do you understand by Contract Testing?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

According to Martin Flower, contract test is a test at the boundary of an external service which verifies that it meets the contract expected by a consuming service.

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.

🔗 Source: edureka.co

Q22: What is the role of an architect in Microservices architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

An architect in microservices architecture plays the following roles:

  • 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.

🔗 Source: edureka.co

Q23: Explain what is the API Gateway pattern

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

An API Gateway is a server that is the single entry point into the system. It is similar to the Facade pattern from object‑oriented design. The API Gateway encapsulates the internal system architecture and provides an API that is tailored to each client. It might have other responsibilities such as authentication, monitoring, load balancing, caching, request shaping and management, and static response handling.

A major benefit of using an API Gateway is that it encapsulates the internal structure of the application. Rather than having to invoke specific services, clients simply talk to the gateway.

🔗 Source: nginx.com

Q24: Mention some benefits and drawbacks of an API Gateway

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

There are some:

  • A major benefit of using an API Gateway is that it encapsulates the internal structure of the application. Rather than having to invoke specific services, clients simply talk to the gateway.
  • It is yet another highly available component that must be developed, deployed, and managed. There is also a risk that the API Gateway becomes a development bottleneck.
  • Developers must update the API Gateway in order to expose each microservice’s endpoints.

🔗 Source: nginx.com

Q25: What is Materialized View pattern and when will you use it?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐

Materialized View pattern is the solution for aggregating data from multiple microservices and used when we need to implement queries that retrieve data from several microservices. In this approach, we generate, in advance (prepare denormalized data before the actual queries happen), a read-only table with the data that's owned by multiple microservices. The table has a format suited to the client app's needs or API Gateway.

A key point is that a materialized view and the data it contains is completely disposable because it can be entirely rebuilt from the source data stores.

This approach not only solves the problem of how to query and join across microservices, but it also improves performance considerably when compared with a complex join, because you already have the data that the application needs in the query table.

🔗 Source: microsoft.com

Q26: What is Canary Releasing?

Topic: DevOps
Difficulty: ⭐⭐⭐⭐⭐

Canary Releasing is a technique to reduce the risk of introducing a new software version in production. This is done by slowly rolling out the change to a small subset of users before giving it out to the entire infrastructure, i.e. making it available to everybody.

🔗 Source: edureka.co

Q27: What Did The Law Stated By Melvin Conway Implied?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Conway’s Law applies to modular software systems and states that:

"Any organization that designs a system (defined more broadly here than just information systems) will inevitably produce a design whose structure is a copy of the organization’s communication structure".

🔗 Source: lambdatest.com

Q28: Name the main differences between SOA and Microservices?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

  • SOA uses Enterprise Service Bus for communication whereas microservices use much simpler messaging systems.
  • Each microservice stores data independently while in SOA components share the same storage.
  • For microservices, it’s typical to use Cloud while for SOA Application Servers are much more common.
  • SOA is still a monolith, in order to make changes, you need to change the entire architecture.
  • SOA using only heavy-weight technologies and protocols (like SOAP, etc) whereas microservices is the leaner, meaner, more agile approach (REST/GraphQL).

🔗 Source: quora.com

Q29: What is the difference between cohesion and coupling?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Cohesion refers to what the class (or module) can do. Low cohesion would mean that the class does a great variety of actions - it is broad, unfocused on what it should do. High cohesion means that the class is focused on what it should be doing, i.e. only methods relating to the intention of the class.

As for coupling, it refers to how related or dependent two classes/modules are toward each other. For low coupled classes, changing something major in one class should not affect the other. High coupling would make it difficult to change and maintain your code; since classes are closely knit together, making a change could require an entire system revamp.

Good software design has high cohesion and low coupling.

🔗 Source: edureka.co

Q30: What is a Consumer-Driven Contract (CDC)?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

This is basically a pattern for developing Microservices so that they can be used by external systems. When we work on microservices, there is a particular provider who builds it and there are one or more consumers who use Microservice.

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.

🔗 Source: edureka.co

Q31: What are Reactive Extensions in Microservices?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

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.

🔗 Source: edureka.co

Q32: What is the most accepted transaction strategy for microservices

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Microservices introduce eventual consistency issues because of their laudable insistence on decentralized data management. With a monolith, you can update a bunch of things together in a single transaction. Microservices require multiple resources to update, and distributed transactions are frowned upon (for good reason). So now, developers need to be aware of consistency issues, and figure out how to detect when things are out of sync before doing anything the code will regret.

Think how transactions occur and what kind make sense for your services then, you can implement a rollback mechanism that un-does the original operation, or a 2-phase commit system that reserves the original operation until told to commit for real.

Financial services do this kind of thing all the time - if I want to move money from my bank to your bank, there is no single transaction like you'd have in a DB. You don't know what systems either bank is running, so must effectively treat each like your microservices. In this case, my bank would move my money from my account to a holding account and then tell your bank they have some money, if that send fails, my bank will refund my account with the money they tried to send.

🔗 Source: softwareengineering.stackexchange.com

Q33: Why would one use sagas over 2PC and vice versa?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Here are two approaches which I know are used to implement distributed transactions:

  • 2-phase commit (2PC)
  • Sagas

2PC is a protocol for applications to transparently utilize global ACID transactions by the support of the platform. Being embedded in the platform, it is transparent to the business logic and the application code as far as I know.

Sagas, on the other hand, are series of local transactions, where each local transaction mutates and persist the entities along with some flag indicating the phase of the global transaction and commits the change. In the other words, state of the transaction is part of the domain model. Rollback is the matter of committing a series of "inverted" transactions. Events emitted by the services triggers these local transactions in either case.

  • Typically, 2PC is for immediate transactions.
  • Typically, Sagas are for long running transactions.

I personally consider Saga capable of doing what 2PC can do, but they have the overhead of implementing the redo mechanism. Opposite is not accurate. I think Sagas are universal, while 2PC involves platform/vendor lockdown and lacks platform independence.

🔗 Source: stackoverflow.com

Q34: Provide an example of "smart pipes" and "dumb endpoint"

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Components in a system use "pipes" (HTTP/S, queues, etc...) to communicate with each other. Usually these pipes flow through an ESB (Enterprise Service Bus) which does a number of things to the messages being passed between components.

It might do:

  • Security checks
  • Routing
  • Business flow / validation
  • Transformation

Once it's completed these tasks the message will be forwarded onto the "endpoint" component. This is an example of "smart pipes" as lots of logic and processing reside inside the ESB (part of the system of "pipes"). The endpoints can then be "dumb" as the ESB has done all the work.

"Smart endpoints and dumb pipes" advocates the opposite scenario. That the lanes of communication should be stripped of business processing and logic and should literally only distribute messages between components. It's then the components themselves that do processing / logic / validation etc... on those messages.

🔗 Source: stackoverflow.com

Q35: How would you implement SSO for Microservice Architecture?

Topic: Microservices
Difficulty: ⭐⭐⭐⭐⭐

Add identity service and authorize service access through it using tokens. Any service that has protected resources will talk to the Identity service to make sure the credentials (token) it has are valid. If they are not it will redirect the user for authentication. Once the token had been validated then it could be saved in the session so subsequent calls in the user's session did not have to make the additional call. You can also create a scheduled job if tokens need to be refreshed in that session.

A good way to resolve it is by using the OAuth 2 protocol. In this situation you could authenticate with an OAuth 2.0 endpoint and the token will be added to the HTTP header for calls to your domain. All of the services shall be routed from that domain so you could get the token from the HTTP header.

🔗 Source: stackoverflow.com

Thanks 🙌 for reading and good luck on your interview!
Please share this article with your fellow devs if you like it!
Check more FullStack Interview Questions & Answers on 👉 www.fullstack.cafe

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .