Hubert Wang

I am
Hubert Wang

Wechat Official Account
Find fun things here!

Reduce Honor of Kings Latency by over 50% with HTTPDNS

How to play Honor of Kings (China edition) from USA with latency under 120ms?

TL;DR: jump to the last section on how to configure your phone to reduce latency and improve gaming experience.

Bad Gaming Experience with High Latency

Honor of Kings is a China MOBA game super popular with over 100M daily active users. I’m also a fan of it but have to endure the super high latency, usually varies from 250ms to 350ms, as all of the game servers are in China but I’m physically in USA.

When I was in China, the gaming latency can be as low as 20ms as physically closer to the server thus getting the HTTP / HTTPS responses faster. Now in USA, China and USA are literately at the opposite sides of the Earth. The distance contributes to a large portion of the overall latency.

Solutions and How it works

We cannot diminish the latency attributed to physical distance for sure. But how about saving time at the domain name resolution step?

Domain resolution is a set of address conversion systems for resolving domain name to corresponding IP address as the step before sending actual HTTP / HTTPS. And in MOBA scenario, gaming companies use distributed server solutions spinning up tons of servers with different IP addresses to satisfy tremendous parallel demands of requests from massive players. This means there are actually tons of domain resolving happens when play games and ideally we can reduce the latency by choosing the right address conversion systems, i.e. DNS (Domain Name System).

Many big tech companies like Google (8.8.8.8, 8.8.4.4) and Cloudflare (1.1.1.1, 1.0.0.1) provide public DNS for generally better performance on DNS address lookup. By using them, my latency reduced from 350ms to 250ms in average and gets more stable. But is there a better solution?

As the red lines in diagram show, DNS usually uses a two layer systems, with an operator’s local layer caching usual results in local DNS and a remote layer for actual call to address “book” if cache missed. As few players outside of China, cache missing is likely a usual case with these implementations.

HTTPDNS is another type of domain name resolution service, which can directly access the server of cloud CDN through HTTP protocol as shown in diagram above tagged with the green line. As it bypasses the operators, it can obtain real-time and accurate DNS resolution results especially in the gaming scenario that play staying far way from servers. By using Baidu’s public HTTPDNS (180.76.76.76), the average latency further reduces from 250ms to 120ms.

Using Wireshark to capture DNS packets, we can tell whether it works as expected more intuitively. From the comparison below, the DNS request latency reduced from 105ms to 31ms.


Configure Your Phone Step by Step

  1. Go to Phone’s Settings
  2. Tap on Wi-Fi entry
  3. Tap on the Wi-Fi you’re currently connecting to
  4. Tap on Configure DNS entry
  5. Use Manual mode, delete any DNS entries if there is any, type in “180.76.76.76” as the screenshot shows, and Save the changes by tapping on the right top button “Save”
  6. After saving, you’ll be in the former page, tap on Renew lease button and you’re all done.

Remember that do not forgot to remove the DNS address after playing the game, otherwise you’ll lose access to certain website like Google.com due to the reason you know. 😉

在美国玩王者荣耀,怎么把延迟降低到 120ms 以内?

(如果不想了解原理的话可以直接跳到最后一部分配置你的手机。)

高延迟影响操作

王者荣耀是现在最火爆的 MOBA 游戏,每天活跃用户超过1亿。但是因为所有游戏服务器都在中国,从美国玩儿国服必须忍受超高延迟,我从西雅图玩儿延迟一般是在 250 毫秒到 350 毫秒之间。

回国的时候,地理上离服务器更近延迟可以低到 20 毫秒,可见距离占整个延迟的很大一部分。

解决方案和原理

除了肉身回国,我们肯定不能减少因为地理距离产生的延迟。但是可以考虑网络优化的原理看有没有哪一步能节省网络请求响应时间。

域名解析本质上是个地址转换系统,在发送实际的 HTTP / HTTPS 请求之前,将域名解析为相应的 IP 地址。在 MOBA 场景中,游戏公司会使用分布式服务器解决方案,将大量具有不同 IP 地址的服务器链接成集群,以满足来自海量玩家的巨量并行请求。这意味着在玩游戏时实际上需要做大量的域名解析。理想情况下,我们可以通过选择正确的地址转换系统,即 DNS(Domain Name System),来减少延迟。

许多大型科技公司,比如 Google(8.8.8.8,8.8.4.4)和 Cloudflare(1.1.1.1,1.0.0.1)都有提供公共 DNS,通常这些公共 DNS 有更好的地址查找性能。直接使用这些 DNS,我测试王者荣耀的延迟可以从平均 350ms 减少到 250ms,并且变得更加稳定。但是这个延迟还是非常高,有更好的解决方案吗?

如图中的红线所示,DNS 通常使用两层系统,本地这一层通常将结果缓存在本地 DNS 中,而远程解析服务器则在缓存内容不存在时作出响应。在美国地区,由于王者荣耀国服玩家较少,缓存不命中可能是常见情况,两层请求的 DNS 查询增加了延迟。

HTTPDNS 是另一种架构的域名解析服务,可以通过 HTTP 协议直接访问云 CDN 的服务器,如上图中用绿线标记的图所示。由于它绕开了运营商,因此可以获得实时、准确的 DNS 解析结果。通过使用百度的公共 HTTPDNS(180.76.76.76),平均延迟能进一步从 250ms 减少到120ms。

可以用 Wireshark 抓 DNS 数据包来更直观地判断它是否按预期工作。下面的用时比较可以看出来,用了百度的 HTTPDNS 之后,访问王者荣耀官网的 DNS 请求延迟从 105ms 减少到了 31ms。


如何设置手机

  1. 转到手机的设置页面
  2. 点击 Wi-Fi 条目
  3. 点击您当前正在连接的 Wi-Fi
  4. 点击配置 DNS 条目
  5. 使用“手动”模式,删除任何已有的 DNS 条目,像截图所示用“180.76.76.76”,之后点击右上方的“保存”按钮来保存更改。
  6. 保存之后,您将进入上一页,点击“Renew Lease”按钮,就完成了。

玩完游戏之后不要忘记删除 DNS 地址,否则由于“科学上网”的限制,有一些网站(比如 Google.com)在用这个百度 DNS 的时候没办法访问。😉

356
TOC
Comments
Write a Comment
  • 站元素主机 reply

    真不错 还可以中英文切换,赞一个