A security dashboard has an ugly performance profile. One page load fans out into dozens of expensive operations: summary cards, trends, per-source charts, alert counts, filters, exports, and live updates. If each request loads broad tables and builds its own cache, the dashboard becomes the incident it was supposed to report. Scale failures like this are rarely fixed by a bigger container. They are fixed by bounding each request and treating shared state as something with a lifecycle.
Unbounded work is the first suspect
The classic culprit looks harmless at small volume:
load all rows -> deserialize -> filter in application code -> summarize
Memory use grows with the entire result set, and it multiplies with concurrent users, especially when one page fires several of these at once. If you are tempted to raise a memory limit to stop out-of-memory kills, go looking for queries like this first.
The pattern I prefer:
apply tenant and time bounds -> aggregate in the database -> return a bounded response
Databases are built to group, filter, sort, and window large datasets. The application should receive the summary it needs, not every row that could contribute to it. While you are there, check that the columns you filter and sort on are actually indexed. A missing index turns a bounded query back into a full scan.
Make bounds part of the API contract
Limits are not a late optimization. They belong in the contract:
- Every list endpoint has a maximum page size, deterministic ordering, and scoped filters.
- Every dashboard endpoint has a defined time range, a tenant context, and a cap on buckets or categories.
- Every export that cannot safely finish inside an interactive request gets an asynchronous path.
Beyond performance, this makes UI behavior predictable, gives load tests a stable target, and makes it easy to explain why a user saw a partial or paginated result.
Cache the work, not the leak
Caches usually arrive after someone notices a slow endpoint. That helps, but an unbounded cache is just another memory problem. A few rules:
- Key by tenant and every input that changes the result.
- Use short, deliberate TTLs for volatile posture summaries.
- Cap the number of keys and locks that arbitrary request parameters can create.
- Make a miss safe: it should trigger a bounded query, not an unbounded rebuild.
- Clean up coordination state when work finishes.
That last point matters for request coalescing. Collapsing identical in-flight requests is great when many users ask for the same expensive summary. But if you keep a lock around for every key you have ever seen, the coalescer itself leaks.
Real-time needs a budget
Live updates turn periodic server work into a multiplier. If every connected browser recomputes the same summary, work grows with audience. Compute a shared, tenant-scoped update on a controlled schedule, serve it from a bounded cache, and give each connection a timeout and a cancellation path. Decide how much work you will spend per update cycle before you start the next one. Real-time is not a license for unlimited concurrency.
Test the whole interaction
Load-testing one API route misses what users actually do. A real dashboard load issues concurrent requests while it opens a live connection and fills multiple charts. So test that path:
- Authenticate as a realistic role and tenant.
- Load the summary, trends, and source views together.
- Open the live connection.
- Repeat with concurrent users and representative data volume.
- Watch memory growth, latency percentiles, errors, and cache and connection behavior.
The goal is not a fast first page. It is flat memory and predictable latency over sustained use.
Takeaway
When a dashboard struggles, bound the queries, aggregate where the data lives, check the indexes, cap and expire your caches, budget your real-time work, and load test the full path. A dashboard that times out during an incident undermines trust in every number on it, so treat performance as a property you verify, not something a quiet dev environment proves.