# Enhancing Saga Pattern for Distributed Transactions within a Microservices Architecture
## 6 System Evaluation
#### Performance Analysis  
1. Throughput: Number of requests that are handled in a specified duration  
In this experiment, the duration was set to 1 min and 3 min. The VUs were set to 1, 10, 15, 50, 100, and 150. Moreover, there is a one-second sleep between every iteration. * Throughput Results: 1 min duration  
The results of the throughput for 1 min duration are shown in Figures 13-18. As shown in the figures, the average values of the throughput for version 1 with (1 VU/10 VUs/15 VUs/50 VUs/100 VUs/150 VUs) are 297.5, 592.8, 781.5, 2400, 3170, and 4378 respectively, where the average of throughput for version 2 with (1 VU/10 VUs/ 15 VUs/50 VUs/100 VUs/ 150 VUs) are 299.5, 596.4, 887.3, 2928, 4442, and 6393 respectively. Results indicate that the system \"version 2\" that utilizes the proposed approach (enhances saga pattern) achieves better throughput. Although the duration of this experiment is short, the difference between the two versions can still be observed. Figure 13: Load Testing—1 virtual user with 1 min duration. Figure 16: Load Testing—50 virtual users with 1 min duration. Figure 14: Load Testing—10 virtual users with 1 min duration. Figure 15: Load Testing—15 virtual users with 1 min duration. * Throughput Results: 3 min duration  
The results of a 3 min duration are shown in Figures 19-24. The average of the throughput for version 1 with (1 VU/10 VUs/15 VUs/50 VUs/100 VUs/150 VUs) are 889.4, 1779.3, 2526.1, 3485, 4530.5, and 6252, where the means of the throughput for version 2 with the same number of VUs are 890.7, 1780.8, 2669.5, 4182, 6342 and 9128 respectively. Figure 19: Load Testing—1 virtual user with 3 min duration. Figure 17: Load Testing—100 virtual users with 1 min duration. Figure 18: Load Testing—150 virtual users with 1 min duration. Figure 21: Load Testing—15 virtual users with 3 min duration. Figure 22: Load Testing—50 virtual users with 3 min duration. Results show that both approaches are well performed with 1 virtual user and 10 virtual users. However, there is a significant difference when 15 virtual users were configured, as the mean value of the completed orders in version 1 is 2526.1 in 3 min, while version 2 completes on average 2669.5 orders in 3 min. Results show that the system that employs the proposed approach achieves better throughput. Note that, there were no failures that occurred with the two experiments performed. The main factor behind achieving better throughput by the enhanced saga pattern is reducing the hard-disk operations. The proposed approach decreases access to the main database by utilizing the quota cache. To do that, the quota cache, which is implemented by Redis, is applied to the microservices that require validation (i.e., in the workflow above the Warehouse-Service and the Billing-Service). All CRUD operations are shifted to the memory cache server instead of the main database. Accessing the main database occurs only to perform database commit when all transactions are completed successfully. Figure 23: Load Testing—100 virtual users with 3 min duration. Figure 16:0 Load Testing—150 virtual users with 3 min duration. Additionally, the proposed approach applies Redis as an in-memory cache server which plays a significant role in enhancing the performance. Redis is extremely fast as it preserves data in the primary memory (in-memory) instead of the secondary memory. Thus, data access latency is decreased. Moreover, via Redis, the read and write operations are extremely fast which in turn allows the system to deliver sub-millisecond response times that enables more requests to be handled in one second. As a result, increasing the throughput of the system. In contrast, the standard saga pattern stores data in the secondary memory; as a result, read and write operations will be much slower. Thus, it affects the throughput of the system. Moreover, the message queue middleware, implemented by Kafka, plays a key role in improving the overall throughput.