调整WordPress以处理大量流量

tech2022-12-27  58

Performance tuning used to be reserved for high-end websites, however in a world where websites are the first impressions customers have of a company, it is vital to ensure that you and your customers have an efficient website.

性能调整曾经是高端网站的保留,但是在网站是客户对公司的第一印象的世界中,确保您和客户拥有高效的网站至关重要。

At SitePoint, we regularly cover web performance, including topics such as How to Speed Up Your WordPress Site and the Perception of Performance. But, if you still don’t think that speed matters, an article from KISSmetrics provides multiple figures on how latency on websites leads to lost conversions.

在SitePoint,我们定期介绍网络性能,包括诸如如何加快WordPress网站的速度和性能的感知之类的主题 。 但是,如果您仍然认为速度无关紧要,则KISSmetrics的一篇文章提供了多个数字,说明网站的延迟如何导致转化率下降。

什么影响绩效 (What Affects Performance)

Before going into the ways you can improve your WordPress site performance, it is important to understand the factors which impact the performance of typical WordPress websites. Some of the biggest areas according to the official WordPress Codex include:

在探讨改善WordPress网站性能的方法之前,了解影响典型WordPress网站性能的因素非常重要。 根据官方WordPress Codex的一些最大领域包括:

Hosting: This is a topic which can span pages, but in a nutshell for anything mission critical, you should be using a virtual private server (VPS) or dedicated box at the least. While shared hosting is dirt cheap, performance often is lacklustre because you’re sharing resources with hundreds (if not thousands) of users. On VPS and dedicated machines, resources are dedicated meaning you are guaranteed what the host promises.

托管:这是一个可以跨越多个页面的主题,但是概括地说,对于任何关键任务,您至少应使用虚拟专用服务器(VPS)或专用盒。 尽管共享托管非常便宜,但是性能却往往很低下,因为您要与数百个(如果不是数千个)用户共享资源。 在VPS和专用计算机上,资源是专用的,这意味着您可以保证主机所承诺的。

Number of servers: For highly trafficked sites, you will need multiple servers to spread the load rather than having a single server bear the brunt of your visitors. Load balancing can be a complex topic, but in a nutshell, you need to keep in mind that for high traffic settings, multiple lower end machines is better than having a single high end box.

服务器数量:对于人流量大的站点,您将需要多个服务器来分散负载,而不是让单个服务器首当其冲地吸引访问者。 负载平衡可能是一个复杂的主题,但总而言之,您需要记住,对于高流量设置,多台低端计算机比拥有一个高端设备要好。

Hardware performance: Using Solid State Drives (SSDs) and high performance servers can greatly boost your site’s performance. If you don’t want to pay for a SSD, purchasing extra RAM for your server is a more affordable option to boost performance.

硬件性能:使用固态驱动器(SSD)和高性能服务器可以大大提高站点的性能。 如果您不想为SSD付费,则为服务器购买额外的RAM是提高性能的更实惠的选择。

检查您的站点是否存在瓶颈 (Checking Your Site for Bottlenecks)

Before tuning your WordPress install, you need to make sure that you are aware of the areas where your site needs improvement. By using a tool such as YSlow, you can determine the precise steps you need to take to improve your sites performance. YSlow is a great asset as it provides actionable steps which you can follow to improve your performance.

在调整WordPress安装之前,您需要确保您了解网站需要改进的地方。 通过使用诸如YSlow之类的工具,您可以确定需要采取的精确步骤来提高站点性能。 YSlow是一项很棒的资产,因为它提供了可操作的步骤,您可以按照这些步骤来提高性能。

The YSlow Browser Extension

YSlow浏览器扩展

Another tool you can use for performance testing is Pingdom. While it doesn’t provide you with the same guidance as YSlow, Pingdom is useful for determining which scripts, page elements or pieces of code are taking the longest to load. From there, you can work on optimizing specific elements to boost your speed.

可以用于性能测试的另一个工具是Pingdom 。 虽然Pingdom不能为您提供与YSlow相同的指导,但它对于确定加载时间最长的脚本,页面元素或代码段很有用。 从那里,您可以优化特定元素以提高速度。

简单的方法来提高性能 (Easy Ways to Improve Performance)

While performance tuning is a vast topic, you can improve your website by following a few simple steps.

虽然性能调优是一个广泛的话题,但是您可以通过执行一些简单的步骤来改进您的网站。

在网站上启用缓存 (Enable Caching on Your Website)

Caching is one of the easiest ways to improve your site performance as it can be done with the flip of the switch and a few settings changes. We’ve already discussed caching in an article on Managed WordPress Hosting so we won’t discuss it in-depth here. In a nutshell though, if you’re looking to enable caching on your website W3 Total Cache is the tool for you.

缓存是提高站点性能的最简单方法之一,因为只需轻按一下开关并进行一些设置更改即可完成。 我们已经在有关托管WordPress托管的文章中讨论了缓存,因此在此不做深入讨论。 简而言之,如果您希望在网站上启用缓存,那么W3 Total Cache是适合您的工具。

The W3 Total Cache WordPress Plugin

W3 Total Cache WordPress插件

If you really want to take your caching to the next level, you should look into a reverse proxy such as Varnish Cache. Although it’s far from the easiest system to install on your website, if you’re operating a high-traffic website, this is a technology you should look into.

如果您确实想将缓存提高到一个新的水平,则应考虑使用反向代理,例如Varnish Cache 。 尽管它不是最容易在网站上安装的系统,但是如果您经营的是人流量大的网站,则应研究该技术。

整合CDN (Integrate a CDN)

By using the previously mentioned W3 Total Cache or popular service Cloudflare, you can ensure your website load times are reduced by having the content deployed from servers which are closest to your visitors. As this has been covered before in the previously mentioned article on WordPress hosting, we’re going to move on to additional tips to help your site performance.

通过使用前面提到的W3 Total Cache或流行的服务Cloudflare ,可以通过从与您的访问者最接近的服务器部署内容来确保减少网站加载时间。 正如前面提到的有关WordPress托管的文章中已介绍过的那样,我们将继续介绍其他技巧以帮助您提高网站性能。

使用更少的插件 (Use Less Plugins)

One of the greatest aspects of WordPress is its extensibility, however as with any computer, if you keep adding software without discretion, the performance will drop significantly. While it can be easy to use a plugin to modify WordPress, as a rule of thumb, you should only install a plugin if it is adding significant value which cannot be done with a few simple code tweaks. If you aren’t using a plugin at the moment but you think you’ll need it down the road, then disable it.

WordPress的最大方面之一是它的可扩展性,但是与任何计算机一样,如果您不加考虑地继续添加软件,性能将会大大下降。 虽然使用插件来修改WordPress很容易,但是根据经验,您仅应在插件增加了可观的价值的情况下安装插件,而这需要通过一些简单的代码调整即可完成。 如果您目前不使用插件,但您认为以后会需要它,请禁用它。

主题优化 (Theme Optimization)

While theme optimization can be a complex topic, below are a few key points taken from the WordPress Codex on the topic.

尽管主题优化可能是一个复杂的主题,但以下是有关该主题的WordPress Codex的一些关键点。

Image files

图片文件

Avoid unnecessary images such as using pictures instead of using standard type.

避免使用不必要的图像,例如使用图片而不是标准类型。

Ensure that all images are optimized for the web (Photoshop has a specific export option for this) and ensure that you are using JPEG/GIF/PNG as the file format.

确保所有图像均已针对Web优化(Photoshop为此提供了特定的导出选项),​​并确保您使用JPEG / GIF / PNG作为文件格式。

Use a plugin such as WP Smush.it to compress your images as they are added to your media library.

在将图像添加到媒体库后,使用WP Smush.it之类的插件压缩图像。

File count and size

文件数和大小

If possible, try minimizing the number of files which are required to display your website.

如果可能,请尝试最小化显示您的网站所需的文件数。

Combine CSS and JavaScript files into a single file where applicable.

将CSS和JavaScript文件合并为一个文件(如果适用)。

Minify script files where possible. The previously mentioned W3 Total Cache plugin has this capability built in.

尽可能缩小脚本文件。 前面提到的W3 Total Cache插件内置了此功能。

Query reduction/optimization

查询减少/优化

If possible, try hard coding values into static areas of your website such as your charset and site title.

如果可能,请尝试将值硬编码到网站的静态区域中,例如字符集和网站标题。

If you have menus that rarely change, also try hardcoding those where possible.

如果您的菜单很少更改,也请尝试对这些菜单进行硬编码。

更进一步 (Taking it Further)

While this guide has provided you with enough tips to help you get started with tuning WordPress for optimal performance, it is far from comprehensive. If you’re planning to run a site with tons of constant traffic, you’ll want to consult an experienced server admin to help ensure that you’re doing everything you can to squeeze every bit of performance from your website. You also might want to consider the pros and cons of Managed WordPress Hosting since managed WordPress hosts often are able to answer WordPress specific questions other hosts will not touch. As mentioned earlier, we’ve written extensively about web performance on SitePoint, including a detailed article on WordPress performance optimization.

虽然本指南为您提供了足够的技巧,可以帮助您开始调整WordPress以获得最佳性能,但它远非全面。 如果您打算运行一个流量持续不断的站点,则需要咨询经验丰富的服务器管理员,以帮助确保您正在尽一切努力来提高网站的性能。 您还可能要考虑托管WordPress托管的利弊,因为托管WordPress托管主机通常能够回答其他托管主机无法解决的WordPress特定问题。 如前所述,我们已经在SitePoint上撰写了大量有关Web性能的文章,其中包括有关WordPress性能优化的详细文章 。

For the average WordPress website, following the previously mentioned tips should be sufficient for your day-to-day operations.

对于普通的WordPress网站,遵循前面提到的提示对于您的日常操作应该足够了。

翻译自: https://www.sitepoint.com/tuning-wordpress-to-handle-higher-amounts-of-traffic/

最新回复(0)