Dry | CDN with OSS best practices - building the separation of static and dynamic application architecture

First, the traditional architecture and pain points

Traditional Website application architecture, all resources deployed in the application server stored locally or mount the data storage area, for static and dynamic resources without separation, product architecture as shown below:

This architecture has many problems:

● system performance as traffic growth is limited by the system even bottlenecks;

● When the huge amount of static resource access, and bandwidth utilization, affect the dynamic response to the request;

● When a user requests dispersed, long distance back to the source, affect the user experience (simply use the CDN still need to pull back to the source).

Two, CDN + OSS Infrastructure Solutions:

The architecture leverages the "OSS-bandwidth / low-flow cost, independent response, storage space, unlimited" features, combined with CDN distribution network to achieve separation of static and dynamic resources to support massive user access.

After optimization of the product structure as shown below:

1, application scenarios

● static file storage capacity, the number of documents and more, the larger the file size, server storage space is not enough;

● static file access capacity, bandwidth load or server load, I / O problem causes users to access Caton;

● user distribution is more dispersed, distributed throughout the country, the operators;

● higher speed requirements for file downloads and high concurrent downloads.

2, architecture description

Products involved:

Object Storage Service (OSS: Object Storage Service) is an independent research and development of large-scale cloud Jingdong distributed object storage services for businesses and individual developers to provide high availability, low cost, high security cloud storage service. You can achieve unified management of data, to meet various storage needs. RESTfulAPI supports standard interfaces, you simply press the actual amount paid, no minimum usage restrictions. It supports streaming write and write files in two ways. The face of the cold storage of data scene, for those who access frequency is relatively low, while the less demanding data access speed, data can be accessed by way of the low-frequency stored for you to save and backup data provide a massive low-cost space .

京东云CDN(Content Delivery Network),基于京东优质网络基础设施和智能云计算技术,向用户提供低成本、高性能、可扩展的互联网内容分发服务。利用广泛的节点覆盖和先进的云调度、云存储技术,将海量内容更快、更可靠地投递给互联网终端用户,降低网站运营成本,提升用户互联网应用体验。京东云 CDN 的前身是服务于京东商城的自建 CDN 平台,历经多年 618 和 11.11等大促业务活动考验,京东云 600+ 节点广泛覆盖于全国各区域和运营商,精选全网优质基础设施,边缘节点覆盖全网、全地域,真正实现就近接流、就近推流。

将京东云的对象存储和CDN服务搭配使用,使用京东自建的全网CDN加速节点,为您提供上传下载双向加速,实现全网覆盖、快速高效的内容分发。

架构优势:

降低Web/应用服务器负载,静态资源响应压力转移到CDN,避免性能影响;

费用最低,OSS的存储费用远低于云主机磁盘费用;

超大容量存储空间,大带宽上传通道,无需担心存储空间上限;

降低流量费用,正常访问热度情况下,相比直接访问OSS,减少95%回源流量。

三、实际案例

以一个常见的Web站点为例。www.abc.com是一个新闻门户网站,有500GB的新闻图片、新闻视频、JS文件等静态内容,使用了LAMP架构,目前站点全套架构部署在京东云上。随着用户业务发展,访问量的不断增长,不少用户反映,访问网站的速度越来越慢,图片、视频加载慢,卡顿率高,网站响应慢。客户工程师发现用户上传的图片越来越多,业务高峰期,带宽峰值很高,服务器I/O经常被占满。

对于以上案例我们可以利用以上介绍的OSS+CDN架构对网站进行优化,实现动静分离的产品架构,提升用户访问体验,同时成本可控。

解决方案及步骤如下:

1、对网站应用架构进行整理,区分动态程序部分和静态部分到不同的目录进行管理,建立image、video、js目录,分别放置所有网站图片素材;

2、京东云控制台进入OSS产品,新建一个Bucket。根据云主机所在的区域选择bucket所在区域,权限选择“公共读”,bucket名称与云主机新建的目录的名称对应,如“abc-image-bucket”、“abc-video-bucket”和“abc-js-bucket”;

3、分别绑定域名image.abc.com、video.abc.com、js.abc.com并进行CDN加速。

4、上传文件:提供控制台上传和表单上传两种方式。

控制台上传:可以通过对象存储控制台上传小于1GB 的文件。如您要上传的文件大于1GB,请通过对象存储 API或SDK的方式上传。

表单上传:表单上传指用户使用OSS API中的Post Object请求来完成文件的上传,非常适合嵌入在HTML网页中来上传文件;

5、修改DNS调度,增加CNAME解析,将原本访问源站的请求,调度到CDN加速域名,以后用户访问您的网站的静态文件就全部通过OSS+CDN的方式访问,不再占用您云主机的资源。

四、典型应用场景

● 新闻门户网站

● 应用分发市场

● 在线音乐、在线K歌

● 视频、短视频(UGC/PGC)

● 电影院线

● 在线教育

阅读原文

Guess you like

Origin www.cnblogs.com/jdclouddeveloper/p/11127640.html