How do I reduce my GPU usage?


Browse by products and services

  • Applies to: Grid
    • Difficulty: Medium
    • Time Needed: 30
    • Tools Required: AccountCenter access, SSH

READ ME FIRST

This article is provided as a courtesy. Troubleshooting the functionality and efficiency of web applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Overview

This article discusses the process of identifying the cause of GPU overages, as well as reducing GPU usage.

Identifying The Cause Of GPU Overages

To begin, take a look at your GPU report. For more information, see Understanding the GPU Tool

Specifically, you want to first see if your GPU usage has been consistent, or has spiked suddenly. In the event of a spike in GPU usage, you will want to see if any changes have been made to your web content around that time, such as a new theme or plugin. If so, it is likely that the increased GPU usage is due to this recent change in your content. If no changes have been made, or your GPU usage has been consistent, you will next want to take a look at your GPU usage per file. This will show you which files on your website are requiring the highest amount of GPU. Quite often, excessive GPU usage can be attributed to a particularly inefficient script that requires a signficant amount of processing power.

Reducing GPU Usage

Find and block incoming traffic

If your GPU overage is due to an increase in traffic, it may be helpful to block illegitimate traffic. To figure out where your traffic is coming from, you can log into your Grid via SSH and run the following command in your logs directory ( /home/00000/logs/ ):

cat access_log-2010-10* | grep example.com | awk '{print $1}' | sort -n | uniq -c | sort -nr | head

This command shows the top 10 visiting IPs to example.com. The first number listed is the number of times the IP visited since Oct 1, 2010:

14608 12.34.56.78
12700 34.56.78.12
3107 56.78.12.34
2833 78.12.34.56
2453 12.33.45.67
2440 12.34.55.67
2235 34.56.77.89
2157 34.56.78.99
1974 56.78.99.12
1812 78.99.12.23

If you believe some of those IP addresses are not coming from legitimate users, you can block them via an .htaccess file on your server by using order/allow/deny. This affects the way that Apache handles requests.

Order allow,deny
Deny from 12.34.56.78
Allow from all
Order deny,allow
Deny from all
Allow from 12.34.56.78

NOTE:

While this can help with blocking visitors, it can also stop legitimate visitors to your website. Use carefully. 

Install a caching plugin for your CMS

A caching plugin works by making static (pre-compiled) pages of your site, instead of making the Grid compile the page each time. It is always more efficient to have your website serve visitors static pages, and a properly configured caching plugin can have an effect on reducing GPU usage. This is particularly important when your website requires a significant amount of processing, receives high traffic, and cannot be altered. 

Due to the number of caching plugins available for CMS applications, it is left up to the user to compare and choose the right one for the job. Commonly utilized WordPress caching plugins incude the following:

http://wordpress.org/extend/plugins/wp-super-cache/

http://wordpress.org/extend/plugins/w3-total-cache/ 

Identify problem WordPress plugins

Many Grid websites use WordPress, and there are over 15,000 plugins listed on the WordPress site. Often, a faulty plugin can be responsible for increasing the GPU use of your service. You can log into your Grid via SSH, navigate to your WordPress folder, and run the following command to get an idea of how many times WordPress calls to a plugin for a single page:

strace php5 index.php 2>&1 | perl -ne 'if (/plugins\/([\w\d-_]*)/ ) { print "$1\n" }' | sort | uniq -c | sort -n

You will receive output like the following:

6 changelogger
14 google-sitemap-generator
21 wp-polls
23 akismet
28 simple-coming-soon-and-under-construction
30 all-in-one-seo-pack
53 wp-recaptcha
64 promotion-slider
196 wp-pagenavi
223 wptouch-pro
400 like-button-plugin-for-wordpress

In this example, you would want to investigate the "like-button-plugin-for-wordpress", since it is one of the top troublemakers.

Summary

Isolating the cause of GPU overages can often be difficult, but hopefully this information will get you moving in the right direction. All websites are different, and there are reasons you may be encountering such overages which are not covered in this KnowledgeBase article. Although troubleshooting the functionality of web content is outside the scope of support offered by (mt) Media Temple, please contact customer support if you require further assistance.