Nextcloud seems to have a bad reputation around here regarding performance. It never really bothered me, but when a comment on a post here yesterday talked about huge speed gains to be had with Postgres, I got curious and spent a few hours researching and tweaking my setup.

I thought I’d write up what I learned and maybe others can jump in with their insights to make this a good general overview.

To note, my installation initially started out with this docker compose stack from the official nextcloud docker images (as opposed to the AIO image or a source installation.) I run this behind an NGINX reverse proxy.

Sources of information

Improvements

Migrate DB to Postgres

What I did first is migrate from maridb to postgres, roughly following the blog post I linked above. I didn’t do any benchmarking, but page loads felt a little faster after that (but a far cry from the “way way faster” claims I’d read.)

Here's my process
  • add postgres container to compose file like so. I named mine “postgres”, added a “postgres” volume, and added it to depends_on for app and cron
  • run migration command from nextcloud app container like any other occ command. The migration process stopped with an error for a deactivated app so I completely removed it, dropped the postgres tables and started migration again and it went through. after migration, check admin settings/system to make sure Nextcloud is now using postgres. ./occ db:convert-type --password $POSTGRES_PASSWORD --all-apps pgsql $POSTGRES_USER postgres $POSTGRES_DB
  • remove old “db” container and volume and all references to it from compose file and run docker compose up -d --remove-orphans

Redis over Sockets

I followed above guide for connecting to Redis with sockets with details as stated below. This improved performance quite significantly. Very fast loads for files, calendar, etc. I haven’t yet changed the postgres connection over to sockets since the article spoke about minor improvements, but I might try this next.

Hints
  • the redis configuration (host, port, password, …) need to be set in config/config.php, as well as config/redis.config.php
  • the cron container needs to receive the same /etc/localtime and /etc/timezone volumes the app container did, as well as the volumes_from: tmp

Outlook

What have you done to improve your instance’s performance? Do you know good articles to share? I’m happy to edit this post to include any insights and make this a good source of information regarding Nextcloud performance.

  • dan@upvote.au
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    11 months ago

    Try MySQL instead of MariaDB. They have some performance tweaks in version 10 that aren’t present in MariaDB.

    Also, tune your MySQL (or MariaDB) server. Make sure all tables use InnoDB. Enable the slow query log and analyze slow queries (there may be missing indices). If there’s a lot of unique queries, increase the query cache size.

    The easy approach is to run MySQLTuner after the MySQL or MariaDB server has been up for at least a week, and go through its suggestions.

    There shouldn’t be a significant difference in performance between PostgreSQL and MySQL/MariaDB if both have been optimized. Out-of-the-box config isn’t ideal for a production system.

    • douglasg14b@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      Depends on how you’re using it. You can wrong an absolutely insane amount of performance out of postgres that you cannot with MySQL.

      I wonder how much next cloud leaves on the table?