350 likes | 381 Views
One of the reasons behind Tudip's success over these 9 years is our intention to help the people around.<br>In another such endeavor, our CTO Mr. Tushar Apshankar spoke about 'Database design for containerized microservices' in NASSCOM product conclave at Pune.<br>Herewith sharing the PPT presentation for the same.
E N D
Tudip Technologies Continuously Delivering Digital Solutions with Integrity | Innovation | Serenity https://tudip.com/
The world where we live in... Organizations which design systems … are constrained to produce designs which are copies of the communication structures of these organizations. - M. Conway Corollary by James and Neil: Therefore: Make sure the organization is compatible with the product architecture. “ ”
What is Microservice Architecture? As per Martin Fowler, services in a microservice architecture (MSA) are often processes that communicate over a network to fulfill a goal using technology-agnostic protocols such as HTTP. Services are independently deployable. Services are organized around fine-grained business capabilities. Services can be implemented using different programming languages, databases, hardware and software environment, depending on what fits best. This does not mean that a single microservice is written in a patchwork of programming languages.
Salient features of Microservices • Multiple Components • Built For Business, instead of technology • Simple Routing • Decentralized • Failure Resistant • Evolutionary
Overall Microservices Loose coupling is the operative word, that means microservices should be able to be modified without requiring changes in other microservices.
Microservices Pros • Freedom to independently develop and deploy services • A microservice can be developed by a fairly small team • Code for different services can be written in different languages (though practitioners discourage it) • Easy integration and automatic deployment • Easy to understand and modify for developers, thus can help a new team member become productive quickly • The developers can make use of the latest technologies • The code is organized around business capabilities • When change is required in a certain part of the application, only the related service can be modified and redeployed—no need to modify and redeploy the entire application • Better fault isolation: if one microservice fails, the other will continue to work • Easy to scale and integrate with third-party services • No long-term commitment to technology stack
Microservices Cons • Due to distributed deployment, testing can become complicated and tedious • Increasing number of services can result in information barriers • The architecture brings additional complexity as the developers have to mitigate fault tolerance, network latency, and deal with a variety of message formats as well as load balancing • Being a distributed system, it can result in duplication of effort • When number of services increases, integration and managing whole products can become complicated • In addition to several complexities of monolithic architecture, the developers have to deal with the additional complexity of a distributed system • Developers have to put additional effort into implementing the mechanism of communication between the services • Handling use cases that span more than one service without using distributed transactions is not only tough but also requires communication and cooperation between different teams
How Micro a Microservice should be? Amazon's policy is that the team implementing a microservice should be small enough that they can be fed by two-pizzas.
The Hardest Part About Microservices: Database Design
Problems in Monolithic Database • You can NOT scale a service without scaling the database • You can not deploy a service because change in 1 schema, going to affect other microservices and hence you can not do Continuous Integration/Continuous Deployments • You would be stuck with an RDBMS OR NoSQL and can NOT pick what works the best • And hence, service preference of the DB would be completely lost
Well, what about 2PC (Phase Commits) • 2PC, is a mechanism for implementing a transaction across different software components (multiple databases, message queues etc.) • Well, if that is how you implement, the ghosts of limitations of Monolithic Database are going to Haunt You!
The Hardest Part About Microservices:Your Data But challenges of the Database per Service.. https://blog.christianposta.com/microservices/the-hardest-part-about-microservices-data/
Multiple Databases has its own challenges! • Complexity of managing multiple SQL and NoSQL databases • Implementing business transactions that span multiple services is not straightforward. Moreover, many modern (NoSQL) databases don’t support them. The best solution is to use the Saga pattern. Services publish events when they update data. Other services subscribe to events and update their data in response. • Implementing queries that join data that is now in multiple databases is challenging.
Saga • Implement each business transaction that spans multiple services as a saga. • A saga is a sequence of local transactions. • Each local transaction updates the database and publishes a message or event to trigger the next local transaction in the saga. If a local transaction fails because it violates a business rule then the saga executes a series of compensating transactions that undo the changes that were made by the preceding local transactions.
2 ways to coordinating the Saga • There are two ways of coordination sagas: • Choreography - each local transaction publishes domain events that trigger local transactions in other services • Orchestration - an orchestrator (object) tells the participants what local transactions to execute
What all we have used in this application? Saga Along with CQRS
References • https://en.wikipedia.org/wiki/Microservices • https://en.wikipedia.org/wiki/Conway%27s_law • https://microservices.io/patterns/data/event-sourcing.html • https://auth0.com/blog/introduction-to-microservices-part-4-dependencies/ • https://stackoverflow.com/questions/41640621/data-sharing-between-micro-services • https://www.baeldung.com/transactions-across-microservices
Thank You Know more about Tudip here!