• Hi, interested to see if anyone can help

    I run multiple wordpress sites on a VPS, all using Wordfence. Been running for years, no problem. Recently, every 3 days at a predictable time, the CPU maxes out and the sites start to fall over.

    It all seems to be related to the recent Wordfence changes to scheduled scans – which are now every 72hours, at a time determined by the Wordfence servers. On checking the logs, I can see that Wordfence is initiating scans on most of the sites on this particular server at EXACTLY the same time, and it is this that’s killing the CPU.

    It was never a problem before, when scans ran every 24 hours, and I can only assume that the scheduling of those scans was different then.

    On reading the changelogs, I can see that there has been some attempt to prevent this exact problem (stuff about the WF servers detecting and delaying scans where it sees multiple instances on the same server). But that does not seem to be happening.

    I’m running PHP7.0-fpm with nginx, Debian 8 on a 2Gb RAM Digital Ocean droplet.

    I’ve enabled ‘low resource’ scans, which helps a bit by stretching out the scan stages, but the end result is the same. I can avoid the problem by disabling the scans, or at least the ‘scan file contents’ stages, but that rather defeats the object.

    I appreciate that a) a VPS with more cores would help this problem, and b) with Wordfence Pro I could manually schedule the time of the scans – but this configuration has always been fine until 10 sites start to scan simultaneously, and the cost of that number of Pro licences is just prohibitive.

    So if I’m right, I kinda get WHY this problem is happening, but I’d love to get some feedback from Wordfence about the logic behind kicking off all the scans at the same time. At the moment, I’m having to disable the automatic scanning for all of the sites, which means that WF is much less useful.

    Thanks in advance

Viewing 15 replies - 1 through 15 (of 15 total)
  • Can I ask a dumb question? Are all these sites yours?
    If they are, if you have 10 sites, all running on the same VPS, why are you not running them in a single WordPress Multi-Site setup? Rather than as individual separate WordPress copies, requiring independent WordFence, independent site scans, independent management, …, …?

    Just curious.

    Thread Starter pplong

    (@pplong)

    hey Caleb – no, they’re not all mine, they’re all quite different in terms of functionality, plugins etc, and I need the ability to move/migrate sites easily. I’m (definitely) no multisite expert, but I’ve made the decision in the past that it’s not the right solution in my case.
    Using separate WP instances has been fine in the past (with centralised plugin/theme management etc), but this recent WF update appears to have generated a new problem.

    Thanks for your reply though

    Hi @pplong,

    Could you please check the actual scans scheduled start time for each site?

    • Go to the Wordfence Tools page
    • Click the Diagnostics tab
    • Find the “wordfence_start_scheduled_scan” Cron Jobs and compare the scheduled times

    Do you confirm that the scheduled start times are consistent with the behaviour you’re seeing?

    Thread Starter pplong

    (@pplong)

    thanks @wfyann
    Yes the cron job times in Diagnostics do correspond to the times when it grinds to a halt.

    But that gave me another thought (this might well be what you’re getting at) – as a test, I’ve just checked ‘Delete Wordfence tables and data on deactivation’ and then gone ahead and deactivated/reactivated Wordfence – and that cron job is now scheduled for a different (albeit apparently random) time/day.

    So I guess it’s possible to effectively force wordfence to choose a different scan schedule – it’s a bit nasty, but it might help to get round the problem…

    thanks for looking, any further thoughts appreciated

    Hi @pplong,

    Could you please send me a Diagnostics report for a few sites?

    • Go to the Wordfence Tools page
    • Click the Diagnostics tab
    • Scroll down to the Send Report by Email section
    • Send the report to yann[at]wordfence[dot]com
    Thread Starter pplong

    (@pplong)

    thanks @wfyann – I’ve sent you diagnostics reports from 3 sites via email.

    Hi @pplong,

    Sorry about the delayed reply.

    I wonder if you exported settings from one of your Wordfence instances and then imported those settings into all other instances?

    Hi sorry to dig up a old thread

    I had similar issues with CPU maxing our. I have 5 wp sites on a vulture 2gb vps.

    I actually clone my website and then modify it for each client each time. So I do suspect I am copying across settings (as per your email above).

    What would be the best way arround this? Would deleting and reenabling the plugin work?

    Thank
    Z

    Hi

    Also to note, I actually have two separate wordfence start Cron jobs. Is this normal?

    Thanks
    Zed

    Thread Starter pplong

    (@pplong)

    Hi @trademark2k6

    You might not need to actually delete the plugin – I seem to remember that if you select ‘Delete Wordfence Tables and Data on deactivation’ – and then deactivate and reactivate the plugin, this will cause the scheduled scan time to regenerate.

    If you check the timing of the ‘wordfence_start_scheduled_scan’ cron job (within Tools – Diagnostics – Cron Jobs) before and after de/reactivation, you should see that the time has changed.

    Do that on 4 of your 5 sites, and the scheduled scan times should all be different.

    And on your other question, I always see two ‘wordfence_start_scheduled_scan’ cron jobs, as if two are always scheduled, usually 3 days apart. Normal, as far as I know.

    Hope that helps – just bear in mind that using this method will mean that you’ll need to reconfigure your WF settings if you were using anything customised.

    Hi pplong

    Thank you for coming back and answering. Should I deactivate and activate 4/5 sites an hour or two apart from each other? So they don’t again have scheduled times that are very close together?

    Also – apart from when the scans are taking place (which will obviously eat into the cpu time), should the wordfence plugin pretty much not effect cpu speed?

    On my monitoring logs I am seeing my cpu usage maxing our a few times a day. None of my other plugins really do anything intense. Only 1/5 websites are “live” so the rest shouldn’t really have any traffic (probably just me and one other person browsing). And the 1/5 site I am talking about should really only have traffic after 5pm (London time) as it’s a online website for a restaurant for customers to place orders. However my cpu is maxing out even first thing in the morning.

    Thread Starter pplong

    (@pplong)

    Hi @trademark2k6, no problem

    Well, these are only my observations, having used WF on a number of sites, so it is just my opinion, but:
    – I guess there’s no harm in staggering when you do the de/reactivation, although I’m not actually convinced that there’s a link between when you reactivate, and what the scheduled scan start time is – i.e. if you did two sites at once, I don’t think that will necessarily result in the same schedule time being selected by WF for both;
    – On an otherwise ‘quiet’ VPS, I’ve never noticed WF drawing attention to itself (resources-wise) for any other reason than scanning
    – I guess it could any number of things causing the CPU spikes, not necessarily related to WF. If it always happened at the same time of day, that’s gotta tell you something (e.g. backups all running at the same time?)
    – It depends on the rest of your server setup – I’ve certainly hit problems before with things like ‘sub-optimal’ configuration of php-fpm pools, resulting in more nginx/php services being spawned than necessary. But of course you might have a completely different setup.

    My first response is always to try to understand the pattern of behaviour (time-wise) and then drill into the logs for those times for clues.

    All of that said, I’m no expert by any means – but I do share your frustration.

    Many thanks. I just noticed most of my websites were staggered already, with the exception of one website. So 3 our of 4 site shall had different scanning schedules, and the other two had the same, which I have now changed.

    The cpu spikes don’t seem to correlate with the wordfence scans at all either.

    I did use updraftplus to take backups but I have disabled this now and now rely on the cloudways auto backups that happen 6am. Again I don’t think the cpu spikes correlate with this either.

    I’m far from a expert. This is my first vps. I usually use shared hosting and only just made the leap now. I can’t seem to understand what’s going on. Even when cpu isn’t maxed out, I can see moments where 60-70% is being use for 5-10 mins. But again, I can’t link this to a particular Cron job or visitor action.

    Thread Starter pplong

    (@pplong)

    Using a VPS is definitely going to be worthwhile in the end, it’s just the learning curve that’s the problem.

    Assuming that you’ve got SSH/console access to the VPS, I find that a tool like ‘htop’ is really useful because you can see a live view of the processes and which ones are hitting the CPU. You’ll just find yourself sitting there staring at it though.

    Aside from all that, I’m assuming that you don’t see spikes from ‘unwanted’ traffic at these times? e.g. if you look at the access logs, you’re not getting loads of hits to /wp-login.php or some other attempt to compromise the site? For sites that don’t require customer logins, I’ll always set the WF option for ‘immediately block invalid usernames’ because at least then each IP can only guess one username before it gets blocked. And set some sensible rate limiting rules too.

    I need to learn how to install such applications. At the moment I am relying on the cloudways admin panel to monitor my server. But it’s not exactly live.

    I did yesterday have a IP address that was attackih which was picked up by wordfence and also cloudways. But generally and honestly I don’t know how to check which IPs have accessed the site at a specific time. I’ll need to research!

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Automated scans on multiple sites all start exactly same time, killing CPU’ is closed to new replies.