Nextcloud web interface is slow

Nextcloud version: 18.04
Operating system and version: Ubuntu Server 18.04
Apache version: Apache 2.4.29
PHP version: 7.2.24
PHP memory limit: 512 MB
PHP Max Execution Time: 3600
MySQL version: 5.7.30

The problem I’m facing is that the web interface is too slow to load.
The web interface usually takes 10-30 seconds to load. Depending where you live in the world, this might sound ok, but usually websites load in 1-3 seconds in Bucharest. It also seems that if there isn’t any activity for a while (an hour or so), the interface kind of ‘goes to sleep’ - sort of speak - and i need to reload the tab in order to access it again.
Of course, the server never goes into suspend mode and even if the interface is not responding, I can still access the files via sync clients (like on Android for example).

The file access is very fast, though. So when the desktop client syncs the files on my drive or phone, it’s very fast. It seems the problem is with the web interface alone.

I don’t think it’s anything to do with my internet connection.
I live in Bucharest, Romania and we have some of the fastest internet in the world. When I download something online, I normally have speeds of 10-20 MB/s. I don’t think my ISP throttles my connection - as I’ve said, the file access is very fast. And my ISP even lets me setup my own dynamic dns and open whatever port I want on the router.

I also think my system should be fast enough.
The server is dedicated to Nextcloud only, and it’s connected via ethernet cable to the router.
The server runs on a HP Z200 workstation with an intel Xeon X3470 3GHz 4 core processor, 8GBs DDR3 RAM and 3 x 250 GB Seagate HDD ST3250312CS.
I am the only user on my Nextcloud and I usually don’t perform any heavy tasks. On average, the CPU shows 1% usage and RAM about 1.5 GB. I also have 250 GB of free hard disk space available.
Also, this issue is not with Nextcloud 18. I’ve been using Nextcloud for almost 2 years now, and it’s always been like this.
Also also 90% of the time I access the cloud from within Bucharest, so I’m not far away from the server.

I followed the instructions on this web page, and I did notice a slight increase in speed, but still not enough, and not always:
https://docs.nextcloud.com/server/18/admin_manual/installation/server_tuning.html?highlight=slow

I configured memcache this way, acording to the guide above. I hope it’s correct:

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',

I have enabled OP Cache as well. These are my settings:

opcache.enable=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=256
opcache.save_comments=1
opcache.revalidate_freq=1

I’ve also disabled the swap partition, and I’m only using RAM right now. I understand it had the potential to make things slower.

So, with all these things said, what can I do to make the web interface load faster and not ‘fall asleep’ again?

I know of course, there is no competition between my server and something like Google Drive, but all things above considered, I really think I should be able to have the same speeds as any commercial application and any other website I access, really. What do you guys think?

Is your primary storage S3 by chance?

no. i don’t use any external storage. just the hard drives in the workstation

When you open browser hit F12 (this should launch console) and click on Network tab. Then open your nextcloud page and you should se a bunch of requests taking place in console until page is fully loaded. When its finished examine the timings of each request and you should see which request (URL) takes so much time to load.

Have you tried different browsers?
Have you cleared browsing cache?

Users are local or external?

Was it this slow from the moment you installed it?
Have you tried updating separate components, e.g.PHP?

thanks for the idea. i did that and looked into the results, but i can’t really pinpoint something exactly.

thanks. this happens across the board, on different browsers, networks, versions.

i’m not a very advanced user, but is there a setting in my ubuntu server, maybe in the php or apache configs that makes the server ‘go to sleep’?
again, it’s not in suspend mode, but after the first time i load the cloud, the next times it’s faster. that’s until the next period of inactivity.
you know what i mean?

Maybe you have a slow database. Second time it gets the data for the database cache.

i was thinking about that. is there a way to put the database in RAM? it’s only 80 MB, and i don’t think it will ever get super big, because i’m the only user. i’m using MySQL 5.7.30 btw.

i also experimented a bit with the php and opcache memory limit. i increased them to 1GB. and i had some ok results yesterday. it did seem to be a bit faster, but today it’s lagging again.

what about changing the apache timeout / keepalive timeout settings? would that help me? i have apache 2.4.29 installed.
right now the Timeout is 300 sec, the MaxKeepAliveRequests 100, KeepAliveTimeout 5 sec.

What about using SSD instead of HDD? Makes big difference most of the time. Even with good specs I found that there are big differences between vps providers.

well, that is true, but unfortunately i don’t have the money to go for ssd right now. plus it would mean reinstalling everything. the file transfer is very fast, anyway, so it’s not necessarily a hdd thing.
more and more i think it’s about tuning the memory settings.

My configuration is slightly different (debian, mariadb, nginx) but otherwise I have similar problem as you (Nextcloud web-interface too slow). I tried everything: more and faster cpu, more ram, fast ssd, added all possible caching, tweaked php/nginx config for more servers/workers, deactivated many modules, but nothing helped.

I can not even find what actually is reason for NC web-interface being so slow. My vps is basically sitting idle, and yet NC is slow. Very slow. Any other website I tested on the same vps was blazingly fast, but not NC. I’m starting to think this is not bug, but “feature” of NC web-interface…

I think the performance is improved with newer version and no error in configuration panel. All new and correct?

Does top/htop show significant CPU activity during the wait? If not the server may be waiting for something.

I observed lags of this magnitude when there is a DNS problem on the server side. This problem may not be logged so it can be hard to spot. DNS timeout is usually 5 seconds. Try changing the DNS to 8.8.8.8 (google) or some other public server. You can also change the timeout in resolv.conf.

htop shows very little cpu / memory activity. around 1-2 % with short spikes from time to time. and around 1GB of ram.

but i think you gave me an interesting idea. i have been using Cloudflare Free DNS because it’s more private, but i remember i used to have some issues on the phone with it - sometimes everything would go much slower. let me go back to my ISP DNS server and see if there’s a change.

Do you host your service with Cloudflare Services (CDN)? I think that make no sense. Also you can perhaps allow additional ip-addresses to nextcloud to see the difference between dns and no dns.

Than you use actually Ubuntu 18.0.4 LTS with older php-version. Perhaps you can switch to a new php-version or to the new Ubuntu version 20.04 LTS

Perhaps also you can temporary deactivate redis.

it wasn’t cloudlfare CDN, it was their free service which they call 1.1.1.1: https://1.1.1.1
they don’t spy on your activity as a normal ISP would. i’m big on privacy - that’s why i’m using nextcloud in the first place :slight_smile:

i had 1.1.1.1 enabled on all my devices (laptop, workstation, phone) - not the server though. but basically anytime i was accessing the cloud it was through 1.1.1.1. i’ve disabled it on all my devices and i’ll have to see if there’s a difference. so far it seems a bit faster, but let’s see.

i’ll try all your other tips and see what happens.

hmm… Serverhardware / CPU , Ram, Swap…
if it’s not the Software could it be the hardware… what know we about the hardware ?
so, what for a Computer it is ? the Webserver… an 1,8 Dualcore with 2 Gig supports not many :wink:
@reborn579 what’s your Hardware ?

if you give for php 1024MB have PHP enough to breath
and Memcache is also a bit afterburner… it load it up for faster running…

best
Blacky