An event-driven microservice architecture offers flexibility and scalability but introduces significant challenges in maintaining data consistency across distributed services. Traditional ACID transactions are not viable in such environments, leading to potential data integrity issues during partial failures. This research proposes and evaluates the use of the Saga orchestration pattern as a solution to this problem. A comparative study was conducted by developing two systems in Golang: a baseline system using synchronous inter-service communication and a second system implementing an event-driven Saga pattern with Redis Streams as the event bus. The systems, utilizing MySQL, MongoDB, Redis, and Elasticsearch, were subjected to various failure scenarios. The results demonstrate that the synchronous system consistently produced data inconsistencies during partial failures, while the Saga-based system successfully maintained data integrity by executing compensating transactions, thus restoring the system to a consistent state. The study concludes that the Saga pattern is an effective strategy for optimizing data consistency and reliability in complex microservice architectures.
Copyrights © 2025