How to set up memory_limit value for WordPress

Increasing memory_limit for WP Fast Total Search plugin – why and how?

In this short article, I will tell you why we will need to increase the amount of script memory for the WP Fast Total Search plugin to work properly compared to WordPress default requirements, how to do it, and whether it is really that painful for your site and whether you should worry about it.

  1. What is script memory and memory_limit?
  2. What special requirements does the WP Fast Total Search plugin have and why?
  3. How can increasing the amount of script memory affect my budget?
  4. Step-by-step instructions to increase the amount of script memory in your WordPress.

What is script memory and memory_limit?

Script memory is the amount of memory that is allocated by PHP to run scripts within a single startup session. In our case, these are the PHP scripts that run on your WordPress site. The memory_limit parameter determines how much memory can be used to run each such script.

By default in WordPress, this parameter is set to 64M – 64 megabytes. This is enough to run ‘pure’ WordPress without plugins. But when any plugins are installed, this requirement naturally increases – for example, the popular Woocommerce plugin requires a minimum of 128 megabytes of script memory.

What special requirements does the WP Fast Total Search plugin have and why?

As you already know, the WP Fast Total Search plugin allows you to organize a fast search within your WordPress site without using third-party services. All the work is organized by your server, on which the site itself runs, and the data is also placed in your database.

To implement this mechanism, the plugin uses a two-step scheme of work. In the first step, it traverses all records on the site following the specified Indexing Rules, extracts the data necessary for the search from all primary and secondary fields of the post (again, following the specified indexing rules), and places them in a structured form in the database.

This task is performed by the PHP interpreter of your WordPress site in the background and may require a rather large amount of script memory, as the amount of text data inside the post may be in the tens of megabytes. The entire operation of converting data from one post should be completed in one script run. Breaking the task into parts to save server resources during indexing would result in too much slowdown. Therefore, the maximum memory size for running the script should not be less than 256 megabytes and ideally should be 512 megabytes or more. Actually, this amount is not so critical for you and your server, and below we will explain why.

The second step is searching for information. At this step, the algorithm’s speed is especially critical, because your users would like to see the search results instantly.

We have organized the work of the script so that it can scan the search index for units or tens of milliseconds, at the same time it can return from the database thousands and tens of thousands of ID records with service information, and all this information should ideally be placed in the script memory.

Yes, there is a special mechanism implemented in the WPFTS plugin code, which will process a large amount of information found in the database in pieces, so as not to exceed the allocated amount of script memory, but in this case, the result will be significantly slower and users will notice it.

That’s why the increase of script memory is critical for the second step of the algorithm. In our tests, information fragmentation into pieces did not occur already with 300 thousand posts and 256 megabytes of allocated script memory. That’s why we can be sure that the search will be as fast as possible if memory_limit is set to 512M.

How can increasing the amount of script memory affect my budget?

Increasing script memory may seem expensive, but it isn’t.

Firstly, you don’t pay for every megabyte of memory, you pay for the resources available to you on the server. Increasing memory_limit by 400-500 megabytes is unlikely to have a big impact on your costs, and probably won’t have any impact at all. The fact is that web hosting service providers assume that your scripts may consume a large amount of memory during peak load hours and therefore usually the physical memory on the server is dozen times larger than the default memory_limit value. An overwhelming number of hosting providers do not prohibit changing memory_limit and do not charge for this value in any way.

Secondly, the performance of your site is far more important than a slight increase in hosting costs. Users who can easily and quickly find information on your site are more likely to return to you. This is what will ultimately lead to increased sales or other positive results, not a few dollars a month increase in hosting costs.

Although, let’s repeat, limiting memory_limit by any hosting tariff conditions is a very rare phenomenon (we, for example, have never encountered such a thing).

Step-by-step instructions to increase the amount of script memory in your WordPress server

To change the memory_limit parameter, you will need access to the php.ini configuration file on your server. The way to edit it depends on your hosting provider:

  1. Using cPanel: If your hosting provider gives you access to cPanel, you will be able to find php.ini under ‘PHP Settings’. In this section, you can change the memory_limit or set a custom configuration for your site.
  2. Using an FTP client: If you do not have access to cPanel, you can edit php.ini using an FTP client such as FileZilla. Alternatively, if you own a VPS or Dedicated server, you can log into the server using root access and edit the php.ini file using a text editor inside the console. This file is usually located in the /etc/php/ folder. But be careful! Careless modification of the files in this folder can cause your site and server to fail.

In some cases, you can set memory_limit directly in your site’s wp-config.php file. To do this, add the following line to that file:

define(‘WP_MEMORY_LIMIT’, ‘512M’);

Replace 512M with the desired memory size in megabytes.

Important! Before modifying the php.ini configuration file, it is recommended to make a backup copy of it.

Conclusion

Increasing the script memory to run your WordPress site is an important but often forgotten condition for stable site performance, especially one loaded with plugins like WP Fast Total Search. This will not only give you faster site search speeds, but also stable site performance, leading to a better UX and higher conversions.

Don’t be afraid to experiment! Try changing memory_limit and test the result.

3 2 votes
Article Rating
Was it useful? Share the experience!
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments