blog-image

Nextcloud - Slowness issue

(**) Translated with www.DeepL.com/Translator

The slowness problems with Nextcloud can come from several parameters (disk speed, architecture,…).

The problem I encountered is simply related to DNS (Domain Name Service).

Depending on your architecture:

  • A server with all stacks
  • or a distributed architecture (one php server, one sgbdr server, one redis server, one file server)

All servers involved in the operation of Nextcloud must have access to the correct DNS information, otherwise it is a disaster.

To detect this type of incident, make a list of all the servers involved in your Nextcloud infrastructure and on each of the servers, try to resolve all the servers with one of these commands for example: “host”, “nslookup”, “dig”,…

host [server name]

But also the reverse

host [server IP address]

If you encounter an error, some of the slowness of NextCloud will be the cause.

DNS problems can vary but the most common error when managing your own DNS Bind is the “journal out of sync” error, which is related to a wrong increment of the “serial”.

To solve the problem, connect to the server that manages the DNS function, then :

systemctl restart bind9
# Out of sync error search
grep "journal out of sync with zone" /var/log/syslog
# If errors occur
rm -rf /var/cache/bind/*.jnl
# restart bind
systemctl restart bind9
# and search again for out of sync errors
grep "journal out of sync with zone" /var/log/syslog

Repeat the name resolution check on each of the servers involved in your Nextcloud infrastructure.

Automation

To be run on the DNS server (bind9)

cache="/var/cache/bind/"
res=$(grep "journal out of sync with zone" /var/log/syslog | tail -1)
if [ "$res" != "" ];then
        # looking for jnl files
        files=$(find "$cache" -name "*.jnl")
        if [ "$files" != "" ];then
                echo "syslog out of sync detected : "
                echo "*****************"
                echo "$res"
                echo "*****************"
                echo "Deleting files : $files"
                find "$cache" -name "*.jnl" -exec rm -rf {} \;
                echo "*****************"
                echo "Restarting bind9"
                systemctl restart bind9
        fi
fi

+++

Document licence : Creative Commons (CC BY-NC-ND 4.0)

THIS DOCUMENTATION IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND AND DISTRIBUTED FOR EDUCATIONAL PURPOSES ONLY. THE AUTHOR, CONTRIBUTORS TO THIS DOCUMENTATION OR ©MYTINYDC.COM SHALL IN NO EVENT BE LIABLE FOR ANY DIRECT OR INDIRECT DAMAGE THAT MAY RESULT FROM THE APPLICATION OF THE PROCEDURES IMPLEMENTED IN THIS DOCUMENTATION, OR FROM THE INCORRECT INTERPRETATION OF THIS DOCUMENT.

(**) Translated with www.DeepL.com/Translator