dawarich icon indicating copy to clipboard operation
dawarich copied to clipboard

Pages take 10+ seconds to load

Open xaho opened this issue 9 months ago • 2 comments

OS & Hardware Hardware: Synology D224+ (with 16GB extra memory installed) OS: DSM 7.2.2-72806 Update 3

Version 0.25.1 0.25.2 0.25.3

Describe the bug When opening the login webpage via <NAS IP>:32568 the page takes 10s+ to load. Any page load takes at least 10 seconds.

To Reproduce Steps to reproduce the behavior:

  1. Followed https://dawarich.app/docs/tutorials/platforms/synology
  2. Visit https://<NAS IP>:32568
  3. Wait for 10+s (determined via network panel in Chrome DevTools, times vary from 10.12s to 16s at one point, but generally are around the 10.1s area)
  4. Page is loaded

Expected behavior Page to load in <1s.

Logs dawarich_sidekiq , dawarich_db, dawarich_redis did not log anything when refreshing the login page. dawarich_app :

19:35:26 web.1  | D, [2025-03-23T19:35:26.240508 #90] DEBUG -- :   Rendering layout layouts/application.html.erb
19:35:26 web.1  | D, [2025-03-23T19:35:26.246348 #90] DEBUG -- :   Rendering home/index.html.erb within layouts/application
19:35:36 web.1  | I, [2025-03-23T19:35:36.342635 #90]  INFO -- : {"method":"GET","path":"/","format":"html","controller":"HomeController","action":"index","status":200,"allocations":14201,"duration":10124.11,"view":10116.5,"db":0.0}
19:35:37 web.1  | E, [2025-03-23T19:35:37.037115 #83] ERROR -- :
19:35:37 web.1  | ActionController::RoutingError (No route matches [GET] "/images/bg-image.jpg"):
19:35:37 web.1  |
19:35:37 web.1  | I, [2025-03-23T19:35:37.040113 #90]  INFO -- : {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"allocations":281,"duration":1.89}
19:35:37 web.1  | D, [2025-03-23T19:35:37.145180 #83] DEBUG -- :   Rendering layout vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/lib/action_dispatch/middleware/templates/rescues/layout.erb
19:35:37 web.1  | D, [2025-03-23T19:35:37.147788 #83] DEBUG -- :   Rendering vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout
19:35:37 web.1  | I, [2025-03-23T19:35:37.151388 #90]  INFO -- : {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"allocations":6,"duration":0.34}
19:35:37 web.1  | D, [2025-03-23T19:35:37.361631 #83] DEBUG -- :   Rendering vendor/bundle/ruby/3.4.0/gems/actionpack-8.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb

Additional context This happens with a clean install, before and after login. Interesting detail in the logs might be the 10116ms duration for the "view".

xaho avatar Mar 23 '25 20:03 xaho

This happens with a clean install, before and after login.

Even without any data in the database?

Freika avatar Apr 02 '25 22:04 Freika

Yes, to confirm I did the following just now:

  • Stop the docker containers
  • Remove all files inside the directories which are volume mounted (only db_data folder had anything in it, the others were empty and did not have any hidden files or folders according to ls -a)
  • Start the docker containers in the compose file
  • visit <NAS IP>:32568
  • experience 10s loading time on the home page (attempts resulted in 10.74s, 10.32s, 10.11s, 10.17s)
  • docker stats shows no CPU usage until after 10s after which dawarich_app spikes to 100%+ CPU usage for a very brief moment after which the page is rendered

xaho avatar Apr 03 '25 20:04 xaho

@xaho please update to the most recent version and try again. One of previous releases should have address this issue

Freika avatar Jul 26 '25 12:07 Freika

~Sadly the issue is still present. I am now on 0.26.0, I deleted the containers, emptied the folders that are volume mounted, rebuilt the Synology "Container Manager project", (I had to manually create the dawarich database for some reason which I didn't dig into further) but I still have 10s+ page load times.~ I just saw that 0.26.0 is not the latest version, updating and retrying, one moment please. :)

xaho avatar Jul 26 '25 18:07 xaho

I managed to update the docker images to 0.30.4 (checked with docker inspect dawarich_app, which shows "org.opencontainers.image.version": "0.30.4"). docker logs dawarich_db shows a lot of FATAL: database "dawarich" does not exist docker logs dawarich_app shows a lot of Postgres database dawarich is unavailable - retrying... After trying to jumpstart it by creating the database manually the dawarich_app keeps crashing due to not being able to connect to Redis. I have updated the .env file as it has some new environment variables and I comment the previously present REDIS_URL. I am currently getting

Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)
...
Caused by:
RedisClient::CannotConnectError: Connection refused - connect(2) for 127.0.0.1:6379 (redis://localhost:6379/1) (RedisClient::CannotConnectError)
...
Caused by:
Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)

If I uncomment the REDIS_URL in the .env file I get the following error:

bin/rails aborted!
ArgumentError: invalid value for Integer(): "0/0" (ArgumentError)
/var/app/vendor/bundle/ruby/3.4.0/gems/redis-client-0.24.0/lib/redis_client/url_config.rb:33:in 'RedisClient::URLConfig#db'
...

xaho avatar Jul 26 '25 19:07 xaho

I managed to update the docker images to 0.30.4 (checked with docker inspect dawarich_app, which shows "org.opencontainers.image.version": "0.30.4"). docker logs dawarich_db shows a lot of FATAL: database "dawarich" does not exist docker logs dawarich_app shows a lot of Postgres database dawarich is unavailable - retrying... After trying to jumpstart it by creating the database manually the dawarich_app keeps crashing due to not being able to connect to Redis. I have updated the .env file as it has some new environment variables and I comment the previously present REDIS_URL. I am currently getting

Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)
...
Caused by:
RedisClient::CannotConnectError: Connection refused - connect(2) for 127.0.0.1:6379 (redis://localhost:6379/1) (RedisClient::CannotConnectError)
...
Caused by:
Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)

If I uncomment the REDIS_URL in the .env file I get the following error:

bin/rails aborted!
ArgumentError: invalid value for Integer(): "0/0" (ArgumentError)
/var/app/vendor/bundle/ruby/3.4.0/gems/redis-client-0.24.0/lib/redis_client/url_config.rb:33:in 'RedisClient::URLConfig#db'
...

Please pay attention to release notes, in this particular case remove "/0" from your REDIS_URL value

Freika avatar Jul 26 '25 19:07 Freika

I was not expecting to need to read release notes as I was effectively building from scratch using the documentation, which does not mention that at all. https://github.com/Freika/dawarich/blob/master/docs/How_to_install_Dawarich_on_Synology.md instructs me to use the .env in the repo and doesn't mention anything regarding the REDIS_URL. The .env in question (https://github.com/Freika/dawarich/blob/master/docs/synology/.env) doesn't include REDIS_URL anymore, which it used to do, perhaps it should be included again, but indeed without the "/0"?

Regardless, removing the "/0" did indeed fix the startup issue, however, page loads are still slow, in fact, they're slower now at around 16 seconds:

19:45:25 web.1  | {"method":"GET","path":"/users/sign_in","format":"html","controller":"Devise::SessionsController","action":"new","status":200,"allocations":153836,"duration":16188.98,"view":16086.0,"db":21.45}
19:45:34 web.1  | {"method":"GET","path":"/","format":"html","controller":"HomeController","action":"index","status":200,"allocations":62735,"duration":16044.77,"view":16041.37,"db":0.0}
19:45:35 web.1  | {"method":"GET","path":"/users/sign_in","format":"html","controller":"Devise::SessionsController","action":"new","status":200,"allocations":79398,"duration":16169.51,"view":16072.34,"db":20.73}
19:45:35 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"allocations":222,"duration":1.88}
19:45:35 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"allocations":7,"duration":0.1}
19:45:36 web.1  | {"method":"GET","path":"/users/sign_in","format":"html","controller":"Devise::SessionsController","action":"new","status":200,"allocations":115595,"duration":16073.35,"view":16070.74,"db":0.0}
19:45:57 web.1  |   Rendering layout layouts/application.html.erb
19:45:57 web.1  |   Rendering home/index.html.erb within layouts/application
19:46:13 web.1  | {"method":"GET","path":"/","format":"html","controller":"HomeController","action":"index","status":200,"allocations":13626,"duration":16046.95,"view":16043.4,"db":0.0}
19:46:14 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"allocations":229,"duration":1.48}
19:46:14 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"allocations":7,"duration":0.11}
19:48:18 web.1  |   Rendering layout layouts/application.html.erb
19:48:18 web.1  |   Rendering home/index.html.erb within layouts/application
19:48:34 web.1  | {"method":"GET","path":"/","format":"html","controller":"HomeController","action":"index","status":200,"allocations":13539,"duration":16073.97,"view":16071.03,"db":0.0}
19:48:35 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"connect","status":200,"allocations":232,"duration":1.01}
19:48:35 web.1  | {"method":null,"path":null,"format":null,"params":{},"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"allocations":7,"duration":0.1}

xaho avatar Jul 26 '25 19:07 xaho

Well, I see it's slow but can't say anything about the reasons for that. Not intended behavior for sure though

Freika avatar Jul 27 '25 19:07 Freika

I also tried out the app and can report similar behaviour. For me its 2 min sharp every time and I saw the following nice graphic in my devtools:

Image

The machine the docker containers are running at is idling at around 10% CPU and 40% Mermory allocation. I used the docker-compose.yml from the intro. Image Version: 0.30.5

DanielHabenicht avatar Jul 27 '25 22:07 DanielHabenicht

I'm unfamiliar with the tech stack, but if there's any additional logging we can enable or debug or something like that, let me know.

xaho avatar Jul 29 '25 18:07 xaho

I experienced a very similar issue on my Synology NAS. The pages took at least 10 seconds to load, even though the CPU and RAM seem to be almost idle during this time. (Over the time I tried it with several version and updates of dawarich - 0.30.5, 0.28.1, 0.27.3, 0.26.7, 0.26.3).

Recently I found a solution, by deactivating the Synology Firewall (or allowing the internal IP range of all the docker containers). After that most of the pages load perfectly fast (in the latest version 0.30.8 and 0.30.7). Some pages need some more time to load but not like before with always the same pattern of idle time. I am not really sure about the reason and why this solves the problem in my case. But my best guess is that the Firewall somehow prevent the communication with the redis container. Maybe the 10 seconds are some kind of timeout in trying to reach the redis data and after that the data is loaded directly.

juriseelmann avatar Aug 16 '25 08:08 juriseelmann

Sadly, disabling the Synology Firewall did not change anything for me, still 16+s of load time

xaho avatar Aug 17 '25 14:08 xaho

Sorry, I can't support you as I'm not proficient with Synology, so I'm closing this as not planned. If you ever find a solution, please share it here. Thank you!

Freika avatar Aug 27 '25 10:08 Freika