Jump to content
Sign in to follow this  
Morendal

Network code optimization | Оптимизация сетевого кода

Recommended Posts

🇺🇸
Hi, today we’ll talk about optimizing network code!  
In essence, this is one of the most important parts of a game: the better the game and server network code is optimized, the more players the game can handle.
A modern approach (and the approach used by most game engines) is to limit a session to no more than 32/100 people. For our game, that’s far too low!
Splitting the world into sessions is a critical mistake, and doing sharding as well—the world must be alive, and a living world creates a huge load on the network!
But besides the server network, poor optimization can also affect the players’ network.
A modern approach is socket-based connections, where player information (their ID, position, etc.) is sent in JSON. In other words, every second about 3–5 KB of data flies from each player. Now imagine there are 100 players: then every player would need to receive 300–500 KB of information every second, and the server would have to send 300–500 KB to 100 players. That totals 30–50 MB per second. And what if there are 200–300 players? That would be 100–150 MB/s—those are very big numbers!
We use byte packets and our own compression methods, which means that with 1000 players in the same area, total network usage is about 5–15 KB of information. That reduces the load on the network stack by hundreds of times!

DalamWorldNetworkEN.jpeg

    

 

🇷🇺
Привет, сегодня поговорим про оптимизацию сетевого кода! По сути это одна из самых важных деталей в игре, чем лучше оптимизирован сетевой код игры и сервера, тем больше количество человек игра может обработать! Современный подход и подход большинства игровых движков включает в себя подход, что в сессии не может находится более 32/100 человек, что для нашей игры слишком мало! Разбивать мир по сессиям, это критическая ошибка, как и делать шарды, мир должен быть живым, а живой мир - это огромная нагрузка на сеть ! Но кроме сети сервера при плохой оптимизации может страдать сеть игрока! Современный подход - это сокет соеденение , где в json отдается информация о игроке, его местоположение и тд, короче говоря, каждую секунду с одного игрока летит около 3-5кб данных, а теперь представим, что игроков 100, уже каждый игрок должен ежесекундно получать по 300-500кб инфы, а сам сервер должен отправлять 300-500 кб данных 100 игрокам , что будет 30-50к кб, или ≈30-50мб в секунду, а если 200-300 игроков? По 100-150мб/с ? это очень большая цифра! Мы же используем байт пакеты, и свои методы сжатия, что позволяет при 1000 игроков в одном мест потреблять около 5-15кб информации, что в сотни раз снижает нагрузку на сетевой стек!

DalamWorldNetworkRU.jpeg

Share this post


Link to post
Guest
This topic is now closed to further replies.
Sign in to follow this  

×