Were you ever curious about why large websites load their pages quicker. Sure, they have high performance dedicated servers, but they also use a globally distributed network called Content Delivery Network (CDN). This article will introduce you to the concept of CDN, how it works and how it can be configured on a Joomla website or in other words how to perform a Joomla CDN integration to help improve website content delivery speeds and reduce latency.
你是否曾经好奇为什么大型网站加载页面更快。当然,他们有高性能的专用服务器,但他们也使用一个全球分布式网络称为内容交付网络(CDN)。本文将向您介绍CDN的概念,它是如何工作的,以及如何在Joomla网站上进行配置,或者换句话说,如何执行Joomla CDN集成,以帮助提高网站内容交付速度和减少延迟。
What is a Content Delivery Network (CDN)?
什么是内容交付网络(CDN)?
A Content Delivery Network (CDN) is a globally distributed network of web servers or Points of Presence (PoP) whose purpose is to provide faster content delivery by replicating the content and storing it on multiple CDN Servers. That way, the user can access the data from a server that is in the nearest geographical location. This has proved more efficient than storing content on just one central server. Clients accessing copies of their data on the multiple CDN servers will help avoid bottlenecks near that central server.
内容交付网络(CDN)是Web服务器或存在点(PoP)的全球分布式网络,其目的是通过复制内容并将其存储在多个CDN服务器上来提供更快的内容交付。这样,用户就可以从地理位置最近的服务器访问数据。事实证明,这比仅在一台中央服务器上存储内容更高效。访问多个CDN服务器上的数据副本的客户端将有助于避免中央服务器附近的瓶颈。
Without a CDN, central servers must respond to every single end user request. This results a subsequent load, thereby increasing the chances for central server failure if the traffic spikes are exceedingly high or if the load is persistent.
如果没有CDN,中央服务器必须响应每个最终用户的请求。这会导致后续负载,从而在流量峰值过高或负载持续的情况下增加中央服务器发生故障的机会。
How does a Content Delivery Network (CDN) work?
内容交付网络(CDN)如何工作?
Nowadays, web pages are quite complicated and complex; one feature being that the entire content is too big to be downloaded at once. The browser on the user's personal computer or smartphone makes multiple requests to the central web server where each of these requests takes a few milliseconds only to get a response.
如今,网页相当繁杂复杂;一个特征是整个内容太大而不能一次下载。用户的个人计算机或智能手机上的浏览器向中央Web服务器发出多个请求,其中每个请求只需要几毫秒就能得到响应。
Moreover, the further away the central server is located, more intermediate nodes or networking devices that multiply requests time will be inevitable. Subsequently, hundreds of requests are placed to the central server for a single webpage to load up completely. This not only increases the server load but also increases the latency.
此外,中央服务器位置越远,将不可避免地会有更多的中间节点或网络设备,从而使请求时间倍增。随后,数百个请求被放置到中央服务器以完全加载单个网页。这不仅增加了服务器负载,而且增加了延迟。
Therefore, a website that applies Content Delivery Network (CDN) technology bridges the physical distance between the central server and the users’ personal computers. For example, a user is requesting a webpage from Saudi Arabia. The requested web page’s central server is located in the United States and there is a CDN server located in Switzerland.
因此,应用内容交付网络(CDN)技术的网站在中央服务器和用户的个人计算机之间架起了物理距离的桥梁。例如,用户正在请求来自沙特阿拉伯的网页。所请求网页的中央服务器位于美国,而CDN服务器位于瑞士。
If the webpage requested is a typical non-CDN website: The browser straight off connects to the server in the United States and asks for the HTML. The server sends it back from the United States to the browser in Saudi Arabia. Then the browser asks the United States web server again for images, Javascript and CSS. The server sends the images, Javascript and CSS to the browser in Saudi Arabia. But if the webpage requested is a CDN Website: The browser requests the HTML from the server in the United States. The browser receives the HTML from the United States and informs that the images, Javascript and CSS are in Switzerland CDN server. The images, Javascript and CSS are being sent by the Switzerland CDN server to the user browser in Saudi Arabia.
如果请求的网页是典型的非CDN网站:浏览器直接连接到美国的服务器并要求HTML。服务器将其从美国发送回沙特阿拉伯的浏览器。然后,浏览器再次向美国网络服务器请求图像、Javascript和CSS。服务器将图像、Javascript和CSS发送到沙特阿拉伯的浏览器。但是,如果请求的网页是CDN网站:浏览器向美国的服务器请求HTML。浏览器从美国接收HTML,并通知图像、Javascript和CSS位于瑞士CDN服务器中。图片、Javascript和CSS由瑞士CDN服务器发送到沙特阿拉伯的用户浏览器。
What are the Content Delivery Network (CDN) Pros and Cons?
内容交付网络(CDN)的优缺点是什么?
The Pros of using CDN are:
使用CDN的优点是:
- Web pages load quicker. 网页加载速度更快。
- Better user experience. 更好的用户体验。
- Reduce server bandwidth. 减少服务器带宽。
- Lower server load. 降低服务器负载。
- Increase in concurrent users on the central server. 中央服务器上并发用户的增加。
- Geo-location of the content. 内容的地理位置。
- Faster content delivery to the users’ browsers. 更快地将内容交付到用户的浏览器。
While the Cons of using CDN are:
使用CDN的缺点是:
- Incorrect configuration of the CDN might cause viewing errors. CDN配置不正确可能会导致查看错误。
- Cost additional expenses. 成本附加费用。
- Adds complexity to your website and deployment procedures. 增加网站和部署程序的复杂性。
- Network filters might block some Content Delivery Networks and prevent your website content from being loaded. 网络筛选器可能会阻止某些内容交付网络,并阻止加载您的网站内容。
- Geo-location might actually be further away from your targeted audience. 地理位置可能实际上更远离您的目标受众。
What are the two types of Content Delivery Network (CDN)?
有哪些两种类型内容分发网络(CDN)的性能?
There are two different types of CDNs: push and original pull (or simply 'pull'). Each has its own advantages and disadvantages. Some sites work best with push CDNs, and some work better with pull CDNs.
有两种不同类型的CDN:推送和原始拉取(或简称为“拉取”)。每一种都有其优缺点。有些网站最适合使用推送CDN,有些则更适合使用拉取CDN。
Using a push CDN server, the site owner is required to upload website content (automatically or manually) directly to the CDN server and link that content to the website. The site owner, or the primary server, takes responsibility for providing the content to the CDN server, which in turn pushes it to the network. This is flexible as site owners can specify the content that is uploaded, when it expires and when it should be updated. This method is also the most efficient in terms of how the traffic is used. Content is uploaded only when it is new or changed, thus keeping traffic to a minimum.
使用推送CDN服务器时,网站所有者需要将网站内容(自动或手动)直接上传到CDN服务器,并将该内容链接到网站。站点所有者或主服务器负责向CDN服务器提供内容,CDN服务器进而将内容推送到网络。这是灵活的,因为网站所有者可以指定上传的内容、过期时间以及更新时间。就如何使用流量而言,此方法也是最有效的。只有当内容是新的或更改时才上传,从而将流量保持在最低水平。
On the contrary, an origin pull CDN works very differently. The site owner is not required to upload files onto the CDN, the CDN does it autonomously. The site owner leaves the content on the central server and rewrites the content URLs to point to the CDN server. When the visitors ask for a specific file, the CDN server will first go to the central server, pull the file and serve it. The CDN server will then cache that file until it expires. People who are trying to access a file for the first time, or accessing it after it has expired, may notice a small difference in speed. Setting the expiration correctly can help to minimise this problem, but it can involve trial and error.
相反,源拉CDN的工作方式非常不同。网站所有者不需要将文件上传到CDN,CDN会自动完成。站点所有者将内容保留在中央服务器上,并重写内容URL以指向CDN服务器。当访问者请求一个特定的文件时,CDN服务器会首先访问中央服务器,提取该文件并提供服务,然后CDN服务器会缓存该文件,直到它过期。首次尝试访问文件或在文件过期后访问文件的用户可能会注意到速度上的细微差异。正确设置过期时间有助于最大限度地减少此问题,但这可能需要反复试验。
How to Implement a Content Delivery Network (CDN) in Joomla?
如何在Joomla中实现内容交付网络(CDN)?
We already mentioned the two main CDN types, which were Push and Pull CDNs. Both of them have their advantages depending on the setup of your website. The Pull CDN is the one which is great for most of the Joomla sites and there is not much initial setup and maintenance needed.
我们已经提到了两种主要的CDN类型,即Push CDN和Pull CDN。他们都有自己的优势取决于您的网站的设置拉CDN是一个伟大的大多数Joomla网站,并没有太多的初始设置和维护需要.& nbsp;
We will now introduce to you some tips on how to implement the Pull CDN. You can start with choosing a CDN provider from the list shown in the below sections, and creating an account with them. Now establish the DNS redirects while reading the instructions given by the provider. Once the cdn.yourdomain.com points at your CDN account, it’s all good.
现在我们将向您介绍一些关于如何实施Pull CDN的技巧。您可以从以下部分所示的列表中选择CDN提供商,并创建一个帐户。现在,在阅读提供商提供的说明的同时建立DNS重定向。一旦cdn.yourdomain.com指向您的CDN帐户,一切都很好。
The next step after the DNS and the CDN account configuration is to change your website files URLs from www.mydomain.com to cdn.mydomain.com. Instead of changing all website files URLs manually as it's very inefficient and will take a lot of time to do that, you can save your time and do it automatically using a Joomla CDN extension from the list shown in the below section. Joomla CDN extension gives you advanced options, easy accessibility, less maintenance, and can automatically change the links of your websites images, Javascript and CSS. Some of these extensions also include the option to specify the file types which should be rewritten while allowing the use of multiple CDNs at once. You can also easily turn the CDN on and off by using such an extension.
DNS和CDN帐户配置后的下一步是将网站文件URL从www.example.com更改www.mydomain.com为cdn.mydomain.com。而不是手动更改所有网站文件的URL,因为它是非常低效的,并将花费大量的时间来做,你可以保存你的时间,并自动使用Joomla CDN扩展从下面的部分显示的列表。Joomla CDN扩展为您提供了高级选项,易于访问,维护更少,并可以自动更改您的网站图像,Javascript和CSS的链接。其中一些扩展还包括指定应重写的文件类型的选项,同时允许一次使用多个CDN。您还可以使用这样的扩展轻松地打开和关闭CDN。
Choosing a CDN Extension:
选择CDN扩展:
The Joomla CDN extensions can be found in the Joomla Extensions Directory, just go to Core Enhancements > Performance category or you may choose one from the below list according to your needs in order to set up the CDN integration:
Joomla CDN扩展可以在Joomla扩展目录中找到,只需转到核心增强>性能类别,或者您可以根据您的需要从下面的列表中选择一个,以便设置CDN集成:
- CDN for Joomla by RegularLab RegularLab为Joomla提供的CDN: Any CDN that supports pull-zones. :支持拉区的任何CDN。
- JomCDN by CorePHP 由CorePHP开发的JomCDN: Only for Amazon S3 / Cloudfront and StackPath. :仅适用于亚马逊S3 / Cloudfront和StackPath。
- JCH Optimize JCH优化: Only for Amazon Cloudfront and StackPath. :仅适用于亚马逊Cloudfront和StackPath。
Setting up these extensions is usually pretty easy to do, depending on which one you choose. You may find other extensions which might fit your needs. Make sure to check extension documentation for further information.
设置这些扩展通常很容易,这取决于您选择的扩展。您可能会找到其他扩展可能适合您的需要。请确保查看扩展文档以了解更多信息。
Choosing a CDN Provider:
选择CDN提供商:
You may choose one of the popular CDN providers listed below. Be noted that some of them are free with limited features while others should be purchased as subscriptions in order to benefit all CDN features.
您可以选择下面列出的其中一个常用CDN提供商。请注意,其中一些是免费的,功能有限,而其他人应该购买订阅,以受益于所有CDN功能。
- Amazon CloudFront 亚马逊云锋
- Azure CDN (Microsoft) Azure内容分发网络(Microsoft)
- Cloudflare 云耀斑
- BunnyCDN 兔子CDN
- CDN77 CDN77蛋白
- CDNetworks CD网络
- CacheFly 高速缓存
- KeyCDN 密钥CDN
- StackPath (previously MaxCDN) 堆栈路径(以前为MaxCDN)
Conclusion
结语
CDNs serve a great purpose, they reduce significant traffic to the central server and improve the web experience which benefits both the content provider and the end users.
CDN的用途非常广泛,它们可以显著减少中央服务器的流量,改善Web体验,从而使内容提供商和最终用户都受益。
I hope you find this explanation of Content Delivery Networks helpful. A CDN requires extra configuration and extra expenses but the benefits are well worth it especially if you have users located all around the world.
我希望您会发现这对内容交付网络的解释有帮助。CDN需要额外的配置和额外的费用,但好处是非常值得的,特别是如果你有用户位于世界各地。