Design a Network Security Monitoring Tool
0%
Editorial Solution
System requirements
Functional
Capacity estimation
Traffic
API design
Alert Retrieval
Database design
InfluxDB: Packet and Traffic Data
High-level design
Request flows
Packet Capture and Detection Flow
Detailed component design
Sync Analyzer: Real-Time Rule Engine
Trade offs/Tech choices
Full Packet Capture vs. Flow-Level Capture
Failure scenarios/bottlenecks
Sensor Agent Offline
Future improvements
Advanced ML Anomaly Detection
Table of Contents
System requirements
Functional
Capacity estimation
Traffic
API design
Alert Retrieval
Database design
InfluxDB: Packet and Traffic Data
High-level design
Request flows
Packet Capture and Detection Flow
Detailed component design
Sync Analyzer: Real-Time Rule Engine
Trade offs/Tech choices
Full Packet Capture vs. Flow-Level Capture
Failure scenarios/bottlenecks
Sensor Agent Offline
Future improvements
Advanced ML Anomaly Detection
A network security monitoring tool watches every packet entering your data center and decides in real time whether it is legitimate traffic or an attack. Think of it as a security camera system for your network: it must record everything, analyze footage for suspicious behavior, and alert guards immediately when something looks wrong. The hard part is doing all of this at line speed (10 Gbps+) without adding noticeable latency to legitimate requests.
Functional
Real-time packet capture: Sensor agents deployed at network taps (firewalls, switches) and inside the API gateway capture packets in real time. Why two locations? The network layer sees all protocols (DNS, ICMP, TCP, UDP) and catches protocol-level attacks. The API gateway sees decrypted HTTP traffic after TLS termination, enabling detection of application-level threats like XSS and CSRF. Both vantage points are necessary because attackers target whichever layer is unmonitored.
The capacity numbers for a security monitoring tool are dominated by one reality: network traffic generates enormous data volumes, and storing everything is neither practical nor necessary. The art is determining what to keep, what to sample, and how to reduce data without creating blind spots.
Traffic
10 Gbps network throughput: This equals roughly 1.25 GB/sec of raw packet data. At an average packet size of 500 bytes, that is 2.5 million packets per second flowing through the monitoring pipeline.
The API surface serves two audiences: automated systems that ingest threat data and generate alerts, and human analysts who query, investigate, and manage incidents. Unlike user-facing APIs where latency drives design, security APIs prioritize completeness and auditability.
Alert Retrieval
1GET /v1/alerts?severity=high&start=2026-03-01T00:00:00Z&end=2026-03-11T23:59:59Z&page=1&limit=50
2Response: 200 OK {
3alerts: [{
4alert_id: string,
5severity: "critical" | "high" | "medium" | "low",
6type: "signature_match" | "anomaly" | "threat_intel",
7source_ip: string,
8destination_ip: string,
9timestamp: ISO-8601,
10description: string,
11status: "open" | "investigating" | "resolved"
12}],
13total: number,
14page: number
15}The data model spans three distinct workloads: high-volume time-series packet data, structured relational data for configurations and alerts, and fast-access cached rules for real-time detection. Each workload demands a different storage technology, and using the wrong one for any workload creates a bottleneck that undermines the entire system.
InfluxDB: Packet and Traffic Data
1measurement: network_packets
2time TIMESTAMP Nanosecond precision
3source_ip TAG Indexed for fast lookup
4dest_ip TAG Indexed for fast lookup
5protocol TAG TCP/UDP/ICMP/DNS
6device_id TAG Source sensor identifier
7packet_size FIELD Bytes
8flags FIELD TCP flags, DNS flags
9payload_hash FIELD SHA-256 of payloadThe architecture splits detection into two parallel paths: a synchronous analyzer for immediate, simple threat detection and an asynchronous analyzer for deeper, pattern-based analysis. This dual path is not a convenience; it is a necessity driven by the fundamental trade-off between speed and depth of analysis.
Mid-level: identify the core components (sensor agents, Kafka, Sync Analyzer, Async Analyzer, alert system) and explain the hybrid detection approach.
Senior: explain why Kafka decouples packet capture from analysis, how partitioning by source IP enables horizontal scaling, and the trade-off between sync detection speed and async detection depth.
Staff: discuss the consistency trade-offs between real-time alerting (eventual) and alert management (strong), the data retention tiering strategy, and how the system degrades gracefully when individual components fail.
Two request flows define the system: the detection flow (how threats are identified and handled) and the investigation flow (how analysts query and respond to alerts). Understanding the exact sequence of operations reveals where failures can occur and why the architecture handles them.
Packet Capture and Detection Flow
The core engineering challenge (the GATE of this problem) is building a packet analysis pipeline that processes 2.5 million packets per second through both a rule engine and an anomaly detection model, generating accurate alerts without overwhelming analysts with false positives. Every component in this section exists to solve some aspect of that challenge.
The GATE insight: the packet analysis pipeline must balance two competing goals. Detection sensitivity (catching every real threat) pushes toward more aggressive rules and lower thresholds. False positive control (not drowning analysts in noise) pushes toward conservative rules and higher thresholds. The dual-path architecture (sync for known threats, async for pattern analysis) resolves this tension by letting each path optimize for its strength.
Sync Analyzer: Real-Time Rule Engine
Every architectural decision in this system balances security effectiveness against operational constraints. Understanding these trade-offs, and being able to articulate why you chose one side, demonstrates that you made deliberate engineering decisions rather than following patterns blindly.
Full Packet Capture vs. Flow-Level Capture
Full packet capture stores the complete packet including payload. This enables deep forensic analysis (reconstructing exactly what data was exfiltrated) and application-level threat detection (inspecting HTTP bodies for malicious content). The cost is storage: roughly 108 TB/day at 10 Gbps.
In a security monitoring system, every failure scenario is also a security vulnerability. A monitoring gap is not just a degraded user experience; it is an opportunity for an attacker who knows (or discovers) that the system is blind.
Sensor Agent Offline
Scenario: A sensor agent at a network tap crashes or loses connectivity to the Capture Service.
These improvements extend the system's detection capabilities without redesigning the core architecture. Each builds on the existing Kafka pipeline and analysis framework.
Advanced ML Anomaly Detection
The current Async Analyzer uses statistical baselines and simple clustering. Advanced ML models (autoencoders, graph neural networks) can detect sophisticated attack patterns that statistical methods miss. An autoencoder trained on normal traffic learns to reconstruct typical patterns; traffic that cannot be reconstructed accurately is flagged as anomalous. Graph neural networks model the relationships between devices and detect unusual communication patterns (a database server suddenly communicating with an external IP it has never contacted before). These models run as additional analysis stages in the Async Analyzer pipeline, consuming the same InfluxDB data without requiring changes to the ingestion path.
Try this problem yourself
Reading a solution is not the same as producing one under interview pressure. Design it on the whiteboard and get scored feedback.
0%
Editorial Solution
System requirements
Functional
Capacity estimation
Traffic
API design
Alert Retrieval
Database design
InfluxDB: Packet and Traffic Data
High-level design
Request flows
Packet Capture and Detection Flow
Detailed component design
Sync Analyzer: Real-Time Rule Engine
Trade offs/Tech choices
Full Packet Capture vs. Flow-Level Capture
Failure scenarios/bottlenecks
Sensor Agent Offline
Future improvements
Advanced ML Anomaly Detection
Table of Contents
System requirements
Functional
Capacity estimation
Traffic
API design
Alert Retrieval
Database design
InfluxDB: Packet and Traffic Data
High-level design
Request flows
Packet Capture and Detection Flow
Detailed component design
Sync Analyzer: Real-Time Rule Engine
Trade offs/Tech choices
Full Packet Capture vs. Flow-Level Capture
Failure scenarios/bottlenecks
Sensor Agent Offline
Future improvements
Advanced ML Anomaly Detection