2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件

2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件

888339de9e7a88688b6acb30d33e66cd?s=128

蒼時弦や

August 18, 2019
Tweet

Transcript

  1. Revive a Browser Game Server The Open Unlight Project Photo

    by Artem Labunsky on Unsplash
  2. WEB DEVELOPER GAME DEVELOPER ૵ ࣌ ݭ໵ @elct9620

  3. None
  4. None
  5. Ruby + ActionScript 3

  6. None
  7. Adobe Flash IDE is unavailable!

  8. mxmlc src/Unlight.mxml

  9. Unlight can be compiled by Flex SDK 3.x

  10. Failed because missing files

  11. None
  12. Setup environment takes much time

  13. The source code always become dirty

  14. None
  15. •Always reset client compile environment •Patches / Rework •Customizable Server/Client

    •Adjustable Docker compose configure
  16. None
  17. Secure Remote Password not matched!

  18. None
  19. http://srp.stanford.edu/design.html

  20. http://srp.stanford.edu/design.html Step 1. Client create PublicKey A

  21. http://srp.stanford.edu/design.html Step 2. Server create PublicKey B and send it

    with Salt to user
  22. http://srp.stanford.edu/design.html Step 3~. Compute SessionKey and verify other's Matcher

  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. None
  31. None
  32. None
  33. (/‵Д′)/~ ╧╧

  34. None
  35. None
  36. 24 Core CPU 24G RAM 98K IOPS SSD 300M/100M FTTH

    Sponsor by Poka
  37. Feel "LAG" after 500 online players

  38. None
  39. None
  40. (0.214518s) SELECT * FROM `card_inventories` WHERE ( `card_inventories`. `chara_card_deck_id` =

    2971)
  41. src/model/card_inventory.rb

  42. None
  43. ALTER TABLE card_inventories ADD INDEX chara_card_deck_id (chara_card_deck_id)

  44. None
  45. About 100x faster

  46. None
  47. About 1000 online players without "LAG"

  48. •Adjust Cpuset to fix database on specify cores •Adjust Swappiness

    to prevent use disk •Adjust Full Table Index to cache small table
  49. •Move Database outside Docker •Enable SR-IOV to use physics network

    card •Add partition to database
  50. Estimate capability > 3000 online players

  51. •DAU about 500 online players •Rows grow fast
 Only two

    weeks we have 10M ~ 20M rows •1 Developer
 1 DevOps
 1 Player Support
  52. But how to hosting this game?

  53. Add CloudWatch to analytic online players

  54. Open Unlight's Reword/Customize

  55. None
  56. None
  57. Open Unlight's Allow add customize gems

  58. Tricks to allow Docker add optional files

  59. customize/server/src/authentication.rb

  60. customize/server/src/payment.ru

  61. None
  62. Use Rack to implement API server

  63. None
  64. Extend CLI to serve in docker

  65. None
  66. None
  67. Hosting a game have to support players resolve problems

  68. SmartLook can replay player session to debug

  69. ZenDesk can help players in one central system

  70. •ZenDesk - Player support •SmartLook - Client Debug (for HTML5)

    •Asana - Issue Tracking •AWS - CDN/Monitoring •Discord - Co-working
  71. The HTML5 version?

  72. Flash will be removed at 2020 in Chrome

  73. The Unlight client is Flash

  74. But no one knows CPA will maintenance or not

  75. From TCPSocket to WebSocket

  76. Client Server Packet The TCPSocket send packet directly

  77. Client Server Packet The WebSocket send packet with WebSocket wrapper

    WebSocket
  78. Unlight use EventMachine handles connection

  79. Comment out all EventMachine connection

  80. Implement a Rack middleware with WebSocket gem

  81. Add Rack's .ru and it can be served by Puma

    or Unicorn
  82. We already migrated 90% server to WebSocket

  83. How the client communicates with the server?

  84. It convert data to a command

  85. Each packet should have a header to describe command

  86. JavaScript can create 2 byte struct?

  87. new Int8Array([0x00, 0x03, 0x00, 0x01, 0x00, 0x0a])

  88. (/‵Д′)/~ ╧╧

  89. You can learn how the C programmer think by Unlight's

    Ruby source code
  90. From Golang to WebAssembly

  91. func AuthCmd(name string) []byte { buffer := new(bytes.Buffer) binary.Write(buffer, binary.BigEndian,

    uint16(1)) binary.Write(buffer, binary.BigEndian, []byte(name)) return buffer.Bytes() }
  92. GOOS=js GOARCH=wasm go build -o libul.go

  93. Convert Unlight to HTML5 is possible!

  94. What the next?

  95. Test! Test! Test!

  96. We are trying to learn to host a game server

    as a programmer
  97. And last ...

  98. New security problem is coming!

  99. Thanks