Publications-Theses
Article View/Open
Publication Export
-
Google ScholarTM
NCCU Library
Citation Infomation
Related Publications in TAIR
題名 支援 gRPC 微服務的非侵入式分散式交易攔截器模組
An Interceptor Module for Supporting Transparent Distributed Transactions among gRPC-based Microservices作者 施閔雅
Shih, Min-Ya貢獻者 廖峻鋒
Liao, Chun-Feng
施閔雅
Shih, Min-Ya關鍵詞 分散式交易
gRPC
攔截器
微服務
AOP
Distributed Transaction
Interceptor
AOP日期 2025 上傳時間 1-Sep-2025 16:58:20 (UTC+8) 摘要 隨著分散式系統與微服務架構的廣泛應用,橫跨多個服務的分散式交易已成常態,為確保資料正確性與一致性,交易控制機制的重要性日益提升。傳統的二階段提交協定(Two-Phase Commit, 2PC)理論上可確保分散式交易的一致性,然而在實務上,需將交易控制邏輯嵌入各個微服務中,不僅導致交易控制與業務邏輯混合,亦降低系統模組化與可維護性。 目前在企業應用中,對外多以 Web API 進行服務整合,而內部微服務間的溝通則以 gRPC 為主流。針對企業內部微服務通訊需求,本研究提出一套基於 gRPC 的非侵入式分散式交易攔截器架構,將交易控制邏輯封裝為可重用的攔截器模組,有效實現交易控制與業務邏輯的解耦。該架構借鑑切面程式設計導向(Aspect-Oriented Programming, AOP)的核心理念,將分散式交易控制抽象為通用的 gRPC 攔截器,實現橫切關注點與核心業務邏輯的分離。 透過此架構,交易控制邏輯可於執行期間動態插入請求處理流程中,使微服務本身無需感知交易控制即可正常運作,實現交易的透明性與可插拔性。本研究亦設計一系列實驗,從每秒交易量(Transactions Per Second, TPS)、平均延遲(Average Latency)等指標評估本架構之效能表現,並與傳統 2PC 實作進行比較,以驗證本架構在維持資料一致性的同時,能有效兼顧系統效能之可行性與實用性。
With the widespread adoption of distributed systems and microservice architectures, distributed transactions that span multiple services have become the norm. To ensure data correctness and consistency, the importance of transaction control mechanisms is increasingly recognized. Although the traditional Two-Phase Commit (2PC) protocol theoretically ensures consistency in distributed transactions, its practical implementation requires embedding transaction control logic into each microservice. This leads to the intertwining of transaction control and business logic, reducing system modularity and maintainability. In modern enterprise applications, external service integration is typically achieved through Web APIs, while internal microservice communication predominantly relies on gRPC. To address the needs of internal microservice communication, this study proposes a non-intrusive distributed transaction interceptor framework based on gRPC. The framework encapsulates transaction control logic into reusable interceptor modules, effectively decoupling transaction management from business logic. Inspired by the core principles of Aspect-Oriented Programming (AOP), this architecture abstracts distributed transaction control into a general-purpose gRPC interceptor, achieving a clear separation between cross-cutting concerns and core business logic. Through this architecture, transaction control logic can be dynamically injected into the request handling process at runtime, allowing microservices to operate normally without being aware of the underlying transaction control. This achieves transparency in transaction management. This study also designs experiments to evaluate the performance of the proposed framework using metrics such as Transactions Per Second (TPS) and Average Latency. The results are compared with traditional 2PC implementations to validate the feasibility and practicality of this approach in maintaining data consistency while achieving efficient system performance.參考文獻 [1] L. Richardson, M. Amundsen, and S. Ruby, RESTful web APIs: services for a changing world. ” O’Reilly Media, Inc.”, 2013. [2] H. Babal, gRPC microservices in Go. Simon and Schuster, 2023. [3] C. Currier, “Protocol buffers”, in Mobile Forensics–The File Format Handbook: Common File Formats and File Systems Used in Mobile Devices, Springer, 2022, pp. 223–260. [4] S. Arora, A. Bhardwaj, A. Kukkar, S. Kaur, et al., “A comparative analysis of com-munication efficiency: Rest vs. grpc in microservice-based ecosystems”, in 2024 International Conference on Emerging Innovations and Advanced Computing (IN- NOCOMP), IEEE, 2024, pp. 621–626. [5] K. Indrasiri and D. Kuruppu, gRPC: up and running: building cloud native appli- cations with Go and Java for Docker and Kubernetes. O’Reilly Media, 2020. [6] H. Garcia-Molina and K. Salem, “Sagas”, ACM Sigmod Record, vol. 16, no. 3, pp. 249–259, 1987. [7] G. Pardon and C. Pautasso, “Atomic distributed transactions: A restful design”, in Proceedings of the 23rd International Conference on World Wide Web, 2014, pp. 943–948. [8] C. Richardson, Microservices patterns: with examples in Java. Simon and Schuster, 2018. [9] Y. Lee and Y. Liu, “Using refactoring to migrate rest applications to grpc”, in Pro-ceedings of the 2022 ACM Southeast Conference, ser. ACMSE ’22, Virtual Event: Association for Computing Machinery, 2022, pp. 219–223, ISBN: 9781450386975.DOI: 10.1145/3476883.3520220. [Online]. Available: https://doi.org/10.1145/3476883.3520220. [10] M. Bolanowski, K. Żak, A. Paszkiewicz, et al., “Eficiency of rest and grpc real-izing communication tasks in microservice-based ecosystems”, in New Trends in Intelligent Software Methodologies, Tools and Techniques. IOS Press, Sep. 2022. [11] E. F. de Souza Soares, R. Melo Thiago, L. G. Azevedo, M. de Bayser, V. Torres da Silva, and R. F. de G. Cerqueira, “Evaluation of server push technologies for scal- able client-server communication”, in 2018 IEEE Symposium on Service-Oriented System Engineering (SOSE), 2018, pp. 1–10. [12] P. A. Bernstein and E. Newcomer, Principles of Transaction Processing, 2nd. Mor-gan Kaufmann Publishers Inc., 2009, ISBN: 1558606238. [13] Y. Wang and L. Yang, “A distributed transaction performance optimization method”, in 2023 5th International Conference on Electronics and Communication, Network and Computer Technology (ECNCT), 2023, pp. 71–75. DOI: 10.1109/ECNCT59757. 2023.10280971. [14] P. Fan, J. Liu, W. Yin, H. Wang, X. Chen, and H. Sun, “2pc*: A distributed trans- action concurrency control protocol of multi-microservice based on cloud comput- ing platform”, Journal of Cloud Computing, vol. 9, no. 1, p. 40, Jul. 2020, ISSN: 2192-113X. DOI: 10.1186/s13677-020-00183-w. [Online]. Available: https: //doi.org/10.1186/s13677-020-00183-w. [15] H. Saissi, M. Serafini, and N. Suri, “Gyro: A modular scale-out layer for single- server dbmss”, in 2019 38th Symposium on Reliable Distributed Systems (SRDS), 2019, pp. 71–7111. 描述 碩士
國立政治大學
資訊科學系
113753119資料來源 http://thesis.lib.nccu.edu.tw/record/#G0113753119 資料類型 thesis dc.contributor.advisor 廖峻鋒 zh_TW dc.contributor.advisor Liao, Chun-Feng en_US dc.contributor.author (Authors) 施閔雅 zh_TW dc.contributor.author (Authors) Shih, Min-Ya en_US dc.creator (作者) 施閔雅 zh_TW dc.creator (作者) Shih, Min-Ya en_US dc.date (日期) 2025 en_US dc.date.accessioned 1-Sep-2025 16:58:20 (UTC+8) - dc.date.available 1-Sep-2025 16:58:20 (UTC+8) - dc.date.issued (上傳時間) 1-Sep-2025 16:58:20 (UTC+8) - dc.identifier (Other Identifiers) G0113753119 en_US dc.identifier.uri (URI) https://nccur.lib.nccu.edu.tw/handle/140.119/159418 - dc.description (描述) 碩士 zh_TW dc.description (描述) 國立政治大學 zh_TW dc.description (描述) 資訊科學系 zh_TW dc.description (描述) 113753119 zh_TW dc.description.abstract (摘要) 隨著分散式系統與微服務架構的廣泛應用,橫跨多個服務的分散式交易已成常態,為確保資料正確性與一致性,交易控制機制的重要性日益提升。傳統的二階段提交協定(Two-Phase Commit, 2PC)理論上可確保分散式交易的一致性,然而在實務上,需將交易控制邏輯嵌入各個微服務中,不僅導致交易控制與業務邏輯混合,亦降低系統模組化與可維護性。 目前在企業應用中,對外多以 Web API 進行服務整合,而內部微服務間的溝通則以 gRPC 為主流。針對企業內部微服務通訊需求,本研究提出一套基於 gRPC 的非侵入式分散式交易攔截器架構,將交易控制邏輯封裝為可重用的攔截器模組,有效實現交易控制與業務邏輯的解耦。該架構借鑑切面程式設計導向(Aspect-Oriented Programming, AOP)的核心理念,將分散式交易控制抽象為通用的 gRPC 攔截器,實現橫切關注點與核心業務邏輯的分離。 透過此架構,交易控制邏輯可於執行期間動態插入請求處理流程中,使微服務本身無需感知交易控制即可正常運作,實現交易的透明性與可插拔性。本研究亦設計一系列實驗,從每秒交易量(Transactions Per Second, TPS)、平均延遲(Average Latency)等指標評估本架構之效能表現,並與傳統 2PC 實作進行比較,以驗證本架構在維持資料一致性的同時,能有效兼顧系統效能之可行性與實用性。 zh_TW dc.description.abstract (摘要) With the widespread adoption of distributed systems and microservice architectures, distributed transactions that span multiple services have become the norm. To ensure data correctness and consistency, the importance of transaction control mechanisms is increasingly recognized. Although the traditional Two-Phase Commit (2PC) protocol theoretically ensures consistency in distributed transactions, its practical implementation requires embedding transaction control logic into each microservice. This leads to the intertwining of transaction control and business logic, reducing system modularity and maintainability. In modern enterprise applications, external service integration is typically achieved through Web APIs, while internal microservice communication predominantly relies on gRPC. To address the needs of internal microservice communication, this study proposes a non-intrusive distributed transaction interceptor framework based on gRPC. The framework encapsulates transaction control logic into reusable interceptor modules, effectively decoupling transaction management from business logic. Inspired by the core principles of Aspect-Oriented Programming (AOP), this architecture abstracts distributed transaction control into a general-purpose gRPC interceptor, achieving a clear separation between cross-cutting concerns and core business logic. Through this architecture, transaction control logic can be dynamically injected into the request handling process at runtime, allowing microservices to operate normally without being aware of the underlying transaction control. This achieves transparency in transaction management. This study also designs experiments to evaluate the performance of the proposed framework using metrics such as Transactions Per Second (TPS) and Average Latency. The results are compared with traditional 2PC implementations to validate the feasibility and practicality of this approach in maintaining data consistency while achieving efficient system performance. en_US dc.description.tableofcontents 誌謝 i 摘要 ii Abstract iii 目錄 v 圖目錄 vii 表目錄 viii 第一章 緒論 1 1.1 研究背景 1 1.2 研究動機 2 1.3 研究目標 3 第二章 技術背景與相關研究 4 2.1 gRPC 4 2.1.1 gRPC 的主要特性 4 2.1.2 gRPC Interceptor(攔截器) 4 2.1.3 gRPC Context 6 2.2 分散式交易 Distributed Transaction 7 2.3 Two Phase Commit(2PC) 8 2.4 相關研究 9 第三章 系統設計 11 3.1 系統架構 11 3.2 交易協調器 Transaction Coordinator 13 3.2.1 建立交易 14 3.2.2 動態參與者識別機制 14 3.2.3 動態載入微服務客戶端 16 3.3 二階段提交的攔截器模組 Two-Phase Commit Interceptor 17 3.4 執行流程 19 3.4.1 交易成功(Commit)流程 19 3.4.2 交易失敗(Cancel)流程 21 3.5 交易終止處理與容錯機制 23 3.6 與傳統2PC架構之比較 24 第四章 系統實作 26 4.1 動態參與者識別實作 28 4.2 2PC Interceptor 實作 29 4.2.1 Propose 階段 29 4.2.2 Commit 階段 30 4.2.3 Cancel 階段 31 4.2.4 與傳統 2PC 架構之比較 32 第五章 系統評估 34 5.1 Isolation Fault 實驗 35 5.2 交易延遲實驗 37 5.2.1 不同交易量下之比較 37 5.2.2 不同交易間隔下之比較 39 5.3 超時時間(Timeout)實驗 41 第六章 結論與未來研究 43 參考文獻 44 zh_TW dc.format.extent 3231568 bytes - dc.format.mimetype application/pdf - dc.source.uri (資料來源) http://thesis.lib.nccu.edu.tw/record/#G0113753119 en_US dc.subject (關鍵詞) 分散式交易 zh_TW dc.subject (關鍵詞) gRPC zh_TW dc.subject (關鍵詞) 攔截器 zh_TW dc.subject (關鍵詞) 微服務 zh_TW dc.subject (關鍵詞) AOP zh_TW dc.subject (關鍵詞) Distributed Transaction en_US dc.subject (關鍵詞) Interceptor en_US dc.subject (關鍵詞) AOP en_US dc.title (題名) 支援 gRPC 微服務的非侵入式分散式交易攔截器模組 zh_TW dc.title (題名) An Interceptor Module for Supporting Transparent Distributed Transactions among gRPC-based Microservices en_US dc.type (資料類型) thesis en_US dc.relation.reference (參考文獻) [1] L. Richardson, M. Amundsen, and S. Ruby, RESTful web APIs: services for a changing world. ” O’Reilly Media, Inc.”, 2013. [2] H. Babal, gRPC microservices in Go. Simon and Schuster, 2023. [3] C. Currier, “Protocol buffers”, in Mobile Forensics–The File Format Handbook: Common File Formats and File Systems Used in Mobile Devices, Springer, 2022, pp. 223–260. [4] S. Arora, A. Bhardwaj, A. Kukkar, S. Kaur, et al., “A comparative analysis of com-munication efficiency: Rest vs. grpc in microservice-based ecosystems”, in 2024 International Conference on Emerging Innovations and Advanced Computing (IN- NOCOMP), IEEE, 2024, pp. 621–626. [5] K. Indrasiri and D. Kuruppu, gRPC: up and running: building cloud native appli- cations with Go and Java for Docker and Kubernetes. O’Reilly Media, 2020. [6] H. Garcia-Molina and K. Salem, “Sagas”, ACM Sigmod Record, vol. 16, no. 3, pp. 249–259, 1987. [7] G. Pardon and C. Pautasso, “Atomic distributed transactions: A restful design”, in Proceedings of the 23rd International Conference on World Wide Web, 2014, pp. 943–948. [8] C. Richardson, Microservices patterns: with examples in Java. Simon and Schuster, 2018. [9] Y. Lee and Y. Liu, “Using refactoring to migrate rest applications to grpc”, in Pro-ceedings of the 2022 ACM Southeast Conference, ser. ACMSE ’22, Virtual Event: Association for Computing Machinery, 2022, pp. 219–223, ISBN: 9781450386975.DOI: 10.1145/3476883.3520220. [Online]. Available: https://doi.org/10.1145/3476883.3520220. [10] M. Bolanowski, K. Żak, A. Paszkiewicz, et al., “Eficiency of rest and grpc real-izing communication tasks in microservice-based ecosystems”, in New Trends in Intelligent Software Methodologies, Tools and Techniques. IOS Press, Sep. 2022. [11] E. F. de Souza Soares, R. Melo Thiago, L. G. Azevedo, M. de Bayser, V. Torres da Silva, and R. F. de G. Cerqueira, “Evaluation of server push technologies for scal- able client-server communication”, in 2018 IEEE Symposium on Service-Oriented System Engineering (SOSE), 2018, pp. 1–10. [12] P. A. Bernstein and E. Newcomer, Principles of Transaction Processing, 2nd. Mor-gan Kaufmann Publishers Inc., 2009, ISBN: 1558606238. [13] Y. Wang and L. Yang, “A distributed transaction performance optimization method”, in 2023 5th International Conference on Electronics and Communication, Network and Computer Technology (ECNCT), 2023, pp. 71–75. DOI: 10.1109/ECNCT59757. 2023.10280971. [14] P. Fan, J. Liu, W. Yin, H. Wang, X. Chen, and H. Sun, “2pc*: A distributed trans- action concurrency control protocol of multi-microservice based on cloud comput- ing platform”, Journal of Cloud Computing, vol. 9, no. 1, p. 40, Jul. 2020, ISSN: 2192-113X. DOI: 10.1186/s13677-020-00183-w. [Online]. Available: https: //doi.org/10.1186/s13677-020-00183-w. [15] H. Saissi, M. Serafini, and N. Suri, “Gyro: A modular scale-out layer for single- server dbmss”, in 2019 38th Symposium on Reliable Distributed Systems (SRDS), 2019, pp. 71–7111. zh_TW
