# Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture
## 6 System Evaluation
#### Performance Analysis
In our proposal, Kafka allows the communication between the microservices by supporting the sent and received messages between them. It also handles the failure and the completion events. Kafka enhances the performance as it is capable of handling thousands of messages per second. The amount of time it takes for a record that is produced to Kafka to be fetched by the consumer is short. Thus, more records will be fetched and the throughput will be improved. 2. Response-time \"Consumed time in a scenario with failure events\" Three scenarios were tested with different error rates. Each scenario contains two kinds of error: The Warehouse-Service occurs error when goods are fetched, the Billing-Service causes an error when processing the payment. Moreover, the proportion of the Warehouse-Service error to the Billing-Service error is 9:1. Besides, 1 k requests were sent without any sleep time to the message queue middleware. Test results are listed below. Figure 25 shows the consumed time when  
* 10% error rate in 1000 requests (900 successful orders);
* 9% Warehouse-Service fetch goods occur error;
* 1% Billing-Service payment failed. Figure 26 shows the consumed time when  
Figure 16:1 Load Testing—with 10% error. * 40% error rate in 1000 requests (600 successful orders);
* 36% Warehouse-Service fetch goods occur error;
* 4% Billing-Service payment failed. Figure 27 shows the consumed time when  
* 70% error rate in 1000 requests (300 successful orders);
* 63% Warehouse-Service fetch goods occur error;
* 17% Billing-Service payment failed. Figures 25-27 show that version 2 which applies the proposed enhanced saga pattern consumes less time than version 1 which utilizes the baseline standard saga pattern even in the scenario with errors. The reason behind this is employing the cache operations instead of the database operation generally enhances the performance and reduces the latency time. According to the proposal, CRUD operations are moved to the memory cache server to enhance the performance instead of the main database, and a commit to the main database occurs only when all requests are successful. In the case of error, no hard-disk operations are performed, there is only a need to revert the change in the memory cache. In the case where an error occurs, the compensation request will be sent to the corresponding message queue middleware. Figure 16:2 Load Testing—with 40% error. Figure 16:3 Load Testing—with 70% error. In the standard saga pattern, updating data will be accomplished on the main database directly. In the case of an error, the compensation transaction will be run to rollback the changes, and the new update requires accessing the main database one more time. In contrast, with the enhanced version, the CRUD operations are moved to the cache level instead of the main database level. This will not cause a wrong database commit or update. The compensation request will be sent to the corresponding message queue middleware in the case of an error. As a result, with the enhanced saga pattern, database commit will only be performed when the transaction is completely successful. Results demonstrated that transferring the main database's CRUD operations to the memory cache server would provide benefits and resolve the read isolation issue, further achieving better performance.