#7931·ghostfolio

Dashboard load triggers a burst of ~16s portfolio snapshot calculations that block the whole API on large dataset

Author: aayusharyanCreated Sep 20, 2026Updated Sep 20, 2026

Bug Description

Portfolio snapshot calculation is CPU-bound and runs inside the main API process, so while one runs (~16s on my portfolio) the whole API stops responding. Loading the dashboard queues several separate snapshot computations back to back, so the UI is unusable for minutes.

Observed on a self-hosted instance with a large portfolio (~1,900 activities, 8 years of history):

  • Each PortfolioSnapshotProcessor run takes ~16s and uses ~110–120% of one core for its whole duration.
  • While a run is in progress, unrelated requests stall. GET /api/v1/health took 10.8s during a run (normally ~10 ms). Static pages were unaffected in the same test, so it looks like event-loop blocking rather than a network or proxy problem.
  • A page load triggers a burst of consecutive snapshot computations (5 and 8 in a row in the logs below), each ~16s. Redis holds 5–6 portfolio-snapshot-<user>-<hash> entries, so it looks like each API call with a different filter/date range is computed independently. 8 × 16s is over 2 minutes of the process being busy.
  • Run time has grown steadily with data volume (weekly average: June 11.5s → July 13.4s → Aug 14.4s → Sept 16.0s while activities grew from ~1,670 to ~1,890).

Host is idle otherwise (12 cores, 13 GB free, load average ~0.5), so it is not resource starvation. The bottleneck is one thread.

To Reproduce

  1. Self-host Ghostfolio 3.3.0 with a large portfolio (~1,900 activities across ~220 symbols, history of over 8-9 years).
  2. Tail the API container logs.
  3. Open the portfolio dashboard. [A hard reload (Ctrl+Shift+R) triggers the burst]
  4. Observe several consecutive Portfolio snapshot calculation ... has been started/completed in ~16 seconds lines.
  5. While a run is in progress, request GET /api/v1/health from the host. It stalls for several seconds.

Expected Behavior

  • A snapshot calculation should not block the API process (e.g. run in a worker thread or separate process), so other requests stay responsive.
  • Requests for the same user in the same page load should not each trigger a full, independent recalculation, or should share the work.

Screenshots

No screenshot since this is a performance related issue.

Logs

Burst of consecutive runs while loading the dashboard (timestamps UTC, user id redacted):

[Nest] 1 - 09/20/2026, 6:49:30 PM LOG [PortfolioSnapshotProcessor (PORTFOLIO)] Portfolio snapshot calculation of user '<user-id>' has been started
[Nest] 1 - 09/20/2026, 6:49:47 PM LOG [PortfolioSnapshotProcessor (PORTFOLIO)] ... has been completed in 16.396 seconds
[Nest] 1 - 09/20/2026, 6:49:47 PM LOG ... has been started
[Nest] 1 - 09/20/2026, 6:50:04 PM LOG ... has been completed in 17.060 seconds
[Nest] 1 - 09/20/2026, 6:50:05 PM LOG ... has been started
[Nest] 1 - 09/20/2026, 6:50:20 PM LOG ... has been completed in 15.719 seconds
... (8 consecutive runs, 6:49:30 PM to 6:53:17 PM)

Health endpoint probed during a run (from the host, localhost:3333 published as 20200):

t=03:55:11 /api/v1/health ttfb=0.203s
t=03:55:12 /api/v1/health ttfb=0.012s
t=03:55:13 /api/v1/health ttfb=10.772s   <-- run in progress
t=03:55:25 /api/v1/health ttfb=0.031s
t=03:55:26 /api/v1/health ttfb=0.002s

Weekly average snapshot duration (from container logs):

2026-06  n=2778  avg=11.5 s
2026-07  n=2819  avg=13.4 s
2026-08  n=4926  avg=14.4 s
2026-09  n=3510  avg=16.0 s

Things I ruled out:

  • External data providers: Yahoo answers in ~530 ms, CoinGecko in ~250 ms from the container.
  • Postgres: 114 MB database, autovacuum current, heavily indexed, 0.02 % CPU.
  • Redis: 4 MB, no evictions.
  • Container limits: none set.
  • Reverse proxy and network path: ~60 ms end to end for the page and its assets.

Environment

  • Ghostfolio Version 3.3.0.
  • Self-hosted (Docker Compose: ghostfolio + postgres 16.14 + redis 7.4.9), behind Traefik
  • Node v22.22.2, host 12 cores / ~15.8 GB RAM
  • Experimental Features enabled or disabled: none
  • Browser: Tried multiple, this is a backend issue
  • OS: Tried multiple, this is a backend issue, irrelevant here.
  • Data size: 1 user, 66 accounts, 1,887 activities, 219 symbols with activities, ~278k MarketData rows, oldest activity 2018-10-09

Additional Context

  • Default PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_CONCURRENCY (1) and no CACHE_* overrides.
  • I understand raising PROCESSOR_PORTFOLIO_SNAPSHOT_COMPUTATION_CONCURRENCY would not help, since the work is CPU-bound in a single Node thread. Please correct me if this build handles it differently. I found no use of worker_threads or cluster in apps/api/main.js.
  • Would a supported way to run more than one API/worker container against the same Redis and Postgres help here? If so, is it safe with the scheduled data-gathering jobs?
  • Happy to provide a CPU profile (--cpu-prof) if useful.