Cut Memory Usage Running Multiple WordPress Sites
Running several WordPress sites on one server can quickly exhaust memory (RAM), leading to slow loading, database connection errors, or even white screens of death. This guide shows you practical, safe ways to reduce memory usage per site, so more sites can share the same resources without upgrading your hosting plan. You’ll need admin access to your WordPress dashboard, cPanel or similar hosting control panel, and FTP or a file manager.
What You’ll Need
- Admin access to each WordPress site you manage
- Access to your hosting control panel (cPanel, Plesk, etc.) or FTP/SFTP client
- Ability to edit files like wp-config.php and .htaccess
- A basic understanding of PHP and MySQL (not required, but helpful)
Step-by-Step
- Identify the memory hogs. Install a plugin like Query Monitor or WP Server Stats on each site to see which plugins and themes use the most memory. Look at the “Memory Usage” section in the admin bar. Note the peak memory usage of each site. This tells you where to focus your efforts.
- Increase WordPress memory limit (but not too much). WordPress has a default memory limit of 40MB for single sites and 64MB for multisite. You can raise it by adding this line to wp-config.php:
define('WP_MEMORY_LIMIT', '128M');. Start with 128M and check if your site works. Don’t set it to 512M or more unless absolutely necessary – that just uses more RAM per site. - Disable unused plugins. Deactivate and delete any plugins you’re not actively using. Each active plugin loads PHP files and may run database queries. Even a small plugin can add 5-10MB per request. Go through your plugins list and ask: “Do I really need this?” If not, delete it.
- Use a lightweight theme. Heavy themes with page builders and lots of customizer options consume more memory. Switch to a minimal, fast theme like GeneratePress, Astra, or Kadence. If you must use a page builder, consider disabling it on pages that don’t need it.
- Enable caching. Caching plugins like W3 Total Cache or WP Super Cache generate static HTML files, so PHP doesn’t run on every visit. This drastically reduces memory usage per request. Configure page caching, browser caching, and object caching (if available).
- Optimize your database. Run a plugin like WP-Optimize or Advanced Database Cleaner to remove spam comments, post revisions, and transient options. A bloated database makes WordPress run more queries, which uses more memory. Schedule weekly cleanups.
- Limit post revisions. WordPress stores every revision of a post. Add this to wp-config.php:
define('WP_POST_REVISIONS', 5);to keep only the last 5 revisions. Or disable them entirely withdefine('WP_POST_REVISIONS', false);if you don’t need version history. - Use a CDN and offload media. Serve images and static files from a CDN (like Cloudflare) or an external service (like Amazon S3). This reduces the load on your server, freeing up memory for PHP processes.
- Implement object caching. If your hosting supports Redis or Memcached, enable object caching (via a plugin like Redis Object Cache). This stores database query results in memory, so PHP doesn’t have to fetch them repeatedly. This can cut memory usage significantly.
- Monitor and adjust. After each change, check your site’s memory usage again. Use a tool like New Relic or your hosting’s resource usage panel to see overall server memory. Adjust the memory limit in wp-config.php as needed – the goal is to have each site use just enough, not too much.
Common Mistakes
- Setting memory limit too high. Setting WP_MEMORY_LIMIT to 512M or 1G on every site is a common mistake. It doesn’t make your site faster; it just wastes RAM that other sites could use. Only increase it until your site works without errors.
- Not checking for memory leaks. A plugin might have a memory leak, slowly eating up RAM over time. If you notice memory usage climbing steadily, deactivate plugins one by one to find the culprit.
- Ignoring the theme. Many people focus on plugins but forget that themes can also be memory-hungry. A theme with a drag-and-drop builder can use more memory than 10 small plugins.
- Not cleaning up after deleting plugins. When you delete a plugin, it often leaves behind options in the database. These leftover options are loaded on every page load, wasting memory. Use a database cleanup plugin to remove them.
Tips
- Use a managed WordPress host. Managed hosts like WP Engine or Kinsta handle caching, object caching, and server-level memory optimization for you. It costs more, but saves you time and reduces memory issues.
- Consider a VPS. If you’re on shared hosting, you’re limited by the memory allocated to your account. A VPS gives you dedicated RAM, and you can tune PHP settings like
memory_limitandmax_childrenin php-fpm. - Use a plugin to manage multiple sites. Tools like ManageWP or MainWP let you update plugins and themes across all sites from one dashboard, saving you time and reducing the chance of leaving outdated plugins running.
- Schedule cron jobs wisely. WordPress runs cron jobs (like scheduled posts) on every visit. If you have many sites, set up a real cron job on the server to run WordPress cron less frequently. You can add
define('DISABLE_WP_CRON', true);to wp-config.php and set up a server cron to run wp-cron.php every 15 minutes.
Troubleshooting
- Site still runs out of memory after increasing limit. If you set the limit to 256M and still get errors, the problem is likely a plugin or theme with a memory leak. Deactivate all plugins and switch to a default theme (like Twenty Twenty-Four). If the error goes away, reactivate plugins one by one until you find the culprit.
- White screen of death after editing wp-config.php. You might have a syntax error. Check the file for typos, especially extra spaces or missing semicolons. If you can’t access the site, use FTP to download wp-config.php, fix it, and re-upload.
- Object caching causes errors. If Redis or Memcached isn’t properly configured, it can cause database connection errors. Disable the object caching plugin and check your server’s error logs. Make sure the caching service is running.
- Database cleanup plugin breaks a site. Some cleanup plugins remove too much, like transient data that’s still needed. Always backup your database before running a cleanup. If a site breaks, restore the backup.
- Memory limit not taking effect. Some hosting providers override WordPress’s memory limit in php.ini. Check your hosting control panel for a PHP settings section and set memory_limit there. If that doesn’t work, create a php.ini file in your WordPress root with
memory_limit = 256M.
Frequently Asked Questions
- What is a good memory limit for a single WordPress site? Most standard sites run fine with 128M. If you use a page builder or have many plugins, you might need 256M. Anything above that is usually a sign of a poorly coded plugin or theme.
- Does increasing WordPress memory limit affect all sites on the server? No, the WP_MEMORY_LIMIT constant only affects that specific WordPress installation. However, if you set it too high on multiple sites, the server’s total RAM can be exhausted.
- Is it better to use a caching plugin or a CDN? They serve different purposes. Caching reduces PHP execution, while a CDN reduces server bandwidth and load for static files. Both help reduce memory usage, so use both if possible.
- Can I disable WordPress cron to save memory? Yes, but you must set up a real cron job to run wp-cron.php. If you disable WP-Cron without a server cron, scheduled posts and updates won’t work.
- How do I check my current memory usage in WordPress? You can use a plugin like Query Monitor, or add this line to your theme’s functions.php:
error_log( memory_get_peak_usage() );and check your debug.log file. Or use a server-level tool like htop or your hosting dashboard. - Will using a lightweight theme really make a difference? Yes, especially if you have many sites. A theme that uses 20MB vs 50MB per page load can add up quickly. Switching to a minimal theme can reduce memory usage by 30-50% per site.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.