31
1 st node.js Korea conference 2012.11.20 MMORPG 에에에 node.js 에 에에에 에에에에 에에 11.20.2012 드드드드드드 [email protected]

Rhea mmo node_for_share

Embed Size (px)

DESCRIPTION

node.js conference in Korea, 2012

Citation preview

Page 1: Rhea mmo node_for_share

1st node.js Korea conference

2012.11.20

MMORPG 에서의 node.js 를 이용한커뮤니티 설계

11.20.2012드래곤플라이

[email protected]

Page 2: Rhea mmo node_for_share

Page 2

Game Developer

98~ 2004~10 NeowizGames 2010~11 네시삼십삼분 2012~ Dragonfly Technical Director

http://www.gamedevforever.com/

About Me

Page 3: Rhea mmo node_for_share

Page 3

Current

Page 4: Rhea mmo node_for_share

Page 4

IRC

Page 5: Rhea mmo node_for_share

Page 5

TCP

Page 6: Rhea mmo node_for_share

Page 6

Tragedy of WIFI & 3G

Page 7: Rhea mmo node_for_share

Page 7

이럴봐엔 차라리 Comet 을 쓰겠어 !

그런데 PC, 스마트폰 같이 되었으면 좋겠네 .

REST

Page 8: Rhea mmo node_for_share

Page 8

아 !!

WebScoket

Page 9: Rhea mmo node_for_share

Page 9

WebSocket

Page 10: Rhea mmo node_for_share

Page 10

Legacy RPC 와 REST API 를 한번에 찍어내고 싶다 .

node.js 로 이렇게 저렇게 하면 될 것 같은데… ?

Mercury Project– Node.js 를 이용한 MMO 커뮤니티 프로젝트– 스마트 디바이스 지원– 한번에 REST, Socket RPC 를 뽑고 싶다 .

Mercury Project

Page 11: Rhea mmo node_for_share

Page 11

node.js

Node.jsCommon Server

C++ or C#IOCP Model

Lua, PythonScript Engine

By C++

Script Engine Based

Contents

C++IOCP Model

V8JavaScript En-

gineBy C++

JavaScript Based

Contents

Page 12: Rhea mmo node_for_share

Page 12

윈도우 서버의 1 차 임무

완벽한 비동기 I/O I/O CompletePort– 게임 서버 개발자 면접 볼 때의 hello world– 가장 쓰레드를 적게 쓰면서 수천개의 소켓 이벤트 획득– I/O 는 비동기 . Send/Recv 는 일단 리턴한다 .

I/O Model

Page 13: Rhea mmo node_for_share

Page 13

IOCP: node.js

Page 14: Rhea mmo node_for_share

Page 14

Boost::Asio vs. Node.js

메모리를 더 차지하나 속력은 만족– V8 의 메모리

Benchmark

총 데이터 (Recv/Send) : 516,000,000/516,000,000

시도 서버 연결 개수 메모리 (Max) CPU(Max) 스레드 서버 총 처리 시간 클라 총 Send 시간 클라 총 Recv 시간

1 차Asio 1000 276,544 25 2 0:55 0:39 0:54

Node 1000 665,004 12 3 1:04 1:02 1:07

2 차Asio 1000 276,496 25 2 0:57 0:40 0:55

Node 1000 664,596 12 4 1:05 1:02 1:06

3 차Asio 1000 276,420 25 2 1:05 0:45 1:02

Node 1000 662,024 13 4 1:16 1:14 1:20

Page 15: Rhea mmo node_for_share

Page 15

채팅서버 성능이 아닌 개발의 편의성 클라이언트 vs. 서버

Socket.IO– Websocket– Smart Phone– Rooms

net module vs. Socket.IO

Page 16: Rhea mmo node_for_share

Page 16

벤치마킹 – CPU E5-2650 2.00Ghz(2 processors)– 4.00 GB– x64 Windwos Server– 153byte Echo test

Socket.IO

접속수 2253 3257 4053

초당 에코성공 1690 2178 2681

초당 에코성공 1741 2174 2612

초당 에코성공 1684 2225 2225

Page 17: Rhea mmo node_for_share

Page 17

Socket.IO 의 친구 Redis 동접의 증가를 고려

Pub/Sub

Page 18: Rhea mmo node_for_share

Page 18

MS Open Tech

Page 19: Rhea mmo node_for_share

Page 19

IOCP: Redis

Page 20: Rhea mmo node_for_share

Page 20

Basic Community System

CMN1(node.js/Sock-

et.IO)

CMN2(node.js/Sock-

et.IO)

CBS(Redis)

Push Gateway(C#)

Page 21: Rhea mmo node_for_share

Page 21

Win32 Client 에서는 어떻게 받지 ?

WebSocket 을 C/C++ 로 구현 RFC 6455 및 Socket.IO 프로토콜 직접

구현

Native Problem

Page 22: Rhea mmo node_for_share

Page 22

Websocket Protcol 애당초 http, ftp, ws 라는 것은 없다

• 서버 접속• Session ID 와 Transport ID 받음• Socket 혹은 XMLHTTPRequest 로 받을 것인지 선택

– XMLHTTPRequest 라면 클라이언트가 계속 폴링– Socket 이라면 새 Transport 연결 획득

• 지정된 시간만큼 핸드쉐이킹• Socket.IO 프로토콜 추가

Websocket Protocol

Page 23: Rhea mmo node_for_share

Page 23

Socket.IO 클라이언트 (js) 가 하는 일

Websocket Protocol

Page 24: Rhea mmo node_for_share

Page 24

Websocket ProtocolGET /mychat HTTP/1.1Host: server.example.comUpgrade: websocketConnection: UpgradeSec-WebSocket-Key: x3JJHMbDL1EzLkh9GB-hXDw==Sec-WebSocket-Protocol: chatSec-WebSocket-Version: 13Origin: http://example.com

Page 25: Rhea mmo node_for_share

Page 25

Websocket Protocol

Page 26: Rhea mmo node_for_share

Page 26

https://github.com/RheaStrike/Caloris– Socket.IO 용 Win32 C++ 클라이언트 라이브러리

Caloris

Page 27: Rhea mmo node_for_share

Page 27

Demo

Page 28: Rhea mmo node_for_share

Page 28

node.js? ASP.NET– 왜죠 ?

REST API

Page 29: Rhea mmo node_for_share

Page 29

I/O 문제 해결 모바일 환경에서 Connection 문제 해결 접근은 쉽다

그러나…– 표현이 된다고 끝이 아니다 .– 빈약한 자료구조 , C++ 에 비해 부족한 함수– 싱글 쓰레드– 아예 C++ 로 플러그인을 만들어 버릴까– HeartBeat 을 안전하게 처리할 새로운 프로토콜 개발

Socket.IO

Page 30: Rhea mmo node_for_share

Page 30

Appropriate Technology

• C++ 은 여전히 최고의 도구• 기술의 진보• 개발자와 사용자를 위한 적정기술• 실험과 대안

Page 31: Rhea mmo node_for_share

Page 31

감사합니다 .

End