Optimizing your private server helps it to use less memory which saves you money as well as speeding up your websites. This article describes the steps to pinpoint and mitigate the source of any memory issues on a DreamHost VPS.
How to optimize your PS
Blocking abusive access
Common problems for sites are caused by search engine indexing bots or abusive viewers hammering them. When search engine bots hit a site, they usually hit it pretty hard. To minimize this issue, you should definitely set up a Robots.txt file. After that, it's possible that someone can crawl your site, systematically downloading every page, image, and file available. This could especially be the case if your site contains media (video, images, audio, and so on). Finding abusive accesses like this can often be more of an art than a science, but you can get some data on this by analyzing the access.log file for your websites.
View the following article for detailed information on how to check your access.log file and see who is hitting it the most:
Private servers are virtual servers running on a single host machine. The host machine controls IP tables for all private servers on it.
It's not possible to install and control your own custom IP tables on your private server while it's being managed by DreamHost.
If you wish to run your own custom IP tables, you must upgrade to a Dedicated server and manually install this software.
Hotlinking is when a site other than your own includes an image in their site that is actually hosted on your server. They do this by directly referencing the image's URL from your site in their own. This can cause massive problems for you if some of your hosted images are hotlinked in another popular site. Even a relatively low traffic site can cause poor server performance if this is the case. To prevent this from happening, you can review the Preventing hotlinking article.
Caching your site
As you've probably seen by now, PHP processes can take up a significant amount of memory. If your site is getting hammered with traffic, the fewer hits that have to spawn a PHP CGI process, the better. This can be accomplished by enabling caching on your site. Essentially, caching renders a PHP script and then "caches" that HTML output as a file. The next time that page is accessed, the server outputs the static HTML page, rather than process the PHP script again. The task of serving a static file requires far less memory and generally serves more efficiently, than the processing and execution of a PHP script. So if you're having memory trouble on your PS, it's essential that you confirm that you're running software that has caching functionality and that you enable the use of this feature.
Also, if you expect a large volume of website visitors, you can enable Cloudflare. This is a service that DreamHost partners with to add additional caching options for your websites.
Enabling FastCGI and XCache
Another improvement you can make in order to reduce memory usage is to turn on FastCGI and XCache for your domains that run PHP-based sites. Without FastCGI enabled, an entire PHP binary process has to be executed individually for each PHP page that's viewed in order to parse and process it.
Enabling FastCGI for all your PHP domains switches your sites over to using mod_fcgid (see Fcgid overview). What this means is that when a PHP script is hit by a browser, the PHP interpreter process begins, processes the script, and then stays in memory, waiting for another request. When a new request hits, it is sent to this running interpreter for processing, rather than spawn a new one. If you have a lot of sites or a lot of traffic, this can greatly reduce your overall memory usage.
Enabling this also allows you to enable XCache which essentially caches compiled PHP code in memory to output as PHP scripts are requested. For more information on configuring this after it's enabled, view the XCache article page. If you'd like additional information about XCache, the introduction page of the official XCache article is a good place to start.
View the following article for details on how to enable this feature:
If you're running multiple instances of the WordPress software on your private server, you should definitely review the 'WordPress Optimization' category for detailed articles.
Make sure to do the following with each installation:
- Always run the most recent version of WordPress.
- Install only essential plugins.
- Keep your plugins up-to-date.
- Remove/delete unused plugins as opposed to just deactivating them.
- Confirm your active theme isn't generating any errors in your error.log file (located in the same directory as the access.log).
- View Optimizing Page Load Time and make sure you have a popular WordPress caching plugin installed and configured. For example, W3TC or WP Super Cache.
- Please keep in mind that running a third-party WordPress caching plugin simultaneously with your panel’s XCache option can actually increase overall memory usage. It's best to pick either one or the other for your caching needs.
- Another useful tool to detect memory intensive third-party plugins is P3 (Plugin Performance Profiler) plugin for WordPress. Make sure to disable this plugin if you're not currently using it as it can increase your overall memory usage.
- Finally, compressing your image files improves loading time and reduces overall memory usage.
- Managing your VPS memory usage
- Private server overview
- Recovering from memory saturation
- Simulating high traffic
- Using the 'ps' command to troubleshoot your website
- Web server performance comparison
- How do I use XCache on a private server?
- How do I reboot my VPS?