|
| 1 | +# Connectivity Probe Optimizations Roadmap |
| 2 | + |
| 3 | +This document outlines a high-level assessment of the Digital Experience Monitoring (DEM) underlying probe engines, evaluating the potential for deeper integration directly into native `Node.js` APIs versus the current external OS-level subprocess approach. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. TCP Port Reachability |
| 8 | + |
| 9 | +### Current Implementation |
| 10 | +- **Tool**: Shell `nc` (Netcat) via `child_process.exec`. |
| 11 | +- **Workflow**: Spawns an external Bash shell, which then launches the `nc` binary. |
| 12 | + |
| 13 | +### Proposed Optimization |
| 14 | +- **Rewrite to**: Pure Native Node.js `net.Socket`. |
| 15 | +- **Assessment**: **High ROI / Low Effort**. Replacing `nc` with a native `new net.Socket().connect(port, host)` completely eliminates the heavy OS context-switch and bash wrapper overhead. It would lower container CPU spikes instantly while identically validating standard TCP handshake completion. We can track connect times perfectly within the Node Event Loop. |
| 16 | +- **Priority**: High (Whenever next refactoring phase is initiated). |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 2. DNS Resolution Speed |
| 21 | + |
| 22 | +### Current Implementation |
| 23 | +- **Tool**: Shell `dig` utility. |
| 24 | +- **Workflow**: Forked `dig` subprocess targeting specific nameservers using `+time` thresholds. |
| 25 | + |
| 26 | +### Proposed Optimization |
| 27 | +- **Rewrite to**: Pure Native Node.js `dns` module (`dns.promises.resolve` combined with `dns.promises.setServers`). |
| 28 | +- **Assessment**: **High ROI / Medium Effort**. Node internally uses `c-ares`, an extremely robust asynchronous DNS C library. Bypassing `dig` means the backend never leaves Node memory space to perform a query. We'd manually attach `Date.now()` wrapping logic to replicate the pristine latency outputs that `dig` currently supplies. |
| 29 | +- **Priority**: Medium. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## 3. HTTP / HTTPS (Digital Experience) |
| 34 | + |
| 35 | +### Current Implementation |
| 36 | +- **Tool**: Shell `curl` utility. |
| 37 | +- **Workflow**: Uses `curl`'s heavily formatted `-w` flags to independently isolate TLS Handshakes, TCP Handshakes, TTFB, and namelookups. |
| 38 | + |
| 39 | +### Proposed Optimization |
| 40 | +- **Rewrite to**: **N/A (Keep `curl`)**. |
| 41 | +- **Assessment**: **Negative ROI**. While Node.js `fetch` or `https.request` operates in-memory and skips subprocesses, capturing explicit sub-layer timing events (such as tracking when identically the TLS Handshake succeeds vs the physical socket binding) requires exceptionally complex network hooks (`socket.on('secureConnect')`). The external `curl` process is heavier, but provides unparalleled, undisputed raw metric precision automatically. |
| 42 | +- **Priority**: Do not optimize. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## 4. ICMP Ping |
| 47 | + |
| 48 | +### Current Implementation |
| 49 | +- **Tool**: Shell `ping` utility. |
| 50 | +- **Workflow**: Spawns `-c 1` ICMP pings through the host environment. |
| 51 | + |
| 52 | +### Proposed Optimization |
| 53 | +- **Rewrite to**: **N/A (Keep `ping`)**. |
| 54 | +- **Assessment**: **Negative ROI**. Operating raw ICMP sockets inside Node.js programmatically requires massive security escalations (running Node entirely as `root` or mapping explicit `CAP_NET_RAW` Linux capabilities into the Docker image). Leveraging the pre-escalated native `ping` OS binary is the industry-standard secure approach. |
| 55 | +- **Priority**: Do not optimize. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## 5. UDP (Real-time QoS) |
| 60 | + |
| 61 | +### Current Implementation |
| 62 | +- **Tool**: Shell `iperf3` utility. |
| 63 | +- **Workflow**: Client UDP execution binding to proprietary `iperf3` ports. |
| 64 | + |
| 65 | +### Proposed Optimization |
| 66 | +- **Rewrite to**: **N/A (Keep `iperf3`)**. |
| 67 | +- **Assessment**: **Negative ROI**. `iperf3` handles complex proprietary packet accounting including server-negotiation to calculate end-to-end Packet Loss and Jitter. A native Node `dgram` UDP packet mapping engine would require an identical Node instance to live on the target server just to acknowledge the receipt of the connectionless packet chunks. `iperf3` is irreplaceable for interacting with third-party testing nodes. |
| 68 | +- **Priority**: Do not optimize. |
0 commit comments