Table of Contents
Content Error or Suggest an Edit
Notice a grammatical error or technical inaccuracy? Let us know; we will give you credit!
Introduction
This article comes to you today after trying to help someone with their WooCoomerce site and high server CPU load. This person also is suffering from the Pixel Your Site admin-ajax.php issue
The out of the box default WordPress/WooCommerce search works, but isn’t performant when you have a busy site and basic. Leading to folks looking for an alternative WooCommerce specific search plugin, which improves the UI but ultimately hits you right in the CPU.
WooComerce Search Plugins that Eat CPU
Fibosearch / Ajax Advanced WooCommerce Search
This has been my only real experience with a plugin that doesn’t perform well under heavily trafficked WooCommerce sites. Let’s look at the obvious issues.
Issue #1 – AJAX Search will trigger a search with each letter typed into the search box.
As you’re typing your search into the searchbox, once you hit 3 characters your search will be submitted and every character afterwards including spaces and deletions are submitted. Leading to a huge number of requests. Here is an example, a total of 7 search requests.
"GET search.php?s=tes "GET search.php?s=test "GET search.php?s=test "GET search.php?s=test%20e "GET search.php?s=test%20e "GET search.php?s=test%20ea "GET search.php?s=test%20ea
Now if each request returned in milliseconds and not seconds this wouldn’t be a problem. However the search.php file will load the WordPress bootstrap (wp-load.php) leading to more computation necessary for a search.
If you have 10 people on your site searching at the same time, which could lead to 7 individual search as they type. You now have 70 dynamic requests to service, as they cannot be cached.
What’s the solution? Implement a delay of 3-5 seconds between character inputs before showing results.
Issue #2 – No high performing API endpoint.
When a search request is submitted to search.php, the WordPress bootstrap is loaded which loads the entire WordPress environment. Since this is a simple search request, the WordPress REST API could be used instead bringing the response time down.
See my post WordPress Plugins utilizing admin-ajax.php causing Performance Issues which talks about this and how admin-ajax.php does the same. The WordPress REST API isn’t any better, but still better than loading the entire WordPress Environment.
Lastly, don’t store data in MySQL, use something like Redis or Memcache. Redis has the RediSearch module.
RediSearch is a source-available Redis module that enables querying, secondary indexing, and full-text search for Redis. These features enable multi-field queries, aggregation, exact phrase matching, numeric filtering, and geo filtering for text queries.
Solutions to Improve WooCommerce Search Performance
Right now the only way to improve the WooCommerce search is to utilize one of the following plugins.
ElasticPress
ElasticPress has a free and paid option, but ultimately uses ElasticPress and requires that you have access to install and run the elasticsearch service. Which offloads the search to elasticsearch completely.
Super Speedy Search (Affiliate Link)
One of the better search plugins out there by the speed export Dave Hilditch