|
| 1 | +--- |
| 2 | +title: "Performance Impact" |
| 3 | +description: "Learn about the performance impact of the Flashduty Web RUM SDK on page load, runtime CPU, memory, and network reporting, along with optimization recommendations." |
| 4 | +keywords: ["Web SDK", "performance impact", "RUM", "performance optimization", "Session Replay", "frontend monitoring"] |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +When integrating a RUM SDK into a web application, understanding its performance impact is crucial for maintaining a good user experience. The Flashduty Web RUM SDK is designed to minimize page overhead and provides transparent, reproducible benchmark data to help you evaluate whether the SDK fits your page's performance budget. |
| 10 | + |
| 11 | +Integrating the SDK introduces three categories of overhead: |
| 12 | + |
| 13 | +1. **Load overhead**: downloading, parsing, and initializing the SDK JS, affecting first paint and time to interactive. |
| 14 | +2. **Runtime overhead**: main-thread CPU and memory consumed by event collection, automatic instrumentation (resources, long tasks, user interactions), and Session Replay recording. |
| 15 | +3. **Network overhead**: the number and size of requests produced by periodic batched reporting. |
| 16 | + |
| 17 | +<Check> |
| 18 | +Overall, **basic RUM overhead is very small** and negligible for most pages; **Session Replay is the main source of overhead**, especially on pages with large or frequently-changing DOM, and should be controlled via sampling rate and privacy configuration. |
| 19 | +</Check> |
| 20 | + |
| 21 | +## Performance Impact at a Glance |
| 22 | + |
| 23 | +The table below shows the overall impact (p50) relative to a no-SDK baseline for a **typical business page** (with clicks, input, and XHR), under the **recommended production configuration** (RUM + resource + long-task collection, Session Replay sampled on demand): |
| 24 | + |
| 25 | +| Metric | Without SDK (baseline) | With SDK (recommended) | Impact | Assessment | |
| 26 | +| --- | --- | --- | --- | --- | |
| 27 | +| SDK size (gzip) | — | 50.0 KB | +50.0 KB (async / CDN cached) | Minimal | |
| 28 | +| SDK init time | — | 7.8 ms | +7.8 ms | Minimal | |
| 29 | +| First paint (FCP) | 20 ms | 44 ms | +24 ms | Minimal | |
| 30 | +| Main-thread CPU (runtime) | 42 ms | 78 ms | +36 ms | Small | |
| 31 | +| JS heap peak | 1.24 MB | 3.07 MB | +1.83 MB | Small | |
| 32 | +| Report size (per session window) | 0 KB | 30.5 KB | +30.5 KB | Small | |
| 33 | + |
| 34 | +<Note> |
| 35 | +Assessment scale: Minimal (negligible) < Small < Moderate < Large. CPU/memory are cumulative over the entire 10s interaction window, which amortizes to very low per-second values; the SDK is loaded asynchronously via CDN and does not block the critical rendering path. These are reference values for typical scenarios; actual impact varies with page complexity, device performance, and SDK configuration. |
| 36 | +</Note> |
| 37 | + |
| 38 | +## SDK Bundle Size |
| 39 | + |
| 40 | +The default integration loads the full RUM bundle (including Session Replay). If you don't need recording, switch to the slim bundle to significantly reduce size. |
| 41 | + |
| 42 | +| Bundle | Description | Raw | Gzip | Brotli | |
| 43 | +| --- | --- | --- | --- | --- | |
| 44 | +| `flashcat-rum.js` | Full RUM (with Session Replay) | 145.3 KB | 50.0 KB | 43.6 KB | |
| 45 | +| `flashcat-rum-slim.js` | Slim RUM (without Session Replay) | 104.9 KB | 36.2 KB | 31.7 KB | |
| 46 | + |
| 47 | +<Tip> |
| 48 | +Actual transfer size is governed by the **Gzip / Brotli compressed size**. When loaded asynchronously via CDN, the SDK does not block the critical rendering path; the Session Replay recorder is lazy-loaded on demand and only downloaded when recording is enabled. |
| 49 | +</Tip> |
| 50 | + |
| 51 | +## Session Replay Additional Overhead |
| 52 | + |
| 53 | +Session Replay is a separate optional capability whose overhead is strongly correlated with page characteristics. The table below shows the **additional** increment (p50) over the recommended configuration when Session Replay is enabled at 100%: |
| 54 | + |
| 55 | +| Scenario | CPU delta (ms) | JS heap delta (MB) | Recording report size (KB) | Assessment | |
| 56 | +| --- | --- | --- | --- | --- | |
| 57 | +| Typical business page | +11 | +0.3 | 35 | Minimal | |
| 58 | +| SPA route page | +45 | +1.5 | 125 | Small | |
| 59 | +| High-frequency DOM update page | +73 | +0.7 | 10 | Minimal | |
| 60 | +| Large table page (large DOM) | +757 | +39.5 | 1757 | Large | |
| 61 | + |
| 62 | +<Warning> |
| 63 | +Session Replay overhead is manageable on ordinary pages, but is significantly amplified on **large-DOM / high-churn** pages — a larger DOM makes the initial snapshot serialization heavier, and more frequent mutations increase incremental recording and report size. We strongly recommend lowering the recording ratio via `sessionReplaySampleRate`, combined with privacy masking and region exclusion to control overhead. |
| 64 | +</Warning> |
| 65 | + |
| 66 | +## Performance Impact Details |
| 67 | + |
| 68 | +<AccordionGroup> |
| 69 | +<Accordion title="Initialization (init)" icon="rocket"> |
| 70 | +Runs once synchronously early in the page lifecycle to parse configuration, collect context, and register features. It typically takes milliseconds and has minimal impact on FCP/LCP. |
| 71 | +</Accordion> |
| 72 | + |
| 73 | +<Accordion title="Resource collection (trackResources)" icon="wifi"> |
| 74 | +Uses PerformanceObserver to observe resource timing. Overhead grows with the number of page requests, but it is passive observation with low CPU usage. |
| 75 | +</Accordion> |
| 76 | + |
| 77 | +<Accordion title="Long-task collection (trackLongTasks)" icon="clock"> |
| 78 | +Observes `longtask` entries and only records long tasks that have already occurred; it introduces almost no additional long tasks of its own. |
| 79 | +</Accordion> |
| 80 | + |
| 81 | +<Accordion title="User-interaction collection (trackUserInteractions)" icon="hand-pointer"> |
| 82 | +Listens for events such as clicks and infers element names. The cost per interaction is minimal. |
| 83 | +</Accordion> |
| 84 | + |
| 85 | +<Accordion title="Session Replay — main source of overhead" icon="video"> |
| 86 | +- The initial full snapshot serializes the entire DOM tree, so the **larger the DOM, the higher the first recording cost** (see the large table page). |
| 87 | +- Incremental mutations are recorded continuously via MutationObserver, so the **more frequent the DOM changes, the higher the CPU and report size** (see the high-frequency DOM update page). |
| 88 | +- Recording data is compressed in a Web Worker before reporting; compression runs on the Worker thread to avoid blocking the main thread, but still adds memory and network overhead. |
| 89 | +</Accordion> |
| 90 | +</AccordionGroup> |
| 91 | + |
| 92 | +## Performance Optimization Recommendations |
| 93 | + |
| 94 | +<Steps> |
| 95 | +<Step title="Choose the bundle on demand"> |
| 96 | +When recording is not needed, use `flashcat-rum-slim` for a smaller size (gzip 36.2 KB vs 50.0 KB). |
| 97 | +</Step> |
| 98 | + |
| 99 | +<Step title="Control session and replay sampling rates"> |
| 100 | +`sessionSampleRate` controls the proportion of sessions included in RUM; `sessionReplaySampleRate` **separately controls the recording ratio** (recommended well below 100%): |
| 101 | + |
| 102 | +```javascript |
| 103 | +flashcatRum.init({ |
| 104 | + applicationId: "<YOUR_APPLICATION_ID>", |
| 105 | + clientToken: "<YOUR_CLIENT_TOKEN>", |
| 106 | + site: "rum-server.flashcat.cloud", |
| 107 | + sessionSampleRate: 100, // proportion of sessions collected by RUM |
| 108 | + sessionReplaySampleRate: 10, // record only 10% of sessions, greatly reducing overhead |
| 109 | + trackResources: true, |
| 110 | + trackLongTasks: true, |
| 111 | + trackUserInteractions: true, |
| 112 | + defaultPrivacyLevel: "mask-user-input", |
| 113 | +}); |
| 114 | +flashcatRum.startSessionReplayRecording(); |
| 115 | +``` |
| 116 | +</Step> |
| 117 | + |
| 118 | +<Step title="Reduce recording size with privacy and trimming"> |
| 119 | +Use `defaultPrivacyLevel` (`mask` / `mask-user-input` / `allow`) to mask data; use privacy markers to exclude very large or high-churn regions, reducing serialization and report size. |
| 120 | +</Step> |
| 121 | + |
| 122 | +<Step title="Use beforeSend carefully"> |
| 123 | +`beforeSend` is invoked for **every** RUM event; avoid heavy logic or synchronous blocking operations inside it. |
| 124 | +</Step> |
| 125 | + |
| 126 | +<Step title="Disable unneeded automatic instrumentation"> |
| 127 | +If you don't care about resources or long tasks, disable `trackResources` / `trackLongTasks` respectively. |
| 128 | +</Step> |
| 129 | + |
| 130 | +<Step title="Load the SDK asynchronously"> |
| 131 | +Load via CDN with `async` to avoid blocking the critical rendering path. |
| 132 | +</Step> |
| 133 | +</Steps> |
| 134 | + |
| 135 | +## Offline Caching and Reporting |
| 136 | + |
| 137 | +The SDK first writes events to a local buffer, and a background batch processor reports them in batches at a steady cadence (with backoff retries). On page unload (`visibilitychange` / `beforeunload`), it falls back to `sendBeacon` to reduce data loss. Failed reports back off according to the retry strategy and never occupy the network indefinitely. |
| 138 | + |
| 139 | +## Test Methodology |
| 140 | + |
| 141 | +- **Device/environment**: Apple M4 (10 cores / 16 GB), Darwin 24.5.0 arm64, Chromium 147. |
| 142 | +- **Tools**: Playwright drives Chromium; CDP `Performance.getMetrics` collects CPU / memory / DOM nodes; `PerformanceObserver` collects FCP / LCP / CLS / INP / Long Task. |
| 143 | +- **Control groups**: A = no SDK (baseline), B = basic RUM, C = RUM + resources + long tasks (recommended production config), D = + Session Replay 100%. When comparing readings: `B − A` = basic RUM overhead, `C − B` = automatic-instrumentation increment, `D − C` = Session Replay additional overhead. |
| 144 | +- **Statistic**: reported as **p50**, not the mean; JS heap is read as the post-GC "retained" value after a forced GC; report request count and size are measured from the live network, independent of transport (fetch / beacon); the no-SDK group loads zero SDK bytes. |
| 145 | + |
| 146 | +<Note> |
| 147 | +Impact varies with **page complexity, device performance, and SDK configuration**; we recommend measuring on your own key pages with the benchmark tool. |
| 148 | +</Note> |
| 149 | + |
| 150 | +## Related Documentation |
| 151 | + |
| 152 | +<CardGroup cols={2}> |
| 153 | +<Card title="SDK Integration Guide" icon="plug" href="/en/rum/sdk/web/sdk-integration"> |
| 154 | + Learn how to integrate the Web SDK |
| 155 | +</Card> |
| 156 | +<Card title="Advanced Configuration" icon="sliders" href="/en/rum/sdk/web/advanced-config"> |
| 157 | + Learn about SDK advanced configuration options |
| 158 | +</Card> |
| 159 | +<Card title="Data Collection" icon="database" href="/en/rum/sdk/web/data-collection"> |
| 160 | + Learn what data the SDK collects |
| 161 | +</Card> |
| 162 | +<Card title="Compatibility" icon="check-circle" href="/en/rum/sdk/web/compatible"> |
| 163 | + Learn about supported platform versions |
| 164 | +</Card> |
| 165 | +</CardGroup> |
0 commit comments