본문 바로가기
IT 둘러보기

오딘: 발할라 라이징 MMORPG의 성능 최적화 사례 공유

by 날고싶은커피향 2023. 10. 23.

  • 1. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. 김문권 팀장 Service Development Team Manager 라이온하트 스튜디오 오딘: 발할라 라이징 MMORPG의 성능 최적화 사례 공유 GAMES ON AWS 2022 - TRACK03 윤종근 팀장 Technical Project Manager 카카오게임즈
  • 2. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. Intro : 회사 및 게임 소개 2
  • 3. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 글로벌 게임 서비스 퍼블리셔 PC 온라인 및 모바일게임 등의 멀티 플랫폼 서비스 공급자 - 오딘 : 발할라라이징 - 우마무스메 : 프리티더비 - 카카오 배틀그라운드 - 디스테라 on steam - 이터널리턴 on steam - 패스오브엑자일 회사 소개 온라인 / 모바일 게임 개발 - 오딘 : 발할라라이징 - ProjectC (2023년 4Q 예정) - ProjectS (2024년 예정) - ProjectQ (2025년 예정) 3
  • 4. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 4 [오딘 : 발할라 라이징]은, 모바일 및 PC 크로스 플랫폼을 지원하는 진보된 차세대 MMORPG로 압도적인 퀄리티와 함께 북유럽 감성을 경험할 수 있습니다. 북유럽 신화 속 방대한 스케일의 오픈월드 MMORPG로 자유도 높은 탐험과 탄탄한 시나리오, 캐릭터 간의 유기적인 역할을 통해 정통 MMORPG를 계승하였습니다. - 사전예약 400만명 - 구글 플레이스토어, 애플 앱스토어 양대 마켓 매출 1위 달성! - 2021 대한민국 게임대상 수상 오딘 : 발할라 라이징 (Odin: Valhalla Rising)
  • 5. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 5
  • 6. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 숫자로 보는 오딘 6 주1) Packets Per Second : 초당 패킷 처리 수 81 개 월드 서버 6개 대륙 • 심리스 오픈월드 맵 • 월드 / 파티 / 정예 던전 • 통합 월드 서버 +400 만 사전예약 +5천억 런칭 180일 6천만 PPS 주1) 대만 22년 03월 런칭 일본 23년 런칭 예정 추가 런칭 예정 게임 월드 플레이어 글로벌 런칭
  • 7. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. 오딘 게임 서버의 특징과 성과 7
  • 8. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. MMORPG 게임서버의 역할 데이터 – 아이템 정보, 유저 정보, 서버 상태, 보스 정보 등 네트워크 – 접속, 클라이언트 연결 유지, 빠른 재 연결, 중복 접속 처리 등 동기화 – HP, 데미지, 이동 상태, 상태이상 등 인공지능(AI) – NPC와의 대화, 몬스터 행동, 공격 패턴, 용병, 방치모드 등 Anti cheat – 스탯 조작, 자원 조작, 아이템 복사, 어뷰징 등 확률 – 공격 성공률, 스킬 발동 확률, 아이템 획득 확률 등 8
  • 9. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 오딘 게임 서버의 특징 9 • 대규모 전쟁 MMORPG • Server : C++ 기반의 TCP/IP 서버 • Client : Unreal Engine 4 • Client Server 간의 빠르고 일정한 반응 속도 필요 • 유저 간의 상대경쟁(PvP) • 다수의 유저가 한정된 공간에서의 경쟁 Clients iOS/Android PC Server C++ CPP
  • 10. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 오딘 게임 서버의 특징 10 • Database는 데이터 처리용이 아닌 데이터 백업용 • 데이터 1차 저장/처리 : 서버 메모리 • 데이터 2차 저장/처리 : 데이터베이스 • 일정 주기(n초) 간격으로 1차에서 2차 저장소로 저장 • 연결 지향형 TCP/IP Stateful 서버 • 유저의 상태 데이터를 서버 메모리에 저장/처리 • 서버 재 기동시에 필요한 데이터를 서버의 메모리에 적재 • 메모리 사용량과 빠른 응답 속도의 Trade off
  • 11. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 오딘 게임 서버의 특징 Network I/O Thread Data I/O Thread Main Logic Thread 11
  • 12. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 12 싱글 로직 스레드 멀티 로직 스레드 Multi Core 활용도 상대적으로 낮음 (단일 코어 성능에 의존) 높음 (모든 코어 활용) 디버깅 난이도 쉬움 매우 어려움 서버 안정성 유지 쉬움 어려움 개발자 적응 속도 빠름 느림 하드웨어 비용 상대적으로 낮음 높음 Cloud 적합성 낮음 높음 싱글 로직 스레드 vs 멀티 로직 스레드
  • 13. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 싱글 로직 스레드를 택한 이유 13 • 개발 속도와 디버깅 편의성 • 유지보수의 단순화로 안정적 코드 생산 • 낮은 서버 크래시율을 기반으로 안정적인 서비스 제공 • 장기적인 Live 서비스에서도 일관성을 유지 GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates.
  • 14. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 소규모의 서버 개발 팀 14 GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates.
  • 15. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 다양한 시스템/컨텐츠 개발 • 네트워크 시스템 • 채팅 시스템 • 액티브 스킬 시스템 • 패시브 스킬 시스템 • 클래스 시스템 • 아바타 시스템 • 탈것 시스템 • 맵 시스템 • 전투 시스템 • 퀘스트/서브 퀘스트 시스템 • 상점 시스템 • 거래소 시스템 • 파티 시스템 • 길드 시스템 • 경매 시스템 • PK 시스템 • 펫 시스템 • 계정 연동 시스템 • 친구 시스템 • 수집 시스템 • 룬 시스템 • 제작 시스템 • 우편 시스템 • 출석 시스템 • 이벤트 시스템 • 인벤토리 시스템 • 채집 시스템 • 보물 찾기 시스템 • 랭킹 시스템 • 대기열 시스템 • 몬스터 AI • 방치모드 AI • … 15
  • 16. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 대규모 보스 레이드 대규모 보스 레이드 16 GAMES ON AWS 2022 16
  • 17. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 낮은 서버 크래시 비율 0 10 20 30 40 50 60 70 80 Launching +1 months +2 +3 +4 +5 +6 +7 +8 Odin A Game B Game 0 20 40 60 80 100 120 Odin A Game B Game [타 MMORPG 게임과의 서버 크래시 현황 비교] 17
  • 18. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. 아키텍처 18
  • 19. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 아키텍처 19 AWS Cloud Clients iOS/Android Private subnet Login Login Public subnet Game World #n Private subnet Gateway Chat Game server Game Log PC Ranking Database
  • 20. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 게이트 서버 20 • 대규모 전쟁 MMORPG의 Broadcasting 고민 • Main Logic을 관리 하는 Game Server • Broadcasting을 전담하는 Gateway Server • 부하에 따라 n대를 증설 할 수 있는 구조 • 한정된 맵에서 수천명이 보스 레이드 가능 • 게임서버의 직접적인 접근을 막아서 보안성 향상 • 부드러운 서버 간의 이동 지원 Gateway Server
  • 21. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 게임 서버 21 Gateway Server Aurora • Gateway Server N대 : Game Server M대의 구조 • 게임서버의 EC2는 단일 코어 성능이 중요 • Game Main Logic • Single thread • Database I/O , Network I/O, File I/O 등 • multi thread • Game Server는 컨텐츠에 따라 Scale-out이 가능 Game Serer
  • 22. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 데이터베이스 22 Database • 요구 사항 • 빠른 반응속도 • 높은 처리량 • MMORPG 특성상 많은 데이터를 처리 • 단일 데이터베이스 처리량 ⎻ write 7,800 IOPS ⎻ write I/O(throughput) : 80GB/min ⎻ QPS* : 65,000 • 고가용성 (High Availability) * Query per Second
  • 23. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. 게임서버 on AWS 23
  • 24. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 서비스 장비의 고려사항 • On-premise vs Cloud 오딘 게임서버의 중요 고려 사항 우위 CPU Single Core Clock Speed On-Premise Fast Scalability Cloud High Availability Global Game Service (Infra) 24
  • 25. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 게임 서버 on Amazon EC2 고려사항 • AWS Cloud 환경 선택 • Scalability/HA/Global Infra 의 장점 • AWS EC2 type • AWS EC2 type 중 Single Core 성능이 가장 높은 장비 • 런칭 전 : z1d type • 런칭 후 교체 : m5zn type  10% 성능향상 • AWS EC2 size2세대 인텔 제온 스케일러블 프로세서 • EC2 size에 따른 Single Core 성능의 차이 • EC2는 2개의 물리적인 CPU로 구성 • 1개의 CPU Slot 온전히 가용하려면 해당 장비 최대 스펙의 절반 이상이 필요 (ex: z1d.6xlarge) 25 2세대 인텔 제온 스케일러블 프로세서 최대 4.5GHz 올 코어 터보 주파수 인텔 제온 스케일러블 프로세서 최대 4.0GHz 올 코어 주파수
  • 26. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 게임 서버 on Amazon EC2 고려사항 • CPU type에 따른 단일 코어 성능비교 EC2 type c5.12xlarge z1d.6xlarge m5zn.6xlarge Xeon Gold 6250 Performance 75 80 90 100 26
  • 27. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 서비스 장비의 고려사항 • EC2 size에 따른 단일 코어 성능 EC2 type z1d.large z1d.xlarge z1d.2xlarge z1d.3xlarge z1d.6xlarge z1d.12xlarge z1d.metal Performance 85 86 88 92 98 100 100 27
  • 28. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. Windows 최적화 • AWS EC2 장비에서 Windows 서버를 사용할 때 성능 튜닝 포인트 • 네트워크 최적화 • Elastic Network Adaptor(ENA) 최신 드라이버 버전 유지 • AWS 에서 제공하는 Windows AMI는 최신 버전의 ENA 드라이버 설치 28
  • 29. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. Windows 최적화 • AWS EC2 장비에서 Windows 서버를 사용할 때 성능 튜닝 포인트 • 네트워크 최적화 (계속) • ENA 드라이버의 고급 설정에서 8192 로 조정 (기본값 1024) Set-NetAdapterAdvancedProperty -Name "Ethernet*" -RegistryKeyword "*ReceiveBuffers" -RegistryValue 8192 29
  • 30. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. Windows 최적화 • AWS EC2 장비에서 Windows 서버를 사용할 때 성능 튜닝 포인트 • 하이퍼 스레딩 비활성화 • 서버 생성 시에만 비활성화 가능 • RSS CPU Affinity 설정 • Windows AMI는 기본적으로 RSS가 활성화되어 제공 • 하이퍼스레딩 활성화 기준, CPU 0 번을 제외 (병목 최소화) Set-NetAdapterRss -name (Get-NetAdapter | Where-Object {$_.InterfaceDescription -like '*Elastic*'}).Name -Baseprocessorgroup 0 -BaseProcessorNumber 1 30
  • 31. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. Windows 고려 사항 [z1d.6xlarge] [z1d.metal] • AWS EC2 장비에서 Windows의 작업 관리자에서 표시되는 CPU 사용률은 정확하지 않습니다. 31
  • 32. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 데이터베이스 고려사항 : Latency • Game Server의 Database Connection Thread pool Count • Database의 처리량(Throughput)보다 반응속도(Latency)가 중요 • 적절한 Database Connection Thread 수가 필요 • Context Switching Issue 32
  • 33. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 데이터베이스 고려사항 • AWS RDS Type의 특징 • z1d/m5zn의 고성능의 CPU 사용이 불가능 • CPU의 단일 코어의 성능이 상대적으로 낮아 단일 Thread당 처리량이 낮음. • 대신 Core 숫자가 고성능의 CPU 장비보다 훨씬 많아서 연결이 많아 질수록 더 높은 성능을 낼 수 있음. • AWS RDS size • Size에 따라 처리량의 차이가 있음 • EC2와 동일하게 1개의 CPU Slot 온전히 가용하려면 절반의 크기인 12xlarge 이상 사용이 필요 33
  • 34. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 데이터베이스 고려사항 • RDS for MySQL VS RDS Aurora • 동일한 CPU size 일 때 Aurora 의 반응속도가 30~40% 빠름 0 2 4 6 8 10 12 14 16 18 20 1 2 4 8 16 32 64 rds.r5.12xlarge aurora.r5.12xlarge [ Database Latency(ms) ] 34
  • 35. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 데이터베이스 고려사항 • Aurora R5 VS Aurora R6g (Graviton CPU) • Connection 증가 시 R6g가 10% 정도 더 높은 처리 성능 • 런칭 초기 : R6g의 DB maintenance가 잦아 안정적인 서비스 운영을 위해 -> R5로 런칭 • 서비스 1년 후 : R6g 장비의 안정화 된 이후 DB 장비의 type 교체 [ Database Latency(ms) ] 0 2 4 6 8 10 12 1 2 4 8 16 32 64 aurora.r5.12xlarge aurora.r6g.12xlarge [ QPS ] 0 20000 40000 60000 80000 100000 120000 140000 160000 180000 1 Thread 2 Thread 4 Thread 8 Thread 16 Thread 32 Thread 64 Thread aurora.r5.12xlarge aurora.r6g.12xlarge 35
  • 36. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. © 2022, Amazon Web Services, Inc. or its affiliates. 퍼블리싱 팁 36
  • 37. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 운영 팁 : 모니터링 Game Service Log Infra Resource Game Process Status • Process health check • Zombie process check • Process auto recovery • CloudWatch • Zabbix • Promethus • Grafana • OpenSearch Service (ELK stack) 37
  • 38. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 운영 팁 : 데이터 분석 Glue Data Catalog EMR Redshift MSTR Kinesis Data Streams Kinesis Data Firehose OpenSearch Service Kibana Real-time Batch Athena Game Log 분석 소비 S3 (데이터레이크) 수집 카탈로그 S3 (데이터레이크) Data Analyst 세부 내용은 Games on AWS 2022 [트랙 4 : 데이터 분석 및 AI/ML] 의 대용량 데이터레이크 마이그레이션 사례 참고 38
  • 39. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 배포 팁 : 초기 배포 파이프 라인 구성 - relay server & rsync rsync option : compress , bwlimit unblock 39
  • 40. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 초기 배포 파이프 라인 : 문제점 • 제한적인 CI/CD 작업 시간 • 한번에 배포 되어야 하는 서버 바이너리 : 500GB • 서비스 규모의 계속된 확장 • 서버 수의 증가  CD 시간의 증가 • 대용량 파일을 빠르게 서버에 배포하기 위한 고민 40
  • 41. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 개선된 배포 파이프 라인 - Amazon S3 기반의 배포로 구조 변경 aws s3 cli option : max_concurrent_requests = 200 multipart_chunksize = 32MB max_bandwidth = 500MB/s 41
  • 42. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 배포 성능 비교 - 각 배포 파이프 라인의 성능 비교 rsync S3 Performance 18 min 6 min 0 2 4 6 8 10 12 14 16 18 20 s3 rsync Performance 42
  • 43. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. 마치며 43 • [오딘 : 발할라라이징] 의 게임서버 개발 구조 • multi i/o thread + single logic thread • 낮은 서버 크래시율을 기반으로 안정적으로 서비스 • 장기적인 Live 서비스에서도 일관성을 유지 • [오딘 : 발할라라이징] 의 게임서버 구조에 적합한 인프라 환경 구성 • EC2 – 고성능 CPU • Aurora - 빠른 반응속도, 많은 처리량 • 발표 드린 내용은 [오딘 : 발할라라이징] 에 특화 게임 개발 및 서비스를 하실 때, AWS 환경에서 직접 운영 환경에 준하는 테스트 필요 • 장애 테스트, 성능 테스트 , 증설/축소 계획에 따른 확장성 테스트
  • 44. GAMES ON AWS 2022 © 2022, Amazon Web Services, Inc. or its affiliates. Thank you! © 2022, Amazon Web Services, Inc. or its affiliates. 김문권 kmk@lionhearts.co.kr 윤종근 garen.youn@kakaocorp.com
반응형