We Saved a Million PCDN with 4 Lines of Code

Abstract:  Our company mainly does online video on demand, and a small amount of video download. More concerned about network acceleration, the first is the price, followed by the first broadcast time, smooth rate of these core performance indicators. I have been using Alibaba Cloud PCDN for a few months now, and the overall results are beyond expectations and worthy of Amway. By writing this article, I hope to achieve real feelings in several aspects through the comparison of model selection, access process and effect, and give some inspiration to colleagues who are still hesitating. I hope the content of the article will be helpful to you.

Without further ado, let’s talk directly about the effect: the monthly CDN cost is nearly 50% lower than before, and the premiere time and smoothness rate are slightly better than the two CDNs in use. This result is really exciting. I thought that the price of PCDN is so much lower than that of CDN, and the performance will be bad. I didn't expect that this product is not only lower in price, but also better in performance than CDN. It can save the boss nearly 1 million a year. , Mom no longer has to worry about my year-end bonus. How to sew this wool, please listen to me one by one.


Let’s talk about the selection stage first. What made us choose Alibaba Cloud PCDN?

In the first half of the year, the company made great efforts to promote, and our video-on-demand business grew rapidly. As the volume of business increases, not only is the bandwidth cost under pressure, but we are also under great pressure. We are afraid of unstable product services and various problems. Therefore, on the one hand, we are looking for the currently used CDN companies to apply for price discounts and service quality assurance; on the other hand, we are also constantly looking for other high-quality and low-cost CDN products.

Now the competition among CDN companies is also very fierce, and they can basically give a certain discount, but the price is still not ideal. After looking around, I finally settled on P2P. When I first saw P2P, I actually rejected it in my heart. P2P is reminiscent of various BT download tools on the Internet. Although this thing is low in price, can its performance indicators be guaranteed? After reading several P2P CDN product materials, it seems that it is not the same as the P2P I had in my previous impression, and I feel that it is still the same. But after digging deeper, the problem came. To use a P2P CDN, each company needs to integrate the SDK on the client side. Various factors such as the difficulty of SDK integration, the size of the SDK, and whether a bug in the SDK affects the main APP may all have an impact. In addition, from the perspective of the P2P principle, to have a certain P2P sharing rate, it may be necessary to upload traffic on the terminal. Our video-on-demand services are available on OTT boxes and mobile terminals. Once traffic is uploaded on the terminal, it will not only occupy bandwidth and affect the user experience, but also allocate a storage space on the terminal for caching content, and frequently read and write T card/ROM. It will also affect the life of the terminal. These problems are fatal to us, and if these problems exist, even if the cost of P2P CDN is low, we will not be able to use it.

After taking a closer look, it is found that not only the competition of CDNs is fierce, but also the competition of P2P is extremely fierce. During the period, various P2P CDN companies took turns to promote their products, and they were hyped. But laymen watch the fun, experts watch the doorway, let you blow the cows, we have our own concerns, if we can't meet the requirements, no matter how much we blow it, it will be useless. Let's talk about it separately:

1. Tencent Cloud P2P CDN: Tencent Cloud is currently vigorously promoting its CDN. The price is relatively low, and the performance is not yet known. His CDN has not been commercialized for a long time, and the P2P technology used has not been publicly applied, so it should still be in the public beta stage. The main problem is that if you want to use P2P, you must upload from the terminal, which is unacceptable and can only be given up.

2、星域CDN: 星域CDN其实是迅雷下面的一家做云计算的公司,P2P技术来自于迅雷。星域CDN做了赚钱宝这样的硬件终端,用于收集用户的家庭出口带宽。由于有一些这样的硬件P2P终端节点的存在,使得客户端APP可以不用上传流量即可有P2P分享率。SDK大小适中,可以接受。但是他们缺乏视频点播业务的客户案例,并且他们来介绍产品的人,对于星域CDN在视频点播上的性能表现,看起来也没有很大的信心。这让我们比较担心,我们业务体量在快速增长,我们可不愿意当小白鼠,一旦出问题,这锅我们背不起。

3、阿里云PCDN: 和星域CDN类似,阿里云也在全国各地发展了很多终端硬件设备,用户贡献带宽获得一定的收益,像优酷路由宝就是他家自有的设备,所以也不需要在设备上传流量就有P2P效果。而和星域比起来,阿里云对各种业务场景的支持比较全面,视频点播和下载业务领域已经有不少成熟的案例,并且优酷全站都使用了PCDN,这重燃了我们的信心。另外, 它的SDK不仅对接很快,而且大小在100KB左右,集成SDK后几乎不增大APP体积。SDK中跑具体业务的内核可以远程升级,如果出了问题,可以直接停用或者远程升级,APP不用发版,这个很炫。

4、云帆加速: 云帆其实是想卖他们的CDN,通过把P2P免费给我们用,从而把CDN价格做的偏高。云帆的P2P必须要在终端设备上传流量才会有P2P效果,这个没法接受。云帆目前还是个创业公司,他们目前还做了很多其他业务,对于创业公司而言,人少而业务摊的太多,产品不一定能做精,资源也不能得到很好的保障。我们还是希望跟成熟稳定的大公司合作。

最终,我们决定使用阿里云PCDN测试看看效果。


随之而来的就是非常关键的一步—— 接入,这是最能考验服务质量和易用性的一步了。

首先在阿里云官网找到PCDN产品,申请开通。PCDN开通后,还要提供阿里云CDN域名和url给他们后台,说是要匹配规则,然后就把SDK和对接文档发给我们了。阿里云的人专门拉了钉钉群来支持我们的SDK集成和测试,他们的产品技术同学都在里面,响应的还挺及时,碰到问题都能很快解决,这要赞一个。

他们的SDK整体还比较简单,就三个接口:启动、停止和地址转换。SDK对接照着他们给的文档进行就可以了,APP的业务逻辑也不需要更改。从开始对接到集成成功,一共就花了不到一个小时,我数了数,总共也就4行核心代码,这有点颠覆我以前对SDK集成的认知,没想到这么简单。给你们看看我是怎么做到的吧。

和大多数SDK一样,启动APP时启动SDK,传入阿里云分配给我们的token,这样就把PCDN服务启动起来了。

pcdn_1

需要播放视频时,播放器拿到云端提供的播放url地址后,增加一步调用SDK获取PCDN播放地址,然后使用PCDN提供的本地地址播放即可。
pcdn_2

最后再退出应用程序时停止PCDN服务即可。
pcdn_3

我们在APP上做了埋点监测,比对了首播时间、流畅度等指标,PCDN的指标略优于我们使用的CDN,这些关键指标测试下来,效果还是比较满意的。另外,阿里云PCDN有两点是超出了我们预期的。

第一个就是PCDN支持下载限速,我们大部分的业务是点播,有少部分的视频是要下载的,下载都是后台进行,要求下载的同时还能够流畅的播放视频,同时也希望尽量限制在带宽高峰期下载的速度。这就要求对下载进行限速了,还好阿里云PCDN已经支持了下载限速这个功能,下载速度可以由我们灵活控制,这个功能很好的解决了我们的问题。

第二个就是解决视频被劫持的问题。之前时不时有用户反映视频没法播放,经过分析基本都是域名被运营商劫持造成的,这种情况尤其在一些小地方小运营商中出现,比较头疼。给我们提供服务的CDN公司也能解决域名劫持的问题,但需要在APP上集成SDK,我们是不大愿意单纯为了这一个功能去集成SDK的。刚好阿里云PCDN SDK自带了HTTPDNS功能,保证了域名解析的正确性,避免域名被劫持的情况,并且HTTPDNS还免费给我们用,简直太方便太贴心了有木有。


成功接入后,我们就要看看效果了,毕竟老板们对数字指标是相当关心啊。

我们内部测试验证了一周左右。从测试情况看,产品稳定性不错,各方面性能指标也都达到了要求。但这毕竟只是实验室几个测试同学的测试,要真正反映产品表现,还是要大量数据来说话。阿里云PCDN的同学建议我们控制渠道灰度发布,有较多的用户使用才会体现出P2P效果来。经过跟老板商量,我们挑了个渠道,灰度发布了版本。几个小时后,就有几千的安装量,几千个用户对于验证PCDN效果也足够了。

接着又是一周时间,我们持续观察了各方面的数据,首播时间跟CDN不相上下,流畅度方面,使用CDN时流畅度98%左右,使用PCDN时流畅度98.5%左右,下载稳定性和完成率也符合要求,整体的表现还是很不错的。老板看到测试数据比较满意,同时,阿里云PCDN的同学对我们的问题的响应和支持都比较及时,老板果断决定正式上线PCDN产品,在各个渠道逐步全量发布。

现在,我们使用PCDN有几个月时间了,新版本的覆盖率已经很高了。产品还是很稳定的,即使偶尔有问题也能很快得到解决,这是我们非常看重的一点,省了很多麻烦。虽然业务增长,带宽量也在增长。但使用PCDN后,每月的带宽支出却实实在在的省了不少。照这个情况看,每年就能省将近100万的带宽费用了。而这所有的一切,只是花了不到一个小时集成阿里云PCDN SDK,增加了4行核心代码带来的成果,真是相见恨晚。

总结下整体的感受:接口简单服务给力,测试性能稳定优秀,阿里云有这么大的羊毛,不赶紧来薅,还等什么呢?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326441590&siteId=291194637