内容交付网络 ( CDN ) 是分布在世界各地的服务器集合,它们将您的网站片段交付给位于这些服务器附近的站点访问者。
CDN最常见的用途是从网站传送图像。这是因为图像通常是网页中加载速度最慢的组件。
什么是 CDN?(What Is a CDN?)
CDN不是网络主机。它只是缓存您设置为由CDN提供服务的网站部分。这些保存(缓存)的文件被上传到世界各地的所有不同服务器。
当来自其他国家/地区的访问者访问您的网站时,他们会直接从您的虚拟主机收到文本,但他们可能会从离他们最近的CDN(CDN)服务器收到许多其他文件。
这些文件可能包括:
当Google(Google)开始将页面加载速度作为其排名算法中的一个变量时,对CDN服务的需求猛增。
这场成为某个主题上加载速度最快的页面的竞赛要求网站所有者为网站上的缓慢加载图像寻找替代方案。分布式缓存CDN网络是完美的解决方案。
为什么 CDN 对您的网站至关重要(Why a CDN Is Essential For Your Site)
如果您拥有一个网站,页面加载速度很重要,原因有几个。如上所述,它将提高您在Google中的整体排名得分。
其次,它改善了访问者在您网站上的体验。这将使他们在您的网站上停留更长时间,并访问更多页面。
以下是CDN对您的网站至关重要的其他几种方式。
节省带宽(Saves Bandwidth)
通过使用CDN,您可以将带宽使用从 Web 主机的服务器转移到CDN服务器的分布式网络上。
设置CDN帐户并使用您的域进行设置后,您会看到带宽开始在您的帐户仪表板中累积。
这是您从网络主机服务器中移除的带宽需求。由于网络托管服务与它们一样昂贵 - 并且经常因使用更多带宽而被收费 - 减少带宽使用通常等同于显着节省成本。
CDN带宽成本远低于网络托管成本。这是因为CDN服务设置了它们的服务器网络来管理高带宽内容,例如图像。他们通过以下方式做到这一点。
- CDN(CDNs)使用服务器负载平衡和稳态驱动器等优化,从而加快传输速度并减少错误。
- 通过文件压缩和缩小等文件大小操作技术,CDN(CDNs)减少了传输的数据量。
- 使用SSL/TLS证书,CDN(CDNs)可以减少错误的传输启动,从而避免重新启动传输和发送更多数据的需要。
减少停机时间(Reduces Downtime)
在可靠性方面,没有什么比使用CDN服务更能减少您的网站停机时间了。
正常运行时间增加的原因有很多。
分布式CDN网络意味着您的大部分带宽(图像)来自世界各地的多个服务器。CDN服务使用一种称为“负载平衡”的技术,这意味着当一个服务器的需求过多时,其他服务器用于平衡负载。
每当您的网站流量大幅飙升时,都会对多个硬件提出大量需求。具体来说,您的 Web 主机数据中心中的 Web 服务器,以及由您的CDN服务管理的分布式服务器。
由于图像和文件是传输的最大数据量,因此大部分需求将出现在这些数据中。
CDN(CDNs)跨多个负载平衡的服务器管理该需求这一事实意味着,与不使用CDN服务相比,您的站点将能够处理更多的流量。
提高安全性(Improves Security)
您可能会惊讶地发现使用CDN还可以提高您的站点安全性。
要理解这一点,首先重要的是要了解访问者访问您的网站时的数据流。
在单个 Web 服务器设置中,访问者发出对网页的请求,您的 Web 服务器需要响应所有数据——包括文本、图像、javascript 和样式表。所有这些带宽需求都会影响您的一台 Web 服务器。
把它想象成一个有多个水口的水坝。在这种情况下,它将是一个只有一个端口供水流过的大坝。不需要太多的水涌,大坝就会超载,水开始从顶部流过。
这就是为什么大多数水坝都建有多个端口,这些端口可以随着另一侧的水位上升而打开。
如果您的网站托管在单个 Web 服务器上,则DDOS攻击者只需花费更少的精力就可以关闭您的网站。
DDOS 攻击由来自世界各地的许多不同“机器人”发起,模拟数百甚至数千用户同时向您的 Web 服务器发出请求。
然而,通过使用CDN服务和世界各地的分布式 Web 服务器,所有这些服务器就像大坝中的额外端口。
现在您的 Web 服务器只需要提供文本,多个CDN服务器提供图像和其他文件。所有这些服务器本质上都在共享带宽需求。
这不会为DDOS攻击提供 100% 的保护,但在您的网站出现故障之前,黑客需要付出更大的努力才能进行攻击。
此外,如果您确保使用TLS/SSLCDN,所有流量都将被加密并防止黑客拦截网络流量。
如何设置您的 CDN 服务(How to Set Up Your CDN Service)
虽然CDN服务听起来很复杂,但设置起来却相当容易。
首先,您需要选择一个CDN服务。有几个主要的可供选择。
- Cloudflare :世界上许多主要企业使用的最大和最知名的CDN服务之一。(CDN)
- Fastly:提供多种网络优化产品,包括CDN内容交付。
- KeyCDN:管理遍布全球的 34 个数据中心,具有久经考验的网站速度性能。
- MetaCDN:与其他按使用量收费的CDN服务不同,此服务按月收取固定费用。
- StackPath:以前MaxCDN,StackPath被世界各地的许多公司和网站使用。
这些服务中的任何一个都将为您的站点提供足够的CDN优化。如果您的网站很小,最好采用基于使用的付费模式,因为您的带宽可能会很低。如果您有大型网站或企业,固定费率模型会更好。
注册CDN服务后,您需要在帐户中设置CDN区域。
设置帐户只需提供您的域名称,以及配置缓存和压缩。通常,将这些设置保留为默认设置是可以的。
(Make)记下您的CDN提供的CNAME主机名。你稍后会需要这个。
最后,您需要在您的站点上安装CDN插件。例如,如果您正在运行WordPress网站,W3 Total Cache是一个流行的选项。
安装插件后,您会看到一个可用字段,您可以在其中输入CDN服务提供的CNAME 。
您还将找到一个部分,您可以在其中启用您希望CDN服务缓存并提供给访问者的网站上的文件类型。
保存所有更改后,您应该会看到CDN带宽图表随着时间的推移开始反映访问者。更改在整个Internet上复制可能需要一段时间,但DNS更改应在大约 24 小时后更新。
鉴于CDN服务提供的性能和安全优势,您不能不为您的网站配置它。
What Is a CDN & Why Is One Essential If You Own a Domain?
A contеnt deliνery network (CDN) iѕ a cоllection of servers distributed acrоss the world that deliver pieces of yоur website to site visitors located near those servers.
The most common use of a CDN is for the delivery of images from a website. This is because images are usually the slowest-loading component of a web page.
What Is a CDN?
A CDN is not a web host. It simply caches the parts of your website that you’ve set up to be served by a CDN. These saved (cached) files are uploaded to all of the different servers across the world.
When a visitor from another country visits your website, they receive the text directly from your web host, but they may receive a number of other files from the CDN server nearest their location.
These files may include:
- Javascript files
- Images
- Videos
- Stylesheets
The demand for CDN services skyrocketed when Google started using page load speed as one variable in their ranking algorithm.
This race to become the fastest loading page on a topic required website owners to seek out alternatives for slow-loading images on the site. The distributed, cached, CDN network was the perfect solution.
Why a CDN Is Essential For Your Site
If you own a website, the speed that pages load is important for a few reasons. As mentioned above, it’ll boost your overall ranking score with Google.
Secondly, it improves the experience visitors have on your website. This will make them stay on your website longer, and visit more pages on it.
Here are a few other ways a CDN is essential for your website.
Saves Bandwidth
By using a CDN, you’re shifting the bandwidth use off of your web host’s server and onto the distributed network of CDN servers instead.
Once you set up your CDN account and set it up with your domain, you’ll see that bandwidth start to accumulate in your account dashboard.
This is the bandwidth demand you’re removing from your web host’s server. With web hosting services as expensive as they are – and very often being charged for using more bandwidth – cutting back on bandwidth usage usually equates to significant cost savings.
CDN bandwidth costs are far cheaper than web hosting costs. This is because CDN services set up their server network to manage high bandwidth content like images. They do this in the following ways.
- CDNs use optimizations like server load balancing and steady state drives, which speed up the transfer and reduce errors.
- Through file size manipulation techniques like file compression and minification, CDNs reduce the amount of data that’s transferred.
- Using SSL/TLS certificates, CDNs can reduce false transfer starts, which avoids the need to restart a transfer and send even more data.
Reduces Downtime
When it comes to reliability, there are few things that reduce your website downtime more than using a CDN service.
This increased uptime is due to a number of reasons.
The distributed CDN network means that the bulk of your bandwidth – images – are coming from multiple servers from all over the world. CDN services use a technique called “load balancing”, which means that when there’s excessive demand from one server, other servers are used to balance out the load.
Whenever your website traffic spikes significantly, it puts a lot of demand on multiple pieces of hardware. Specifically, the web server in your web host’s data center, and the distributed servers managed by your CDN service.
And since images and files are the largest bulk of the data being transferred, that’s where the majority of demand will occur.
The fact that CDNs manage that demand across multiple load-balanced servers means that your site will be able to handle significantly more traffic than if you weren’t using a CDN service.
Improves Security
You may be surprised to learn that using a CDN can also increase your site security.
To understand this, first it’s important to understand the flow of data when visitors come to your website.
In a single web server setup, visitors make a request for a web page, and your web server needs to respond with all of the data – including text, images, javascript, and stylesheets. All of that bandwidth demand impacts your one web server.
Picture this like a dam with multiple water ports. In this scenario, it would be a dam with just a single port for water to flow through. It wouldn’t take too much of a water surge for the dam to be overburdened and water to start flowing over the top.
This is why most dams are built with multiple ports that can be opened as the water level rises on the other side.
If you have a website hosted on a single web server, it takes much less effort on the part of a DDOS attacker to take down your website.
DDOS attacks are launched from many different “bots” from around the world, simulating hundreds or even thousands of users making requests against your web server all at the same time.
However, by using a CDN service with distributed web servers around the world, all of those servers are like additional ports in the dam.
Now your web server only needs to serve text, and multiple CDN servers provide images and other files. All of these servers are essentially sharing the bandwidth demand.
This won’t provide 100% protection against DDOS attacks, but it will require that the effort the hackers put into the attack be much larger before your website goes down.
In addition, if you make sure to set your CDN up with TLS/SSL certificates, all traffic will be encrypted and protected from hackers intercepting the web traffic.
How to Set Up Your CDN Service
While a CDN service may sound complicated, setting it up is fairly easy.
First, you need to choose a CDN service. There are a few major ones to choose from.
- Cloudflare: One of the largest and most well known CDN services used by many major businesses across the world.
- Fastly: Offers a number of web optimization products, including CDN content delivery.
- KeyCDN: Manages 34 data centers located all across the world, with proven website speed performance.
- MetaCDN: Unlike other CDN services that charge based on usage, this service charges a flat monthly fee.
- StackPath: Formerly MaxCDN, StackPath is used by many companies and websites around the world.
Any of these services will provide sufficient CDN optimization for your site. If your site is small, it’s better to go with a usage-based pay model since your bandwidth will likely be low. If you have a large website or business, the fixed rate model would be better.
Once you’ve signed up for a CDN service, you’ll need to set up your CDN zone in your account.
Setting up the account simply involves providing the name of your domain, and configuring caching and compression. Typically, it’s fine leaving these settings as default.
Make note of the CNAME hostname provided by your CDN. You’ll need this later.
Finally, you’ll need to install a CDN plugin on your site. For example, if you’re running a WordPress site, W3 Total Cache is a popular option.
Once you install the plugin, you’ll see a field available where you can enter the CNAME provided by your CDN service.
You’ll also find a section where you can enable what type of files on your website you want the CDN service to cache and provide to visitors.
Once you’ve saved all changes, you should see the CDN bandwidth charts start reflecting visitors over time. It may some time for the changes to replicate throughout the Internet, but the DNS changes should update after about 24 hours.
Given the performance and security benefits provided by a CDN service, you can’t afford not to configure it for your website.