Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 58

Scalable Frontend Architecture for High-Volume Data Dashboards

Recommended resources

Hello! In our last lesson, we explored the absolute performance limits of the browser, examining how Canvas and WebAssembly provide escape hatches from the DOM when you need to render with extreme density or compute with near-native speed.

Today, we'll apply those patterns and more to a classic senior-level system design problem: architecting a high-performance analytics dashboard. This lesson is designed to synthesize everything from virtualization to data fetching into a coherent, interview-ready blueprint. By the end of our session, you'll be able to confidently outline the frontend architecture for a dashboard designed to render and interact with over 100,000 data points, a task that tests your understanding of scalability, performance, and trade-offs at every layer of the frontend stack.

1. Deconstructing the Problem: Framing the Dashboard

In any system design interview, the first step is to clarify requirements. Let's define the problem for an analytics dashboard, similar to tools like Datadog, Amplitude, or a custom internal admin panel.

Functional Requirements (What it does):

  • Data Display: Renders a large, two-dimensional grid of data (e.g., 100,000 rows by 50 columns).
  • Interactivity: Supports client-side or server-side sorting and filtering.
  • Layout: Implements sticky headers and sticky columns (e.g., the first column with an ID should always be visible).
  • Visualization: May include charts (bar, line, pie) that summarize the grid data.

Non-Functional Requirements (How it performs):

  • Performance: Must maintain a smooth 60fps scroll experience. Initial load and interaction latency (e.g., applying a filter) must be low.
  • Scalability: The architecture must not just handle 100k data points, but be extensible to millions.
  • Accessibility (A11y): The grid must be navigable via keyboard and fully accessible to screen readers.

The core challenge is clear: rendering 100,000 rows * 50 columns = 5,000,000 potential cells without crashing the browser. A naive map over this data would create millions of DOM nodes, freezing the UI for seconds, if not minutes. This immediately tells us we need a more sophisticated rendering strategy.


2. The Rendering Heart: 2D Virtualization

As we established in the last lesson, virtualization is the primary tool for handling large lists. For a 2D grid, we need 2D virtualization, applying the same principle to both rows and columns.

Frontend System Design: Virtualization & Handling Large Data Sets - DEV Community

This section of the "Virtualization & Handling Large Data Sets" article is the most critical resource for this lesson. It directly addresses the problem of 2D virtualization for large tables.

Please read the entire section Large Table Rendering. Pay close attention to the diagram explaining row vs. column virtualization and the proposed architecture using TanStack Table and TanStack Virtual.

The key takeaway is that you need two virtualizers working in tandem:

  1. A row virtualizer that listens to scrollTop and renders only the visible slice of rows.
  2. A column virtualizer that listens to scrollLeft and renders only the visible slice of columns.

The final rendered view is the intersection of these two slices. If 20 rows and 10 columns are visible, you render only 20 * 10 = 200 cells, not 5 million.

The Modern Stack for Virtualized Grids

The article you just read proposes a powerful and standard architecture for this problem:

  • TanStack Table (formerly React Table): A headless library for managing the logic of a tableโ€”column definitions, sorting state, filtering logic, row selection. It does not render any UI.
  • TanStack Virtual (formerly React Virtual): A headless library for managing the rendering of a virtualized list or grid. It tells you which items to render and where to position them.

Your React component's job is to wire these two together. TanStack Table gives you the rows and columns data models, and you feed them into TanStack Virtual's useVirtualizer hooks to get back the small subset of virtual items to actually render into DOM nodes.

This video provides a practical, code-level demonstration of setting up the useVirtualizer hook from TanStack Virtual.

How to Render 100.000 Items with React?

This tutorial, "How to Render 100,000 Items with React?", walks through building a virtualized list with TanStack Virtual. While it covers a 1D list, the core principles of using the useVirtualizer hook are identical for our 2D grid.

Watch the setup of the useVirtualizer hook, focusing on the configuration options like count, getScrollElement, and estimateSize. Then, see how the virtual items are rendered, paying attention to the use of getVirtualItems() and the styles for positioning (transform: translateY) in the rendering section.


3. Data Architecture: Taming the 100k-Point Beast

Rendering is only half the battle. How do we efficiently fetch, manage, and process 100,000 data points on the client?

Fetching: Beyond Simple Pagination

Fetching 100,000 rows in a single API call is not an option. The standard solution is pagination. However, for a seamless "infinite scroll" experience in our dashboard, simple offset-based pagination (?page=2) has flaws. Cursor-based pagination is far superior.

  • Cursor-based Pagination: The API returns a "cursor" (an opaque token representing the last item of the current page) with each batch of data. To get the next page, you send that cursor back. This is more robust and performs better in database systems with large offsets.

To manage this on the frontend, a library like TanStack Query (React Query) with its useInfiniteQuery hook is the industry standard. It automates managing pages, caching, and provides a simple fetchNextPage function to wire up to your scroll logic.

Processing: Server vs. Client vs. Worker

Once the data is fetched, what about sorting and filtering?

  • For < 10,000 rows: Client-side processing is often acceptable.
  • For 100,000+ rows: Performing a filter or sort on a massive JavaScript array on the main thread for every user interaction will cause noticeable UI jank.

The senior-level solution is to delegate processing to the server. A user changing the sort order or typing in a filter should trigger a new API request with those parameters (e.g., ?sortBy=name&filter=acme). The backend performs the operation on the full dataset and returns the first page of the new, sorted/filtered result.

For computationally heavy tasks that must happen on the client (like complex aggregations for a chart), you can offload them to a Web Worker, keeping the main thread free for UI updates.

Optimizing website performance for frontend developers handling large datasets and dynamic content visualization is critical to delivering faster load times and a superior user experience. This guide presents the most effective techniques to optimize frontend applications, ensuring smooth rendering, minimal latency, and scalable interactions without compromising SEO rankings.

This guide provides a great overview of performance optimization strategies. We'll focus on the sections relevant to data handling.

Read through Section 1, "Efficient Data Fetching and Management Techniques", to solidify your understanding of pagination, lazy loading, and client-side caching. Then, review Section 2, "Optimal Data Structures and Processing", focusing on the advice to offload heavy computations to Web Workers and use virtualization.

Persistent Storage: The IndexedDB Bucketing Strategy

For a truly high-performance dashboard, especially one dealing with financial time-series data, relying solely on in-memory caches has limits. To enable offline access, instant loads on repeat visits, and advanced caching, we can leverage IndexedDB.

However, simply dumping 100,000 rows into IndexedDB is inefficient. A much more sophisticated technique is bucketing.

Frontend System Design - Financial Dashboard

This system design mock interview for a financial dashboard contains a brilliant segment on data storage. The presenter outlines a staff-engineer-level strategy for storing and querying massive time-series datasets on the client.

Watch the section on data storage, specifically the discussion on using IndexedDB with a bucketing strategy. Pay close attention to the concept of the compound key (assetID, bucketID, timeframe) and the storage requirement calculations.

The core idea of bucketing is to pre-aggregate data into chunks based on time. For example, instead of storing raw per-second data, you store it in 5-minute, 1-hour, and 1-day buckets.

  • To show a year's worth of data, you fetch the 365 "one-day" buckets.
  • To show one day's worth of data, you fetch the 24 "one-hour" buckets.
  • To show one hour, you fetch the 12 "five-minute" buckets.

This approach, using a compound key in IndexedDB, dramatically reduces the number of records you need to scan to retrieve a specific time range, making queries incredibly fast. It's a powerful technique that signals deep architectural thinking.


4. The Complete Architecture

Let's assemble these pieces into a complete architectural blueprint for our analytics dashboard.

Frontend System Design: Virtualization & Handling Large Data Sets - DEV Community

We'll return to our main resource to see a diagram of the full architecture and review a concise answer to this exact design problem.

First, study the diagram and explanation under the "Full Architecture for Data-Heavy App" section. Then, read the mock interview answer for question Q8: "Design a virtualized grid โ€” 100K rows, 50 columns...".

Here is a summary of the layered architecture, which is the perfect way to structure your answer in an interview:

  1. API Layer: The backend provides a cursor-based paginated API that supports server-side sorting and filtering. For real-time updates, it uses WebSockets or Server-Sent Events.
  2. Data Fetching Layer (Client): TanStack Query (useInfiniteQuery) manages API requests, in-memory caching, and background refetching. It's the "data brain" of the application.
  3. Persistent Storage Layer (Client): (Optional but powerful) IndexedDB is used for long-term, persistent caching, employing a bucketing strategy for efficient time-series data retrieval.
  4. State Logic Layer: TanStack Table manages the definitions and state for columns, sorting, and filtering, acting as a headless "controller" for the grid's logic.
  5. Rendering Logic Layer: TanStack Virtual takes the data model from TanStack Table and, based on the user's scroll position, calculates the minimal subset of rows and columns that need to be rendered.
  6. View Layer: A simple React component renders a <table> element. It uses the output from TanStack Virtual to render only the visible <tr> and <td> elements, applying appropriate transform styles for positioning and position: sticky for headers and key columns.

Conclusion

Designing a dashboard for 100,000+ data points is a fantastic test of a frontend engineer's architectural skills. It forces you to think beyond simple rendering and consider the entire lifecycle of data, from the database to the pixels on the screen.

Key Takeaways:

  • 2D virtualization is non-negotiable. The combination of a headless table utility (like TanStack Table) and a headless virtualizer (like TanStack Virtual) is the modern, standard approach.
  • Move data operations to the server. For datasets of this scale, sorting and filtering should be handled by the backend via API parameters.
  • Use cursor-based pagination with an infinite query hook. This provides a seamless user experience while keeping data fetching efficient.
  • Leverage advanced caching with IndexedDB and bucketing. For applications requiring offline support or extreme performance, this strategy is a powerful differentiator.
  • Start with DOM-based virtualization. Only consider a move to a Canvas-based grid if performance data proves that even a virtualized DOM is insufficient, typically for real-time, high-frequency updates on millions of cells.

In our next lesson, we'll broaden our focus from deep performance on a single, complex component to the architectural challenges of building for a diverse ecosystem. We'll dive into the strategies for mobile web, Progressive Web Apps (PWAs), and cross-platform development.