Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件
Search
蒼時弦や
August 18, 2019
Programming
1
640
2019 - COSCUP - 復活一個 Browser Game - Unlight 開源事件
蒼時弦や
August 18, 2019
Tweet
Share
More Decks by 蒼時弦や
See All by 蒼時弦や
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
62
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
320
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
520
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
260
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
380
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
410
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
210
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
230
2021 - RubyKaigi - It is time to build your mruby VM on the microcontroller?
elct9620
0
190
Other Decks in Programming
See All in Programming
HMSコンペ 11th Solution (team : kansai-kaggler)
t88
1
680
Javaの現状2024夏 / Java current status 2024 summer
kishida
4
1.4k
大規模マルチテナントを解決するYugabyteDBという選択肢
nnaka2992
1
250
Webエディタライブラリ 「CodeMirror」から学ぶ Webアプリ開発のテクニック
ryosukeigarashi
0
250
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
260
CSC307 Lecture 14
javiergs
PRO
0
220
APIのない大学ログインWebサービスをWKWebViewとJavaScriptでアプリ化した話
akidon0000
1
330
DMMプラットフォームにおけるTiDBの導入から運用まで
pospome
7
3k
Findy - エンジニア向け会社紹介 / Findy Letter for Engineers
findyinc
2
81k
GraphQL はいいぞ! ~Laravel で学ぶ GraphQL 入門~
azuki
1
160
20240706_CDKConf
takuyay0ne
0
1.2k
Clean Architecture by TypeScript & NestJS
ryounasso
0
150
Featured
See All Featured
The Invisible Customer
myddelton
117
13k
Optimizing for Happiness
mojombo
373
69k
The Art of Programming - Codeland 2020
erikaheidi
48
13k
WebSockets: Embracing the real-time Web
robhawkes
59
7.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
245
1.2M
Mobile First: as difficult as doing things right
swwweet
219
8.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
149
45k
How To Stay Up To Date on Web Technology
chriscoyier
784
250k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
17
1.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
357
18k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
The Cult of Friendly URLs
andyhume
75
5.9k
Transcript
Revive a Browser Game Server The Open Unlight Project Photo
by Artem Labunsky on Unsplash
WEB DEVELOPER GAME DEVELOPER ࣌ ݭ @elct9620
None
None
Ruby + ActionScript 3
None
Adobe Flash IDE is unavailable!
mxmlc src/Unlight.mxml
Unlight can be compiled by Flex SDK 3.x
Failed because missing files
None
Setup environment takes much time
The source code always become dirty
None
•Always reset client compile environment •Patches / Rework •Customizable Server/Client
•Adjustable Docker compose configure
None
Secure Remote Password not matched!
None
http://srp.stanford.edu/design.html
http://srp.stanford.edu/design.html Step 1. Client create PublicKey A
http://srp.stanford.edu/design.html Step 2. Server create PublicKey B and send it
with Salt to user
http://srp.stanford.edu/design.html Step 3~. Compute SessionKey and verify other's Matcher
None
None
None
None
None
None
None
None
None
None
(/‵Д′)/~ ╧╧
None
None
24 Core CPU 24G RAM 98K IOPS SSD 300M/100M FTTH
Sponsor by Poka
Feel "LAG" after 500 online players
None
None
(0.214518s) SELECT * FROM `card_inventories` WHERE ( `card_inventories`. `chara_card_deck_id` =
2971)
src/model/card_inventory.rb
None
ALTER TABLE card_inventories ADD INDEX chara_card_deck_id (chara_card_deck_id)
None
About 100x faster
None
About 1000 online players without "LAG"
•Adjust Cpuset to fix database on specify cores •Adjust Swappiness
to prevent use disk •Adjust Full Table Index to cache small table
•Move Database outside Docker •Enable SR-IOV to use physics network
card •Add partition to database
Estimate capability > 3000 online players
•DAU about 500 online players •Rows grow fast Only two
weeks we have 10M ~ 20M rows •1 Developer 1 DevOps 1 Player Support
But how to hosting this game?
Add CloudWatch to analytic online players
Open Unlight's Reword/Customize
None
None
Open Unlight's Allow add customize gems
Tricks to allow Docker add optional files
customize/server/src/authentication.rb
customize/server/src/payment.ru
None
Use Rack to implement API server
None
Extend CLI to serve in docker
None
None
Hosting a game have to support players resolve problems
SmartLook can replay player session to debug
ZenDesk can help players in one central system
•ZenDesk - Player support •SmartLook - Client Debug (for HTML5)
•Asana - Issue Tracking •AWS - CDN/Monitoring •Discord - Co-working
The HTML5 version?
Flash will be removed at 2020 in Chrome
The Unlight client is Flash
But no one knows CPA will maintenance or not
From TCPSocket to WebSocket
Client Server Packet The TCPSocket send packet directly
Client Server Packet The WebSocket send packet with WebSocket wrapper
WebSocket
Unlight use EventMachine handles connection
Comment out all EventMachine connection
Implement a Rack middleware with WebSocket gem
Add Rack's .ru and it can be served by Puma
or Unicorn
We already migrated 90% server to WebSocket
How the client communicates with the server?
It convert data to a command
Each packet should have a header to describe command
JavaScript can create 2 byte struct?
new Int8Array([0x00, 0x03, 0x00, 0x01, 0x00, 0x0a])
(/‵Д′)/~ ╧╧
You can learn how the C programmer think by Unlight's
Ruby source code
From Golang to WebAssembly
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() }
GOOS=js GOARCH=wasm go build -o libul.go
Convert Unlight to HTML5 is possible!
What the next?
Test! Test! Test!
We are trying to learn to host a game server
as a programmer
And last ...
New security problem is coming!
Thanks