Multi thread game server

4,447 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,447
On SlideShare
0
From Embeds
0
Number of Embeds
2,489
Actions
Shares
0
Downloads
34
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Multi thread game server

  1. 1. Multi Thread Game Server
  2. 2. Contents● Summary & Simple Test● 게임 서버 구조 사례● 문제점 및 개선 방안
  3. 3. Summary[Concurrent Programming with Threads]Rajkumar Buyya
  4. 4. Summary
  5. 5. Simple Test
  6. 6. User.h
  7. 7. The Goal
  8. 8. Single Thread Core A Core B50%
  9. 9. 2 Threads Core A Core B100%
  10. 10. 4 Threads Core A Core B100% Core A Core B
  11. 11. 8 ThreadsCore A Core B
  12. 12. Result600050004000300020001000 0 1 thread 2 threads 4 threads 10 threads
  13. 13. Thread Programming Models [ A Thread Pipe Line ]
  14. 14. Thread Programming Models [ The Peer Model ]
  15. 15. Thread Programming Models[ The Boss and Worker ]
  16. 16. Worker Threads
  17. 17. Worker Threads Worker AWorker B Worker C [User]
  18. 18. 경쟁 상태 Wor ker AWorker B Enemy Thread C Time Wo rker r ker Wo [User]
  19. 19. 10000000 Updating
  20. 20. 경쟁 상태의 문제점● Crash (ntdll?)● 드랍 아템 다수가 획득● 인벤 꼬임● 경험치 이상● ...
  21. 21. Synchronization Worker AWorker B Worker C
  22. 22. Synchronization
  23. 23. Dead LockWorker Enemy Thread
  24. 24. Dead LockWorker A Worker B
  25. 25. 보너스● Self Deadlock (← single thread에서도)● Half Deadlock
  26. 26. ChaosWo rke ad rA my Thre Ene B T im r ker eW Wo or k er
  27. 27. Synchronization Worker A Worker B Worker CEnemy ThreadTime Worker
  28. 28. Synchronization 50 % 70 % 70 %
  29. 29. Synchronization100009000800070006000 with lock5000 no lock4000300020001000 0 1 thread 2 threads 4 threads 10 threads 20 threads 100 threads
  30. 30. Synchronization 50 % ? 70 % ? 70 %
  31. 31. Avoiding Deadlock● Mutual Exclusion● Hold and Lock● No Preemption● Circular Wait
  32. 32. Deadlock Detector● http://www.softwareverify.com/cpp-thread.php
  33. 33. ChaosWo rke ad rA my Thre Ene B T im r ker eW Wo or k er
  34. 34. Logic ThreadLogic Thread ALogic Thread B
  35. 35. Impenetrable Fortress [ɪm|penɪtrəbl]
  36. 36. http://ohyecloudy.com (오종빈)
  37. 37. Impenetable Fortress [ɪm|penɪtrəbl]
  38. 38. 경쟁 상태 er Work Thread UserWo rker Ti m er r r ke Wo
  39. 39. 무관심 상태Tim er W Th or rea ke r d Us er
  40. 40. Impenetrable Fortress [ɪm|penɪtrəbl]
  41. 41. http://ohyecloudy.com (오종빈)
  42. 42. Updatable Runnable +update() +run()Player update() update() update() Zone RoomPlayer Zone Room Room run() Core Zone Room ThreadPlayer Zone RoomPlayer x N
  43. 43. 개념RoomZonePlayerUser
  44. 44. Thread Safe NPCRoom Zone Enemy ProjectileUser Player Script
  45. 45. Thread Safe
  46. 46. t1 Core At2t3 Core Bt4 time 0 33 66 99 132 165 198
  47. 47. t1 Core At2t3 Core Bt4 time 0 33 66 99 132 165 198
  48. 48. t1 Core At2t3 Core Bt4 time 0 33 66 99 132 165 198
  49. 49. Action->Ani
  50. 50. Action->Trigger
  51. 51. RoomThread
  52. 52. Core At1 Core B Core At2 Core B time 0 33 66 99 132 165 198
  53. 53. t1 Core At2 Core Bt3 Core At4 Core B time 0 33 66 99 132 165 198
  54. 54. ㅇㅇ?600050004000300020001000 0 1 thread 2 threads 4 threads 10 threads
  55. 55. GameLogic Zone PlayerRoom Core AThread Room User Core BWorker NetworkThread
  56. 56. L og ic recvBuf Wo rke r
  57. 57. r ke or W t kce Pa 1 g ic Lo 2 g icLo 3 g icLo
  58. 58. User::State
  59. 59. `http://javawork.egloos.com 01/21/2011
  60. 60. http://javawork.egloos.com 01/21/2011
  61. 61. Queue LogicWoker
  62. 62. 끝 http://javawork.egloos.com 01/21/2011

×