Support » Fixing WordPress » Something causing crippling CPU spike

  • andrewjourney

    (@andrewjourney)


    I’m fairly new to self-hosting WordPress. I’ve been having an issue with sudden spikes in CPU usage that are causing my site to be temporarily disabled by my hosting service.

    At first I thought it was Jetpack, so I killed it and replaced the subscription feature I was after by using MailPoet3 instead.

    When I opened a post to edit it to today, the CPU spiked. (And my site was then disabled for a short time.) But I edited the post again later and the CPU didn’t spike.

    My only active plugins:
    – Classic Editor
    – Heartbeat Control by WP Rocket (only allows ajax on post edits, with 60s saves)
    – LiteSpeed Cache (recommended by my hosting service)
    – Loginizer
    – MailPoet 3

    Any advice? I’m perplexed!

    Thanks,
    Andrew

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 31 total)
  • Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    The only way to track it down is to check each element one at a time.

    Please attempt to disable all plugins, and switch to the default Twenty Nineteen theme. If the problem goes away, enable them one by one to identify the source of the problem.

    andrewjourney

    (@andrewjourney)

    Thanks, James. I was hoping to avoid that since the spikes are intermittent and occur only once or twice or three times a day. It’s probably going to take a week to to through that “elimination” process.

    If anyone knows of known issues with the plugins, then let me know.

    In the meantime, I’ll slog through building it back up from the ground up and see what happens.

    Thanks!
    Andrew

    James Lee

    (@jameslhc)

    I agree with James that the best way to check this is to disable the plugins and re-enable them one by one.

    You mentioned that this is intermittent. Does that mean that the CPU usage may or may not spike when you are editing a post?

    One other possibility to consider is WP Cron. You may want to check if the CPU spike corresponds to the WP Cron.

    based on the plugin list, the Litespeed Cache could cause CPU spikes when it generates cached pages. Try to disable it and see if it solves the issue.

    You can try to ask your hosting provider about the CPU spikes. They have access to the server log files for more information.

    andrewjourney

    (@andrewjourney)

    James, James, and Liew, it does seem primarily linked to me creating or editing posts. But not every time that I edit. I was having spikes prior to installing Litespeed Cache.
    Looking at the server log, there are two processes at the time of the latest fault:
    xmlrpo.php
    wp-chron.php
    I decided to start last night by turning all the Heartbeat API instances with Heartbeat Control. But that hasn’t seemed to make any difference since I had a fault today anyway.

    Thanks,
    Andrew

    James Lee

    (@jameslhc)

    Can you let us know how much CPU were being used for each of the file year you mentioned during the “Fault”?

    You may be under an attack of some sort. Blocking access to WP-Admin and XMLRPC may help. Putting your website behind CloudFlare should also help.

    andrewjourney

    (@andrewjourney)

    Thanks, James.

    My hosting plan limits my server usage to 50% of the CPU.

    lsphp:ome/pickleb1/pickleballjourney.com/xmlrpc.php 12%
    lsphp:ome/pickleb1/pickleballjourney.com/xmlrpc.php 21%
    lsphp:me/pickleb1/pickleballjourney.com/wp-cron.php N/A
    lsphp:ome/pickleb1/pickleballjourney.com/xmlrpc.php 21%

    I don’t know if those are concurrent processes or not, the cPanel report isn’t super obvious, but if concurrent, then they total to 54% which would cause the fault.

    I wouldn’t think it’s an attack, the site has only been up a week, but dunno.

    I use my WP phone app to upload photos to media. If I turn off XMLRPC, would that prevent mobile uploading?

    As far as blocking access to WP-Admin, is this good advice here?
    https://www.wpbeginner.com/wp-tutorials/11-vital-tips-and-hacks-to-protect-your-wordpress-admin-area/
    Or would you recommend a different article?

    Thanks!
    Andrew

    yes, blocking xmlrpc.php will help. Login attemps via xml-rpc is a common brute force attack.

    Yes, turn off XMLRPC will prevent WP phone app mobile uploading.

    Alternatively, you can try to use a security plugin that allows certain XMLRPC access. Ninjafirewall can block XMLRPC “system.multicall” method which often used in brute force attack while allowing app access.

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    This might help with that too: https://wordpress.org/plugins/block-bad-queries/

    andrewjourney

    (@andrewjourney)

    The more I look at this, the more I’m convinced it only happens when I’m editing. But it’s not every time that I’m editing.

    Here are the processes for my latest fault:

    pickleballjourney.pickleballforums.com/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag&q=David+n
    
    pickleballjourney.pickleballforums.com/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag&q=David+
    
    pickleballjourney.pickleballforums.com/wp-cron.php?doing_wp_cron=1572839895.2435779571533203125000
    
    pickleballjourney.pickleballforums.com/xmlrpc.php

    I was starting to think that when I add tags to a post, it spikes that CPU, but I added more tags to a post I’m writing this morning and no fault has happened. So bizarre.

    I’ve gone ahead and swapped out the wp-cron for a cPanel cron as described here:
    https://www.ecenica.com/support/answer/replace-wordpress-cron-cpanel-cron-job/

    I might disable XMLRPC and stop using the mobile app or just limit access to specific IPs that I know are mine.

    Thanks,
    Andrew

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    None of those seem out of place.

    It also could just be an overloaded server in general. These shared servers often have thousands of sites on them taking the same resources, and you could be on a server with a thousand unpopular sites or a thousand incredibly popular sites.

    andrewjourney

    (@andrewjourney)

    Thanks, James, that’s helpful.

    It is on a shared server and it has a 50% CPU limit. Maybe it’s a virtual machine, like a virtual Commodore 64 or something…

    “0.5 CPU Core, 0.5 GB RAM, 10 GB SSD”
    (I have no idea what the “core” is…)

    Is there a recommended minimum for WP? It’s not a lot of traffic on my site.

    Andrew

    James Lee

    (@jameslhc)

    If disabling XMLRPC doesn’t help, you may want to consider upgrading to a higher plan.

    A plan with 0.5 Core of CPU and 0.5 GB of RAM may work for a small WordPress installation but ideally you will want double of that if possible to run a production website.

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    Yeah, there is no stated minimum, but servers are like clothes, you eventually grow out of them.

    andrewjourney

    (@andrewjourney)

    I figured it out.

    Tags overload the CPU. Every time, for any post, if I added several tags at once, the server would disable my site.

    When I add a tag to a post, from what I can tell, WP looks through my 330+ posts. Whatever algorithm that WP is using, I think it’s crap. It shouldn’t use hardly any CPU for doing a tag search.

    So, I stop doing tags (I’m not sure how useful they are anyway) or upgrade my hosting plan.

    Thanks!
    Andrew

Viewing 15 replies - 1 through 15 (of 31 total)
  • You must be logged in to reply to this topic.