Basic Search / Detailed Display

Author: 張祖浩
Tsu-Hao Chang
Thesis Title: 記憶體資料庫與訊息佇列應用於 高並發遊戲伺服器架構之研究
A Study on High Concurrent Requests Game Server using In-Memory Database and Message Queue
Advisor: 戴文凱
Wen-Kai Tai
Committee: 沈上翔
Shan-Hsiang Shen
黃冠寰
Gwan-Hwan Hwang
Degree: 碩士
Master
Department: 電資學院 - 資訊工程系
Department of Computer Science and Information Engineering
Thesis Publication Year: 2021
Graduation Academic Year: 109
Language: 中文
Pages: 36
Keywords (in Chinese): 遊戲伺服器伺服器架構記憶體資料庫訊息佇列
Keywords (in other languages): Game Server, Server Architecture, In-memory Database, Message Queue
Reference times: Clicks: 253Downloads: 9
Share:
School Collection Retrieve National Library Collection Retrieve Error Report
  • 近年網際網路相關技術的蓬勃發展,帶動了許多網路遊戲興起。隨著玩家人數的增多,伺服器需要處理的請求量也越來越高,導致遊戲開發商在除了提供遊戲本身的體驗,還需花大量時間設計並建構後端伺服器架構部份,以確保玩家的遊戲體驗流暢以及服務穩定。

    在本論文中,我們將提出一種伺服器架構,使遊戲伺服器開發者能夠快速串接,並在串接後即具備有高併發、高可用、低延遲的下單系統,並且保證一定的資料一致性及耐久性,並且利用介面定義語言Protocol Buffers與gRPC提供串接介面,使遊戲開發者能夠著重於改善遊戲本身的表現以及遊玩體驗,而不須花費大量心力於後續的資料處理及伺服器建置。之後我們將提出數項績效指標,並依據各個績效指標設計測試流程,評估此系統在各方面之表現。

    最後,本論文列出了數項績效指標,並成功建置一伺服器架構,針對性能、可用性、資料一致性與耐久性等各方面做績效指標之相關測試,並建置了一個單純利用資料庫交易的伺服器架構作為Baseline,比較其兩者之差異。

    關鍵字:遊戲伺服器、伺服器架構、記憶體資料庫、訊息佇列


    The booming development of Internet-related technologies in recent years has led to the rise of many web-based games. As the number of players increases, the amount of requests that servers need to handle is also getting higher and higher. As a result, game developers need to spend a lot of time designing and constructing the back-end server architecture in addition to providing the game experience itself to ensure a smooth gaming experience and stable service for players.

    In this paper, we will propose a server architecture that enables game server developers to quickly connect and have a high concurrency, high availability, and low latency betting system, and ensure high-level data consistency and durability. This allows game developers to focus on improving the performance and experience of the game itself, rather than spending a lot of effort on data processing or server setup. After that, we will propose several key performance indicators and design some testing processes to evaluate the system's performance in various aspects based on each indicator.

    Finally, this paper lists several key performance indicators and successfully builds a server architecture, and test the performance indicators in terms of performance, availability, data consistency and durability.

    Key words: Game Server, Server Architecture, In-memory Database, Message Queue

    論文摘要. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . II 誌謝. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . III 目錄. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IV 圖目錄. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . VII 表目錄. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . VIII 資料結構目錄. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IX 1 緒論. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 研究背景與動機. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 研究目標. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 研究方法概述. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 研究貢獻. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.5 本論文之章節架構. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 相關工作. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1 遊戲伺服器相關服務. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 記憶體資料庫. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3 訊息佇列. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 伺服器架構相關研究. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.5 Docker 與Kubernetes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 研究方法. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1 關鍵績效指標(Key Performance Indicator) . . . . . . . . . . . . . . . . 10 IV 3.1.1 吞吐量(Throughput) . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.2 延遲(Latency) . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.3 錯誤率(Error Rate) . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.4 並發請求數(Concurrent Requests) . . . . . . . . . . . . . . . . . 11 3.1.5 並發連線數(Concurrent Connections) . . . . . . . . . . . . . . . 11 3.1.6 可用性(Availability) . . . . . . . . . . . . . . . . . . . . . . . . 11 3.1.7 一致性(Consistency) . . . . . . . . . . . . . . . . . . . . . . . . 11 3.1.8 耐久性(Durability) . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 系統架構設計. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.1 遊戲伺服器(Game Server) . . . . . . . . . . . . . . . . . . . . . 12 3.2.2 認證伺服器(Auth Server) . . . . . . . . . . . . . . . . . . . . . 12 3.2.3 交易伺服器(Transaction Server, Tx Server) . . . . . . . . . . . . 12 3.2.4 Redis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.5 Apache Kafka . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2.6 Asynchronous Worker (Async Worker) . . . . . . . . . . . . . . 13 3.2.7 MongoDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.3 系統串接介面. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.4 系統實作架構. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5 系統詳細流程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5.1 登入流程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5.2 下注流程. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.5.3 批次插入/非同步更新流程. . . . . . . . . . . . . . . . . . . . . 17 V 3.6 測試與評估方法. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.6.1 性能面測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.6.2 可用性測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.6.3 一致性測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.6.4 Baseline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4 實驗結果與分析. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.1 程式實作與實驗環境建立. . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.2 性能面測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.2.1 並發連線數測試. . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.2.2 並發請求數測試. . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.3 一致性測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.4 可用性測試. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.5 耐久性評估. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 5 結論與未來工作. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 5.1 結論. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 5.2 未來工作. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 參考文獻. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    [1] Google Inc., “Google Cloud Game Servers.” https://cloud.google.com/game-servers/. Accessed: 20210729.
    [2] Google Inc., “Agones.” https://agones.dev/site/. Accessed: 20210729.
    [3] Google Inc., “Kubernetes.” https://kubernetes.io/. Accessed: 20210729.
    [4] Amazon.com, Inc., “Amazon Gamelift.” https://aws.amazon.com/tw/gamelift/. Accessed: 20210729.
    [5] Game Server Services, “Game server services.” https://gs2.io/company.html. Accessed: 20210729.
    [6] Google Inc., “Protocol Buffers.” https://developers.google.com/protocol-buffers. Accessed: 20210721.
    [7] Dropbox, Inc., Google Inc., Skyscanner Ltd. and WeWork Companies Inc., “grpc.” https://grpc.io/. Accessed: 20210721.
    [8] Zynga Inc., “FarmVille.” https://www.facebook.com/FarmVille. Accessed: 20210729.
    [9] Danga Interactive, “Memcached.” https://www.memcached.org/. Accessed: 20210729.
    [10] redislabs, “Redis.” https://redis.io. Accessed: 20210721.
    [11] N. Bronson, Z. Amsden, G. Cabrera, P. Chakka, P. Dimov, H. Ding, J. Ferris, A. Giardullo, S. Kulkarni, H. C. Li, M. Marchukov, D. Petrov, L. Puzar, Y. J. Song, and V. Venkataramani, “TAO: facebook’s distributed data store for the social graph,” in 2013 USENIX Annual Technical Conference, San Jose, CA, USA, June 2628, 2013 (A. Birrell and E. G. Sirer, eds.), pp. 49–60, USENIX Association, 2013.
    [12] Lua, “The programming language lua.” https://www.lua.org/. Accessed: 20210721.
    [13] Pivotal, “Rabbitmq.” https://www.rabbitmq.com/. Accessed: 20210729.
    [14] Synadia Communications, Inc., “Nats.” https://nats.io/. Accessed: 20210729.
    [15] Apache Software Foundation, “Apache kafka.” https://kafka.apache.org/. Accessed: 20210721.
    [16] Q. Fan and Q. Wang, “Performance comparison of web servers with different architectures: A case study using high concurrency workload,” in 2015 Third IEEE Workshop on Hot Topics in Web Systems and Technologies (HotWeb), pp. 37–42, 2015.
    [17] S. S. Prakash and B. C. Kovoor, “Performance optimisation of web applications using inmemory caching and asynchronous job queues,” in 2016 International Conference on Inventive Computation Technologies (ICICT), vol. 3, pp. 1–5, 2016.
    [18] A. Cansever, U. Özel, Önsel Akın, A. Özmez, F. F. Gönen, G. Altuntas Sen, S. Kalaycı, and U. Çolak, “A distributed message queuing mechanism for a mailing system with high performance and high availability,” in 2018 6th International Conference on Control Engineering Information Technology (CEIT), pp. 1–5, 2018.
    [19] Docker Inc., “Docker.” https://www.docker.com/. Accessed: 20210729.
    [20] W. Felter, A. Ferreira, R. Rajamony, and J. Rubio, “An updated performance comparison of virtual machines and linux containers,” in 2015 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS), pp. 171–172, 2015.
    [21] P. Emmerich, D. Raumer, F. Wohlfart, and G. Carle, “A study of network stack latency for game servers,” in Proceedings of the 13th Annual Workshop on Network and Systems Support for Games, NetGames ’14, IEEE Press, 2014.
    [22] R. Morabito, J. Kjällman, and M. Komu, “Hypervisors vs. lightweight virtualization: A performance comparison,” in 2015 IEEE International Conference on Cloud Engineering, pp. 386–393, 2015.
    [23] MongoDB Inc., “Mongodb.” https://www.mongodb.com/. Accessed: 20210721.
    [24] M. Jones, J. Bradley, and N. Sakimura, “JSON Web Token (JWT).” RFC 7519, May 2015.
    [25] Bojand, “ghz, grpc benchmarking and load testing tool.” https://ghz.sh/. Accessed: 20210721.

    QR CODE