Support » Plugin: WooCommerce » Woocommerce causing huge CPU usage spike??

  • Resolved mimibondi


    My hosting company tells me that the reason I have had sudden huge CPU spikes (I get one randomly every couple of months or more) is because of ”the multiple execution of this code: – – [30/Jan/2018:19:59:22 -0600] “POST /wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=cc4eaf3f08 HTTP/1.0” 200 – “” “WordPress/4.9.2;”

    They tell me: ”We would recommend to address it with your developers in order to find the reason for it and fix it. We believe that it is the work of a plugin. Based on this part of the code:wp_1_wc_regenerate_images, I think that it is something connected to WooCommerce. It is doing something with the images. You could also check it with WooCommerce support. ”

    Does this make any sense to anyone out there please?? I just don’t have a developer and I don’t know how to fix it 🙁

    Thanks in advance!

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

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Gerhard Potgieter


    Hi there, the functionality in question is new since WooCommerce 3.3 so cannot be causing it for months since we have only released it yesterday.

    The code will also only ever execute if you switch themes or make changes to your image settings which should not be often.

    Should you wish you can disable it with the following piece of code

    add_filter( 'woocommerce_background_image_regeneration', '__return_false' );

    Thread Starter mimibondi


    Hi Gerhard, thank you so much for your reply.
    The spike today actually happened as I was trying to update my theme (I had to delete it and re-upload the new version) so it must be from that, this time.
    Would you let me know where to add this piece of code exactly?
    Thank you again for your time!

    Caleb Burks


    Automattic Happiness Engineer

    Here is a guide on where to add custom code to your site:

    This code makes it disables automatic thumbnail regeneration. So you could also just run a plugin like this to get it all done with at once:

    Thread Starter mimibondi


    Thank you Caleb!
    Just to clarify, my goal is not to regenerate thumbnails but to stop the CPU over usage that I am told is constant (with the occasional massive spike).So from what I understand from the guide, I can add the bit of code above to my the CSS panel of my Divi Child theme (only the parent theme gets updated).
    Please confirm this is correct so I don’t get all my sites to crash again 😉

    Hi all,
    I’m having the exact same issue. Unfortunately WordPress keeps DDoSing itself even after I add the filter: add_filter( 'woocommerce_background_image_regeneration', '__return_false' ); to my theme’s functions.php.
    It seemed to slow down somewhat but I’m still getting constant requests to "POST /wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=d9e36adeef HTTP/1.1" 200 - "<my domain>/wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=d9e36adeef" "WordPress/4.8.5;" from the hosts’ IP.
    This results in huge memory usage which eventually takes the site down.

    After some further debugging I’ve made some observations:
    WooCommerce queues all attachments to be re-generated when a user changes themes.
    So that filter can’t stop the background process once it already started:

    		if ( apply_filters( 'woocommerce_background_image_regeneration', true ) ) {
    			// Actions to handle image generation when settings change.
    			add_action( 'update_option_woocommerce_thumbnail_cropping', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 );
    			add_action( 'update_option_woocommerce_thumbnail_image_width', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 );
    			add_action( 'update_option_woocommerce_single_image_width', array( __CLASS__, 'maybe_regenerate_images_option_update' ), 10, 3 );
    			add_action( 'after_switch_theme', array( __CLASS__, 'maybe_regenerate_image_theme_switch' ) );

    But the batch is stored in the options table!

    	public function delete_all_batches() {
    		global $wpdb;
    		$table  = $wpdb->options;
    		$column = 'option_name';
    		if ( is_multisite() ) {
    			$table  = $wpdb->sitemeta;
    			$column = 'meta_key';
    		$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
    		$wpdb->query( $wpdb->prepare( "DELETE FROM {$table} WHERE {$column} LIKE %s", $key ) ); // @codingStandardsIgnoreLine.
    		return $this;
    	 * Kill process.
    	 * Stop processing queue items, clear cronjob and delete all batches.
    	public function kill_process() {
    		if ( ! $this->is_queue_empty() ) {
    			wp_clear_scheduled_hook( $this->cron_hook_identifier );

    So all you need to do is
    – Back up your database
    – SELECT FROM <your options table> WHERE option_name LIKE “%_batch_%”
    – Delete the option with the value that looks like a:4757:{i:11165;a:1:{s:13:"attachment_id";s:5:"12976";} ...
    – (optionally) use a plugin like wp-control to delete the cron job that looks like wp_1_wc_regenerate_images_cron_interval

    and it will stop the updates

    • This reply was modified 3 years, 2 months ago by derwentx.

    We are having the same issue with clients on our hosting servers. Non-stop /wp-admin/admin-ajax.php?action=wp_1_wc_regenerate_images&nonce=d9e36adeef wasting a ton of RAM and CPU usage.

    Example: 1 User with high LVE allocations of 8GB RAM 4xCPU 50 EP running 5.6 PHP-FPM with 10 second process idle timeout:

    Result: 2GB RAM used in 5 WC simultaneous resizing process using about 1.5-2 CPU when no traffic on site. Their site is plugin heavy with around a thousand images – so it’s not typical – but still enough to raise alarms for unusal usage pattern.

    The add_filter( ‘woocommerce_background_image_regeneration’, ‘__return_false’ ); in theme functions.php did absolutely nothing to stop the auto regenerate process once it had started – WC resizing processes ran for 4+ hours chewing up 1.5-2 CPU and 2GB ram the WHOLE TIME – this was during peak usage time for a shared server.

    Their web Master tried using WP Control to check the WP Cron – if the regenerate cron was deleted it auto added itself again.

    Can we get a fix to disable this “feature” – maybe this should be set to OFF as default and be MANUALLY TRIGGERED as an admin header alert option to run it after image size change / theme change detected.

    Is there something we can use as server admins to stop this auto generate once it kicks in?

    Looking at early impacts this auto generate has potential to cause major issues for both hosts / webmasters and reputation of WCommerce once a lot of users upgrade to the 3.3.x branch. Especially those with tons of images in their media library.

    Another quick 3.3.2 roll out with fix to disable and give WC team option to rethink this forced “feature”…?

    It won’t be long until others start complaining / realising WC is DOSing their own sites… hope this helps. 😉

    @derwentx – nice – good to know we can stop the process once batched 😀

    This is crazy. I’m on the top-tier shared plan at Siteground (GoGeek) and it used up my a whole days CPU/Executions in about 2 hours. I managed to stop it before my site was taken offline.

    • This reply was modified 3 years, 2 months ago by ozzymuppet.

    Something is very wrong with this update. We tried to change our theme today and it is maxing out our 16 core dedicated server because it appears that every single request is causing WP to try and regenerate images. Pretty much any POST request fails after timing out

    I’m having the exact same issue, exactly as described. Taking down hosting.

    This is a serious error, and using Woo Commerce with Divi is now making me look like an amateur in front of customers.

    Is there any update to fix the issue, rather than manually changing the option in the database? Thanks

    Same is happening to me…..Please can we get a permanent fix.

    My host has found a solution by adding the following code snippet into the functions.php file:

    add_filter( 'woocommerce_background_image_regeneration', '__return_false' );

    all craziness has stopped!

    Any news on this issue? I’m experiencing similar issues with my shared server and WooCommerce 3.3.1… I tried to update to WooCommerce 3.3.3 but that messed every single product picture on my site and had to go back to 3.3.1 again. Not sure about 3.3.2, as I went from 3.3.1 to 3.3.3 and back, but will try if this solves the high CPU usage issue.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Woocommerce causing huge CPU usage spike??’ is closed to new replies.