WordPress:High Traffic Tips For WordPress

来自站长百科
Xxf3325讨论 | 贡献2008年6月19日 (四) 18:06的版本 (新页面: 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...)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航、​ 搜索

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?

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.

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.

See also WordPress:WordPress Optimization

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.

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

  • [[WordPress:#Processor Limitations|Processor Limitations]]
  • [[WordPress:#Network Limitations|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.

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 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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!

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.

Typical Requirements by 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.

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

Still working on obtaining 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.

WP-Cache

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-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.

Turn Off or Limit WordPress Plugins and Graphics

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

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.

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.

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

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.

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

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.

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 Dedicated Hosting, try upgrading to Dedicated Hosting.
  • 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.