Home » Microservices

Microservices

Last Updated on July 9, 2023 by KnownSense

31. How to maintain ACID transactions in Microservices?
ACID is an acronym for four primary attributes namely atomicity, consistency, isolation, and durability ensured by the database transaction manager. 

  • Atomicity In a transaction involving two or more entities, either all of the records are committed or none are. 
  • Consistency A database transaction must change affected data only in allowed ways following specific rules including constraints/triggers etc. 
  • Isolation Any transaction in progress (not yet committed) must remain isolated from any other transaction. 
  • Durability Committed records are saved by a database such that even in case of a failure or database restart, the data is available in its correct state. 

In a distributed system involving multiple databases, we have two options to achieve ACID compliance: 

  1. One way to achieve ACID compliance is to use a two-phase commit (a.k.a 2PC), which ensures that all involved services must commit to transaction completion or all the transactions are rolled back.
  2. Use eventual consistency, where multiple databases owned by different microservices become eventually consistent using asynchronous messaging using messaging protocol. Eventual consistency is a specific form of weak consistency. 

2 Phase Commit should ideally be discouraged in microservices architecture due to its fragile and complex nature. We can achieve some level of ACID compliance in distributed systems through eventual consistency and that should be the right approach to do it.

32. What are the problems solved by Spring Cloud?
While developing distributed microservices with Spring Boot we face few issues which are solved by Spring Cloud.

  • The complexity associated with distributed systems – This includes network issues, Latency overhead, Bandwidth issues, security issues.
  • Ability to handle Service Discovery – Service discovery allows processes and services in a cluster to find each other and communicate.
  • Solved redundancy issues – Redundancy issues often occur in distributed systems.
  • Load balancing – Improves the distribution of workloads across multiple computing resources, such as a computer cluster, network links, central processing units.
  • Reduces performance issues – Reduces performance issues due to various operational overheads.

33. What are Client Certificates?
A type of digital certificate that is used by client systems to make authenticated requests to a remote server is known as the client certificate. Client certificates play a very important role in many mutual authentication designs, providing strong assurances of a requester’s identity.

34. What is PACT in Microservices?
PACT is an open source tool to allow testing interactions between service providers and consumers in isolation against the contract made so that the reliability of Microservices integration increases.
Usage in Microservices:
– Used to implement Consumer Driven Contract in Microservices.
– Tests the consumer-driven contracts between consumer and provider of a Microservice.

35. What is OAuth?
OAuth stands for open authorization protocol. This allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as third-party providers Facebook, GitHub, etc. So with this, you can share resources stored on one site with another site without using their credentials.

36. What is Contract Testing?
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 behaviour 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.

37. What is End-to-End Microservices testing?
End-to-end testing validates each and every process in the workflow is functioning properly. This ensures that the system works together as a whole and satisfies all requirements.
In layman terms, you can say that end to end testing is a kind of tests where everything is tested after a particular period.

38. What is the use of Container in Microservices?
Containers are a good way to manage microservice based application to develop and deploy them individually. You can encapsulate your microservice in a container image along with its dependencies, which then can be used to roll on-demand instances of microservice without any additional efforts required.

Microservices transactions: container

39. What is DRY in Microservices Architecture?
DRY stands for Don’t Repeat Yourself. It basically promotes the concept of reusing the code. This results in developing and sharing the libraries which in turn result in tight coupling.

40. What is a Consumer driven Contract?
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.


Authored by codingknownsense.com

Scroll to Top