This project demonstrates effective techniques for handling high-frequency, high-volume updates in Single-Page Applications (SPAs). By employing strategies like distinct throttling, lazy sampling, transactional delta updates, and Web Workers, we've optimized performance for scenarios like financial applications with large, rapidly-changing order grids (Blotters).
This TypeScript project uses NodeJS, Angular and Ag-Grid. To get started:
- Clone the repository.
- Navigate to the project directory.
- Run
npm install
.
Note: This project is for demonstration purposes only and is not production-ready.
Optimize a Blotter (order grid) for financial applications to ensure consistent, responsive, and lightning-fast rendering, even with massive data updates.
- Support quick filtering based on various criteria.
- Display total order counts for specific filter conditions.
The Blotter includes three filter groups:
- Product Type: Mutual exclusive selection.
- Order State: Multiple selection. Counters reflect Product Type group selection.
- Extra mixed selection: Includes mutual exclusive filters like "Voice" and "Electronic," as well as non-exclusive filters like "Basket." Order counts reflect Product Type and Order State group selections.
Below is selecting filters for "Commodity," "Electronic," and "Basket" orders in a "Cancelled" or "Failed" state.
The application generates 10,000 random orders (new and updates) with high frequency.
-
Throttling and Batching: The human eye can't detect changes faster than about 300 milliseconds. Order updates are throttled, and only the most recent updates are selected within intervals, limiting the number of updates sent to the Blotter. These updates are then sent in smaller batches to delta update grid and to the web worker, which handles heavy calculation processing. By sending updates in batches, we reduce the overhead of transferring data between the main thread and the web worker, leading to smoother performance.
-
Web Worker Offloading: Heavy calculations (e.g., order count calculations) are offloaded to a Web Worker to avoid blocking the main thread.
-
Data Synchronization: The Web Worker maintains its own tab/orders data and receives configuration changes and order updates from the main application.
-
Lazy Sampling: The Web Worker performs calculations only when necessary and at intervals. Once calculations are finished, workers notify the main thread, which renders the results in the tabs.
-
Ag-Grid Delta Updates: The application uses Ag-Grid for the Blotter, which supports delta updates for faster rendering of changes.
Run live demo here.