Why Domain Sharding is Bad News for Mobile Performance and Users

地址

In this post we’ll review the results of a real-world test with over three million samples showing that domain sharding is at best neutral and at worst harmful for mobile websites.

在本帖里,我们将通过超过三百万个样品实际测试的结果来说明域分片对于移动网站来说充其量是中立的和最坏的。

If you’re already familiar with sharding, you may want to skip straight to our results. Otherwise, we’ll begin with a brief introduction to the subject.

如果你已经熟悉分片,你可以跳过直接我们的结果。那么,我们开始简要介绍这个主题把。

What is Domain Sharding?

Traditionally, web browsers place a limit on the number of simultaneous connections a browser can make to one domain. These limits were established in 1999 in the HTTP/1.1 specification by the Internet Engineering Task Force (IETF). The intent of the limit was to avoid overloading web servers and to reduce internet congestion. The commonly used limit is no more than two simultaneous connections with any server or proxy.

传统上的web浏览器会限制一个域的并发连接数。这些限制是互联网工程任务组(IETF)于1999年在HTTP / 1.1规范中成立。目的是为了避免重载web服务器和减少网络拥塞。常用的上限在任何服务器或代理中不超过两个并发连接。

Domain sharding is a technique to accelerate page load times by tricking browsers into opening more simultaneous connections than are normally allowed. It’s a widely-used optimization tactic that enables browsers to make better use of high-bandwidth internet connections.

域分片技术通过欺骗浏览器打开比通常允许更多的并发连接从而加快页面加载时间。这是一个广泛使用的优化策略,使浏览器能够更好地利用高带宽的网络连接。

The average web page references 44 different resources such as image files, stylesheets and JavaScript. Each of these resources need to be loaded for the page to render correctly, so domain sharding seems like a useful technique for increasing load times and, therefore, improving user experience.

当一般的web页面引用44不同的资源,如图像,css样式表和js文件。这些资源需要加载并在页面上正确呈现,所以域分片似乎是一个有用的技术去提高加载时间和改善用户体验。

However, there are two key reasons why domain sharding is no longer a best practice, and why web developers should particularly avoid it on mobile or responsive websites:

然而,有两个关键的原因导致域分片不再是一个最佳实践,以及为什么web开发人员应该特别避免它在移动或响应网站使用:

  1. Additional network connections above and beyond the recommended limits are not “free”. Each connection comes with a setup overhead in the form of a DNS lookup and a TCP 3-Way handshake, as well as TCP slow start. For mobile browsers, the resulting latency is much higher than for desktop users. Additionally, this connection setup consumes extra CPU, memory and battery power–all considerations on mobile devices with scarce resources.

  2. Many mobile browsers implement HTTP pipelining and no longer observe the old HTTP/1.1 connection rules.

1.额外的超出推荐限制数的网络连接并非“免费”。每个连接都会附带dns域名解析和TCP三通握手上的开销,就跟TCP慢启动一样。这对于移动浏览器来说,这个开销造成延迟远远高于桌面用户。而且,这种连接设置会消耗额外的CPU、内存和电池在移动设备上。

2.许多移动浏览器实现HTTP管道并且不再遵守旧的HTTP / 1.1连接规则。

Domain sharding works because web browsers recognize each unique internet name (a DNS entry such as www1.yourdomain.com, www2.yourdomain.com and so forth) as being a different server, even if in reality all those domain names resolve to a single server.

域分片工作原理是因为web浏览器会识别每一个不同的域名(比如www1.yourdomain.com,www1.yourdomain.com等等)是不是来自一个不同的服务器,即使所有的这些域名都解析到一个服务器上。

If you divide your references to static assets such as images, scripts and CSS files over several servers, the browser will open two connections to your web server for each server name. You may have noticed, for example, that resources on YouTube pages load from i1.ytimg.com, i2.ytimg.com and so forth.

如果你把你的引用资源,如图像、脚本和CSS等文件放在多个服务器上,浏览器会根据每个服务器的名称打开多个链接去请求。例如,您可能已经注意到YouTube的页面资源来自i1.ytimg.com,i2.ytimg.com等等。

The web, and web browsers, have changed

When the “two connections per server” rule was established, most internet users were using dial-up internet connections one-tenth to one-hundredth the speeds of today’s broadband connections. Most contemporary browsers no longer implement the two-connection per-server limit since 2010.

在“每个服务器只允许两个链接”的年代,那个时候大多数互联网用户的上网速度只有现在拨号上网连接速度的十分之一到百分之一。自2010年以来,大多数现代浏览器不再实现‘每个服务器两个链接’的限制。

For example, the default for desktop Firefox is eight connections per server, and for Google Chrome and Internet Explorer 8/9 the limit is now six connections per server. For most websites, these values are high enough to effectively maximize bandwidth utilization. Additional sharding for desktop computers will only offer marginal improvements or may even penalize your site’s performance.

例如,Firefox 默认限制每台服务器8个连接,Google Chrome和ie的8/9限制每台服务器是六个连接。对于大多数网站来说,这些值已经足够高到带宽利用率最大化。额外的台式机的附加分片只能提供轻微的改进,甚至可能会影响您网站的性能。

So what about in the mobile browser use case?

那么,在移动浏览器上又如何呢?

Here’s a table showing simultaneous connections by mobile browser type:

这里有个不同移动浏览器的连接数限制表:

BrowserSimultaneous connections
Safari mobile6
Android browser4
Chrome mobile6
Firefox mobile4

As you can see, mobile browsers also no longer respect the two-connection per-server limit.

正如你看到的,移动浏览器也不再遵循原来那个两个链接的限制规则

So, is domain sharding still necessary? We wanted a definitive answer, so we ran some real-world tests.

所以,就目前来看,域分片还有需要吗?我们需要一个明确的答案,所以我们会通过跑一些真实数据来测试。

Real-World Testing of Domain Sharding on Mobile Devices

Our test required downloading 15 images, each about 10 KB in size. By using a portion of our Mobify Cloud network, we were able to test using real users on real networks and real phones distributed around the planet with almost 3-million unique samples.

我们的测试会下载15个图片,每个大约10 KB大小。通过使用Mobify Cloud,我们能够使用真实用户在真实网络和分布在地球上的真实手机来测试300万不同的样本。

The test was limited to visitors using high-end smartphones such as iOS 5, Android 2.2+, BlackBerry OS 7 and newer devices. The backend was serviced by our global Content Delivery Network, so mobile visitors received data from a web server running in one of our 35 worldwide data centers with the images in memory geographically close to their location.

测试仅限于使用高端智能手机(例如iOS 5,Android 2.2+,BlackBerry OS 7和更高版本的设备)的访问者。后端由我们的Content Delivery Network提供服务,因此手机访问者将会从距离他们最近的全球35个数据中心之一的网络服务器接收数据。

Here are our results:

以下是我们的测试结果:

of ShardsSafari mobileAndroid browserChrome mobileFirefox mobile
No sharding2.33s2.81s2.02s1.92s
2 shards2.32s2.78s2.47s1.68s
4 shards2.55s2.81s2.59s2.78s

Regardless of browser, when we added shards, the results were at best neutral and, in most cases, detrimental.

不管浏览器如何,当我们添加分片时,结果是最好的也就中性,但是大多数情况下是有害的。

The lesson: the connection overhead for mobile browsers exceeds the benefits of having additional simultaneous connections.

对移动浏览器来说,不分片下的链接开销好处超过了额外的同时链接带来的好处。

Mobile Chrome takes the biggest penalty for adding more shards, performing half of a second slower when sharding is used, but Safari Mobile also pays a hefty penalty.

移动Chrome为更多的分片付出了很大的代价,但使用分片速度仍然慢了一半多,同样的,Safari也差不了多少。

Domain Sharding Conclusions for Mobile Devices

Ultimately, sharding adds complexity to your infrastructure without providing performance benefits. In many cases, sharding can degrade visitor performance for your site.

分片的结果除了增加基础设施的复杂性,并没有提供多大的性能优势。而且,很多情况下反而降低了用户体验。

Based on our data, we recommend disabling sharding for both for desktop and mobile visitors.

所以,根据数据反馈来看,我们建议对用户群体进行划分,分为桌面用户和移动用户。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值