WordPress:High Traffic Tips For WordPress

来自站长百科
Fludlen讨论 | 贡献2008年6月21日 (六) 17:15的版本
跳转至: 导航、​ 搜索

Have you wondered whether WordPress can handle high-volume traffic? Think of creating a high-traffic site or generating volumes of writing? Think that something you write might get enough attention to get "slashdotted" or dugg by digg, or some other high-traffic-generating site. Wonder if WordPress can handle the sheer volume of traffic or fail. Can WordPress handle all these situations?

你是否疑惑WordPress能否处理高流量?想到创建一个高流量的网站或者写出大量文章?你写的内容可能会引起很多人的注意,引起了"slashdotted"或者被digg dugg,或者其它的一些高流量站点。不知道WordPress能否处理大的流量。WordPress能够处理这些情况吗?

The simple answer is "Yes," but this is a conditional yes. There is a lot you need to consider and understand before you decide on WordPress as your publishing platform, and if you expect high traffic volumes. Running WordPress on basic shared hosting will not be sufficient for truly high-traffic sites.

最简单的答案是"能够,"但是是有条件限制的。如果你将WordPress作为你的出版平台,而且你期望很高的流量值,你需要考虑和领会许多问题。在basic shared hosting上运行的WordPress不能够满足拥有很高流量的站点。

Before selecting WordPress for your high-traffic site, you will need to check the following to ensure your site is ready for the anticipated traffic: The site server and it's software, upon which WordPress is dependent, needs to be sufficient for the traffic you anticipate and expect.

在为高流量站点选择WordPress之前,你需要核查以下的内容,来确保你的站点已经预期的流量做好了准备:WordPress依赖的站点服务器和软件,必须能够满足你期望的流量。

See also WordPress:WordPress Optimization

请看看WordPress最优化

Hardware Limitations

硬件局限性

"Can WordPress handle my traffic?" is the wrong question. Virtually any blogging platform -- indeed, any web application -- is only able to handle as much traffic as can be supported by the hardware on which it runs.

"WordPress 能够处理我的流量吗?"是一个错误的问题。几乎任何博客平台—的确这样,任何网络应用软件—只能够处理它所运行的硬件支持的流量。

Two physical barriers prevent your site from handling a high volume of hits:

两个物理性的障碍,阻止你的站点处理一个高volume of hits:

  • [[WordPress:#Processor Limitations|Processor Limitations]]
  • [[WordPress:#Network Limitations|Network Limitations]]
  • [[WordPress:#Processor Limitations|处理器局限性]]
  • [[WordPress:#Network Limitations|网络局限性]]

Processor Limitations

处理器局限性

To serve high-traffic web sites, you will have to contend with the demand that high traffic puts on your server's internal resources. Be sure that the general demand on your server is met by sufficient processor power and memory resources.

要服务于高流量的网站,你需要处理高流量对于服务器内部资源的需求。要确定对于服务器的一般需求能够由充分的处理器资源和内存资源来满足。

There can be more dependencies than what follows for publishing your WordPress site, however these are the ones that WordPress requires by default.

从属物要多于发行WordPress的附属,然而这些是WordPress默认要有的。

MySQL

MySQL

WordPress, as with many blogging and web applications, depends on MySQL to store data for producing output. Every request that WordPress makes to MySQL for reading or writing data puts load on the server.

WordPress,就如许多写博客和网络应用软件那样,取决于MySQL来储存数据,输送产出。WordPress对MySQL的每个请求,都是用来在阅读服务器,在服务器上编写数据,或者向服务器载入内容。

WordPress is continuously optimized to reduce the transactions required to perform its functions; However, in high-traffic situations, many simultaneous connections to the database can cause excessive load on the server. In this case, connections to the server may not complete, causing the typical "Connection timed out" response in the visitor's browser.

WordPress不断地最优化,来降低执行函数时,需要处理的步骤;然而,在高流量的情况下,许多对数据库的即时连接可能会导致服务器的过多载入。在这种情况下,连接到服务器可能不会完成,导致了典型的访客的浏览器上出现的回应"连接时间超时"。

In most cases, MySQL connection rates can be improved by either adjusting settings for MySQL, or providing more memory and processing power to the overworked server.

在大多数情况下,可以通过调整对于MySQL的设置,或者通过向过载的服务器提供更多的内存和处理能力,就可以提高MySQL连接率。

Web Service

网络服务

WordPress is a web-server-neutral application, meaning that it can run on many different platforms. Apache and Linux are the most robust platforms for running WordPress, but any server that supports PHP and MySQL will do.

WordPress是一个网络服务器中立的应用软件,意思是WordPress可以在许多不同的平台上运行。ApacheLinux是运行WordPress最有力的平台,但是任何支持PHPMySQL的服务器都能够运行WordPress。

Make sure your host features the most up-to-date and stable version of these platforms to create a strong environment in which to run WordPress.

要确定你的主机拥有这些最新的和稳定的平台,创建一个强健的环境,运行WordPress。

Choosing the best method to run PHP, the language that interprets the WordPress code, can also affect your server's performance. In CGI mode, the server creates a new instance of the PHP program for every PHP file that a visitor requests. In shared module mode (or ISAPI), a single library instance is used for each PHP hit. There are advantages and drawbacks to each method - while choosing the method for your server, be sure to keep in mind traffic and its demands on the server. 选择最好的方法来运行PHP,这个语言能够编译WordPress代码,而且能够影响你的服务器的执行效率。在CGI编码中,服务器创建了一个新的PHP程序,用于访客要求的PHP文件。在分享的模块编码(或者ISAPI中),一个单一的library instance 是用于每个PHP hit。每个方法都有优点和缺点-当为你的服务器选择一种方法的时候,要牢记流量和对服务器的需求。

Network Limitations

网络局限性

Depending on the quality of your server's connection to the Internet, you may not be able to serve as many pages as you want to as fast as you want to serve them.

根据你的服务器链接到因特网上的能力,你可能能够尽力地提供更多的网页。

Your server's network provider (your host or ISP) will usually connect your server to their internal network via an ethernet adapter. Adapters typically operate at certain standard maximum speeds, usually 10Mb/s, 100Mb/s, or 1Gb/s. Your server is physically incapable of transferring files of any kind in excess of this speed. There are additional barriers to your transfer rate that will likely reduce your server's speed even more.

你的服务器的网络供应商(你的主机 或者ISP)会通常通过一个以太网adapter,将你的服务器连接到他们的内部网络中。Adapters通常以一个标准的最小速度运行,通常是10Mb/s, 100Mb/s, 或者 1Gb/s。你的服务器本质上不能超出这个速度,来传输任何文件。你的传输率有一些额外的阻碍,很可能会更阻止服务器的速度。

First, it is important to note that many of these numbers (especially the speed of your server's network adapter) are theoretical. In practice, your server will never transfer files at the maximum rate specified by the adapter, because in addition to the actual data being transferred, the server is also sending and receiving routing information of different kinds that the internet requires to get data to your site visitors. Because of this "network overhead", only a fraction of the full bandwidth is available for actually transferring files.

首先,要注意,许多这样的数字(特别是你的服务器的网络adapter)是理论上的。在实际运行中,你的服务器从来都不易adapter规定的最小速率来传输文件,因为除了输送的正在数据之外,服务器还在输送和接收routing 信息,不同的因特网需要从你的站点访客中得到数据。因为这种"网络overhead",完整的带宽中只有一部分,能够真正地传输文件。

Second, your server is likely connected to various devices in your network provider's facilities that will limit your transfer rates more than the limits on your server's network adapter. These devices are in place because your network provider has to fraction out its limited bandwidth to many servers at its location, and all of the bandwidth must be shared.

其次,你的服务器可能链接到你的网络供应商的不同的设备上,这样会限制你的流量率,比你的服务器网络adapter的限制还多。这些设备在适当的位置中,因为你的网络供应商要将有限的带宽分给同一位置上许多的服务器,而且所有的带宽必须要分享。

Certain network providers allow you to "burst" data -- temporarily exceed a pre-set transfer speed limit -- in special cases when demand for your site content is high. The network provider's hardware is specially designed to know when this is required. Some providers charge extra for this feature, some do not, and others do not offer this feature at all. It's up to you to find out.

某个网络供应商允许你"burst"数据-暂时超过一个先前设置的速度限度--当对你的站点内容需求很高的时候,出现。网络供应商的硬件,精心设计,以知道什么时候需要这个。一些供应商对于这个功能收取额外的费用,有的供应商不收取,还有的供应商根本就不提供这种功能。这需要你自己去查找。

Network Transfer Speeds in Use

使用中的网络流量速度

To determine why the bandwidth of the connection is important to a high-traffic site, let's look at the math.

要决定为什么连接的带宽对于一个高流量的站点,至关重要,让我们来看看数学数据。

Assume your site receives 100,000 hits in a day. For the purpose of this computation, we will say that one "hit" is a single data transfer, whether that is a single file or a whole page and its supporting files. Averaged out, 100,000 hits in a day equates to 1.16 hits every second.

假如你的站点一天收到了100,000 hits。为了便于计算,我们假定一个"hit"是一个单一的数据传输,不管是一个单一文件还是一个完整的网页和网页的支持文件。最终达到平衡,一天100,000 hits 相当于每秒1.16 hits 。

Also assume the average hit generates 160KB of transferred data; HTML, images, CSS, downloaded files, etc. Every second, your site is transferring 190KB of data (160KB/hit * 1.16 hits/s). The total, 190KB/s, equals about 1.5Mb/s of sustained throughput. (Note that KB = Kilobytes and Mb = Megabits. Most network speeds are rated in bits per second, whereas file sizes are measured in bytes.) Many network providers cap the transfer rate of a site to about this level; some higher, some lower. However, only if each user visits in a nice succession will this steady rate be maintained.

同时假定一般的hit 产生160KB传输的数据;HTML,图像,CSS,下载的文件,等等。每秒,你的站点正在传输190KB的数据(160KB/hit * 1.16 hits/s)。总共, 190KB/s, 大概等于1.5Mb/s 持续不断地产量。 (注意 KB = KilobytesMb = Megabits。大多数网络流量速度是每秒bits ,然而文件大小是以字节来计算的。) 许多网络供应商将一个站点的流量大小cap到这个水平;有的更高一点,有的更低一点。然而,只有每个用户连续地访问,才能够保证这个持续的速率。

Usually, more than one user at a time will access your site. Sometimes during the day, nobody might access your site at all. If 10 people hit the site simultaneously per second, and that hit rate is sustained over a lengthy period -- not uncommon for a high-traffic site -- then you would need a 15Mb/s connection just to keep up with the simultaneous connections.

通常,一次不止有一个用户会访问你的站点。有的时候,可能又没有人访问你的站点。如果一秒中有十个人同时访问站点,而且这个访问量在很长的时间内,都保持不变—那么你就需要一个15MB/秒的连接,来维持这个即时的连接。

If your network adapters maximum theoretical speed is only 10Mb/s, your demand has already exceeded your capacity. WordPress had nothing to do with it.

如果理论上,你的网络adapters最小的速度只有10MB/秒,你的需求已经超过了你的接受力。WordPress与这个问题无关。

It is not necessary to receive 100,000 hits to cause this problem. Sustaining this rate of connectivity for a mere hour generates only 36,000 hits. If visitors concentrate their access to a certain time of day (or an automated comment spam script attempts to access your system multiple concurrent times while posting comments) then you could be left with many dropped requests.

没有必要接收100,000,导致这个问题。保持这个连接性的速率,一小时只产生36,000 hits。如果访客聚集在每个时刻来访问,(或者一个自动的评论垃圾广告脚本试图在发送评论的同时,访问你的系统),那么你就会留有许多未被处理的请求。

A 100Mb/s connection could handle up to 70 simultaneous connections at the same rate of download, but it is not likely that your network provider would offer the bandwidth that could fully use this speed without paying a premium. This is generally not something you can get with current shared hosting plans.

一个100Mb/秒能够处理70个同时的同一下载速度的连接,但是你的网络供应商可以提供一个带宽,在没有付额外费用就可以使用这个速度,这种情况是不可能的。这不是你在当前分享的主机计划中,能够处理好的事情。

Transfer Overages

传输过多的流量

If you are hosting large files such as videos, podcasts, or large photo archives is transfer overages. Hosting services often provide a fixed amount of overall transfer with their hosting plans. A plan may include only so many MB of transferred data. After your account has reached that amount, you will be charged for any extra data that is transferred. Depending on the host, this could be as much as $1/MB.

如果你正在托管大的文件,例如视屏,播客,或者大的图片存档,要传输大的流量。主机服务通过会提供托管计划内的固定的一个总流量。一个计划可能只会包含这麽多兆节的流量数据。你的流量打到了这个值之后,你就要支付任何额外传输的数据。有主机决定,这个额外的支付可能达到1美元每兆节。

At that rate, a single download of a 20MB file after you've reached your limit could cost you $20 extra on your hosting bill!

那样的话,你达到了提供的流量后,下载一个20MB的文件,可能要额外花去20美元。

Usually, the higher the transfer limit, the more costly your hosting plan will be. Some hosting services offer plans with no transfer limitations, which can be quite costly, but certainly less costly than paying for transfer overages on a high-traffic site.

通常,传输的限度越高,你的主机plan就会越昂贵。有的托管服务提供了plans,没有传输限制,可能会非常昂贵,但是肯定会比在一个高流量站点上支付超额的流量要便宜。

Typical Requirements by Benchmark

Benchmark 的一般要求

This space is reserved for showing the capabilities of a typical server setup under stressful load conditions. Comparing the configuration of a particular hosting service to these benchmarks may help give you a better idea of the capabilities of the server you're considering.
这个空间保留来显示在紧张的载入情况下,一个典型的服务器设置的容量。将特别的主机服务与这些benchmarks相比,你更加了解你想到的服务器的容量。

Note that any server you choose will likely be at least slightly different than the benchmarks shown here.

注意,你选择的任何服务器可能与这里所显示的benchmarks都有所不同。

Still working on obtaining benchmarks.

仍然努力获得benchmarks。

High Traffic Solutions

高流量解决方法

Like Kobe beef, WordPress will only be at its best when raised in the proper conditions. Here are a few things to try if you find that your WordPress site is not performing as well as it could due to high traffic issues.

Kobe beef相似,WordPress在适当的情况下,会尽量处于最好的状态。如果你发现由于高流量的原因,WordPress运行地不好,你可以尝试以下的一些步骤。

WP-Cache

WP-高速缓存

WP-Cache is a WordPress plugin that reduces the need to make many requests on the database by caching page output that has not changed. Fundamentally, when a visitor requests a page from your WordPress site, WP-Cache serves a stored, static version of the requested page. If the page does not exist, it is generated and stored in the cache as part of the request. If a page changes due to editing or a posted comment, the cache for that page is destroyed.

WP-高速缓存是WordPress插件,通常储存没有更改的页面产出,来减少在数据库中做出太多的请求的需要。一般来说,当一个访客要求WordPress站点中的一个网页的时候,WP-Cache提供一个储存的,网页的静态版本。如果访客要求的网页不存在,这个要求就会储存在高速缓存中,作为请求的一部分。如果因为编辑或者发表了评论之后,网页发生了变化,那个网页的储存也会随之破坏了。

WP-Cache will not reduce the load on pages not generated by WordPress. Also, if you want some content on the cached pages to remain dynamic, you will have to perform certain changes to the page to enable this.

WP-Cashe不会降低不是由WordPress产生的网页上的载入量。同时,如果你希望储存的网页上的一些内容保持是动态的,你需要做一些更改,来实现这一点。

Turn Off or Limit WordPress Plugins and Graphics

关闭或者限制WordPress插件和图形

When the traffic increases on your WordPress blog, all aspects of your blog's code and design elements also increase.

当你的WordPress博客上的流量增加的时候,博客编码和设计元素的所有方面都会增加。

For example, let's say the front page of your blog calls upon 8 graphics to create the "look" of your blog's design. Add to this number the various WordPress template files it takes to build your page. You've got the header, sidebar, footer, and post content area at a minimum. That's four more "calls" to files on your site. For 100 visitors, those files get loaded 1200 times. For 1000 visitors, those files are accessed and loaded 12000 times. This increases your bandwidth and server activity.

例如,假如你的博客的首页调用8个图形来创建博客设计的"外观"。给这个数字添加需要创建网页的不同的WordPress模板文件。你得到了标头,工具条,页底文字,以及最小的文章内容区域。你的站点上文件的4个更多的"调用"。对于1000个访客,这些文件就要被访问和载入12000次。这样增加了带宽和服务器活动性。

WordPress Plugins are also files that are "called" by your WordPress Theme. In turn, these make queries to your database to generate the information on your blog. The more WordPress Plugins, the more queries to your database.

WordPress插件也是文件,会被WordPress主题"调用"。然后,会向数据库中提交询问,在博客上产生信息。WordPress插件越多,数据库中的询问越多。

Combine all these access files and database queries with an exponential increase in visitors, and you have a lot of demand on your site.

随着访客的大量增长,将所有的这些access文件和数据库询问结合起来,你的站点上有许多请求。

You can lower the number of files accessed during heavy traffic times by limiting the number of graphics on your blog by editing the stylesheet and template files of your WordPress Theme.

通过编辑WordPress主题中的样式表和模板文件,可以限制博客上图形的数目,从而在高流量时段,降低可访问文件的数目。

You can also lower the number of files accessed and the queries to your database by turning off a few WordPress Plugins temporarily.

通过暂时地关闭一些WordPress插件,你也可以降低访问文件的数目和数据库的查询。

Go through your list of WordPress Plugins to see if there are any listed that you really could live without for a day or two.

仔细查看WordPress插件列表,看看有没有什么插件,你可以关闭一两天。

Keep the access to files and your database to a minimum as much as possible. After the heavy traffic volume has died down a bit, then you can reactivate and restore these features.

尽可能将对数据库和文件的访问保持到最小量。高流量降低了一点后,你就可以重新地激活并且重新启用这些功能。

New Hosting

新的托管

As painful as it may be to hear it, you might simply require a more powerful server.

虽然听起来有点悲伤,你可能需要一个更加强大的服务器。

Here is a simple outline of upgrade steps for a site that is having high-traffic problems. If you are having trouble with:

下面是关于高流量问题站点的更新步骤一个简单的大纲。如果你有以下这些问题:

  • Shared hosting, try upgrading to Virtual Dedicated Hosting.
  • 分享主机,试图升级到一个Virtual专用的主机。
  • Virtual Dedicated Hosting, try upgrading to Dedicated Hosting.
  • Virtual 专用主机,试着升级到专用主机。
  • Dedicated Hosting, try upgrading to a higher-powered dedicated server.
  • 专用主机,试着升级到一个功能更加强大的专用的服务器。
  • High-Powered Dedicated Hosting, it is time to talk with your host about multiple Load Balanced Servers.
  • 功能更加强大的专用的主机,要与你的主机谈论关于多个加载平衡的服务器。

In all cases, your server is only as capable as your network provider. If your provider does not provide the bandwidth you require, you may need to negotiate an increase with them, or find a different provider that can provide you with the bandwidth that your traffic requires.

在所有情况下,你的服务器与你的网络供应商的能力相同。如果你的供应商没有提供你需要的带宽,你可能需要与他们协商,增加带宽,或者找一个不同的供应商,可以提供你的流量所需要的带宽。