How to fix a slow Nextcloud installation

0
683
Oracle enhances customer experience platform with a B2B refresh

Jack Wallen found his Nextcloud installations not up to par, so he discovered two tricks to boost their performance.

nextcloudhero.jpg

Image: Jack Wallen

I’ve installed Nextcloud countless times over the years. I’ve experienced installations that were flawless and some that were, well, less so. One thing I’ve noticed (on a regular basis) is that Nextcloud can tend to be a bit slower than I like it. When I’m swamped with deadlines, the last thing I need is to have to wait for my on-premise cloud installations to load. It can be frustrating, to say the least.

Because of this, I’ve spent plenty of time addressing the issue. Finally, I believe I’ve found a way to get the speed I need with the platform. This isn’t an ideal solution, but it’s one that seems to work every time. Although this fix won’t work for every instance, I’ve found that a number of my installations (at least of recent releases of the platform) respond well to what I’m about to show you.

SEE: COVID-19 workplace policy (TechRepublic Premium)

What you’ll need

In order to make this work, you’ll need a running instance of Nextcloud. You’ll need the ability to SSH into that installation and you’ll need a user with sudo privileges. 

How to adjust the PHP memory limit

This is one culprit that really hindered my Nextlcoud instances from performing well. Here’s the thing: Only do this if your machine has the memory for it and is only being used for Nextcloud or other services that don’t depend on PHP. Even then, you should keep a close watch on the server. By adjusting the memory limit, any PHP application could consume a large amount of memory, leaving little for other services.

There are two ways to go about this: Raise the memory limit to a high number, or completely disable the memory limit. If your server has enough memory to dedicate to PHP, go ahead and raise to, say, 1 GB. If this server is only used for Nextcloud, you could disable the limit (again, keeping a close watch on it for trouble). 

To adjust the memory limit, open the php.ini file for editing. How you do that will depend on the installed version of PHP. To find out, issue the command:

php --version

The output of the command will indicate the version (which will inform your next command). Say your PHP version is 7.4. With that version, the command to open the file for editing would be:

sudo nano /etc/php/7.4/apache2/php.ini

The line you’re looking for starts with:

memory_limit =

To disable the limit, the line would be:

memory_limit = -1

If you want to raise the limit to, say, 1 GB, that line would be:

memory_limit = 1024M

Or maybe 2G:

memory_limit = 2048M

Even with memory limits of 1024 and 2048, I still experience poorer performance than I prefer. The only way I can really eke out the speed I require is by disabling the memory limit.

Once you’ve made the change, you’ll need to restart Apache with the command:

sudo systemctl restart apache2

Open Nextcloud and see if it performs more to your liking.

How to fix missing indices

Now that we have the memory limit out of the way, the next issue lies within the database. In a few of my installations (especially those that were upgrades), there were indices missing in the database. If you’re not a database admin (or a lover of words), indices is the plural of index. With regards to databases, an index is a data structure that speeds up data retrieval operations on a database. When there are missing indices, the speed of your Nextcloud installation will be negatively impacted. 

How do you fix this? Fortunately, the developers included a handy command for such purposes. The command is the occ tool, which has to be run by the php user. 

It’s important to note that you should run the command to fix the missing indices at a time when your Nextcloud installation isn’t being used. Run this command when Nextcloud is in use and you could lose data.

Before you can use the occ tool, log in to your Nextcloud server and change into the directory housing the installation with the command:

cd /var/www/html/nextcloud

The command to add the missing indices is:

sudo -u www-data php occ db:add-missing-indices

Depending on how much data is in your database, this command can take some time. When it completes, log back in to Nextcloud and see if performing is improved.

If you find your Nextcloud installations taking far too much time to respond to your requests, these two steps should bring about significant performance increases. 

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Also see

Source is TechRepublic

Vorig artikelA huge tech company just killed the 9-5 workday for good
Volgend artikelHow to prevent and cure burnout in your team