Skip to content

Commit dccbbae

Browse files
jsuzannejsuzanne
authored andcommitted
docs: detail underlying network probing binaries and optimization roadmap
1 parent 1ab644a commit dccbbae

2 files changed

Lines changed: 81 additions & 5 deletions

File tree

Roadmap/PROBE_OPTIMIZATIONS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.

docs/CONNECTIVITY_ENDPOINTS.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,36 @@ The **Connectivity Probes** (formerly Synthetic Endpoints) provide real-time vis
99
The platform supports three primary probe types, each measuring different aspects of the digital experience:
1010

1111
### 1. HTTP (Digital Experience)
12-
- **Mechanism**: Performs a standard HTTP/HTTPS `GET` request to the target.
12+
- **Mechanism**: Orchestrates a native OS `curl` subprocess to perform HTTP/HTTPS `GET` queries.
13+
- **Primary Benefit**: `curl` provides military-grade precision for extracting intricate low-level execution timings out-of-the-box, allowing us to perfectly isolate DNS lookup delays, TCP Handshake times, and TLS Handshake overhead from the raw Time-To-First-Byte (TTFB).
1314
- **Metrics**:
14-
- **Latency (ms)**: Time to first byte.
15+
- **Latency (ms)**: Total Time to first byte breakdown.
1516
- **Status**: Success (2xx/3xx) or Failure (4xx/5xx/Timeout).
1617
- **Scoring**: Weighted calculation: `100 - (30% Latency + 35% TTFB + 25% TLS)`. Penalized heavily if Latency > 2s, TTFB > 1s, or TLS Handshake > 800ms.
1718

1819
### 2. PING (Network Reachability)
19-
- **Mechanism**: Sends standard ICMP Echo Requests.
20+
- **Mechanism**: Executes the native OS `ping` binary to dispatch ICMP Echo Requests.
21+
- **Primary Benefit**: Using the host's native `ping` utility intelligently avoids the strict capability/root privileges required to open raw ICMP sockets programmatically, ensuring secure, unprivileged execution environments (like Docker containers) map reachability flawlessly.
2022
- **Metrics**:
2123
- **RTT (ms)**: Round-trip time.
2224
- **Scoring**: Good if < 100ms (Score 100). Reaches 0 at 500ms.
2325

2426
### 3. DNS (Resolution Speed)
25-
- **Mechanism**: Queries the target domain.
27+
- **Mechanism**: Queries the target domain leveraging the `dig` system utility.
28+
- **Primary Benefit**: `dig` bypasses systemic OS-level caching interfaces, providing the exact unadulterated response time of the raw nameserver for highly faithful resolution mapping.
2629
- **Metrics**:
2730
- **Resolution Time (ms)**: Real-world mapping speed.
2831
- **Scoring**: Good if < 80ms (Score 100). Reaches 0 at 400ms.
2932

3033
### 4. UDP (Voice/Real-time Quality)
31-
- **Mechanism**: UDP reachability probe.
34+
- **Mechanism**: Triggers an `iperf3` client process (`-u` mode) aimed at the target port.
35+
- **Primary Benefit**: `iperf3` is the undisputed industry standard for UDP throughput mapping. It intrinsically calculates complex networking permutations including packet loss percentages and millisecond Jitter natively without requiring manual script math.
3236
- **Scoring**: `100 - (Loss % * 10) - Jitter penalty`. Jitter over 30ms reduces the score (max -50). 10% packet loss results in a score of **0**.
3337

38+
### 5. TCP (Port Reachability)
39+
- **Mechanism**: Executes `nc` (Netcat) to simulate a standard TCP socket connection.
40+
- **Primary Benefit**: Netcat securely tests port exposure and firewall routing viability without risking incomplete handshakes that some specialized application daemons reject.
41+
3442
## 🏆 Scoring Methodology
3543

3644
All probes return a score from **0 to 100**.

0 commit comments

Comments
 (0)