eBPF for Testing
What Is eBPF?
eBPF (extended Berkeley Packet Filter) is a Linux kernel technology that allows sandboxed programs to run inside the kernel without modifying kernel source code. Originally designed for packet filtering, eBPF has evolved into a general-purpose in-kernel virtual machine used for observability, security, and software testing.
Traditional approaches require modifying your application: importing SDKs, configuring middleware, or routing traffic through proxies. Each adds complexity, latency, and language-specific constraints. eBPF eliminates these trade-offs by observing from the kernel level, where all network traffic is visible regardless of language, framework, or architecture.
eBPF programs attach to specific kernel events — system calls, network functions, tracepoints — and execute a small, verified program when that event fires. The Linux kernel verifier ensures eBPF programs cannot crash the kernel, access unauthorized memory, or execute infinite loops.
For testing, the relevant attachment points are networking syscalls: sendto(), recvfrom(), write(), and read() on socket file descriptors.
Why eBPF for Testing
The testing industry spent two decades building tools that require application changes. eBPF removes all of these requirements.
Kernel-Level Capture
eBPF runs inside the Linux kernel, capturing every byte entering and leaving your application through network sockets. No proxies, no middleware, no blind spots.
Near-Zero Overhead
JIT-compiled and verified by the kernel, eBPF probes add only 1-3% latency during recording. Compare this to 10-30% for sidecar proxies.
Language Agnostic
Go, Java, Python, Node.js, Rust, C++, Ruby, PHP, Elixir — any language that makes network calls through Linux works automatically.
Full Protocol Support
HTTP, gRPC, PostgreSQL, MySQL, MongoDB, Redis, Kafka, GraphQL — all captured and decoded into human-readable test cases and mocks.
Key Takeaway: eBPF shifts the instrumentation burden from the application developer to the kernel. This is the same paradigm shift that eBPF brought to networking and security — and Keploy is bringing it to testing.
How Keploy Uses eBPF for API Testing
Keploy is the first testing tool built on eBPF for record and replay testing.
Recording Phase
Keploy attaches eBPF probes to the kernel's networking syscalls for your application's process. Every inbound request (HTTP, gRPC) and every outbound call (SQL queries, Redis commands, downstream HTTP, Kafka produce) is captured at the byte level and stored as YAML test cases with mocks.
Noise Detection
AI-powered analysis compares response fields across multiple recordings and identifies non-deterministic values — timestamps, UUIDs, session tokens. These are flagged with flexible matchers to eliminate flaky tests.
Replay Phase
Keploy replays recorded requests, intercepts all outbound calls via eBPF and returns recorded responses. The system clock is frozen at the original recording time for deterministic results.
CI/CD Integration
Keploy provides a CLI that runs as a step in your pipeline. Tests execute in seconds with mocked dependencies — no infrastructure to provision. Natively integrates with GitHub Actions, GitLab CI, Jenkins, and any CI system.
eBPF vs Sidecar vs SDK
Three approaches to capturing traffic for testing, each at a different layer of the stack.
eBPF (Keploy)
RecommendedCapture layer: Linux Kernel
Code changes: None
Protocol visibility: All network protocols
Performance overhead: 1-3%
Language support: Any
Sidecar Proxy
Capture layer: Network (user-space)
Code changes: Deployment config
Protocol visibility: HTTP, gRPC only
Performance overhead: 10-30%
Language support: Any
SDK / Library
Capture layer: Application
Code changes: Import library, wrap clients
Protocol visibility: Depends on library
Performance overhead: 5-15%
Language support: Language-specific
Key Takeaway: eBPF provides the widest protocol visibility with the lowest overhead and zero code changes. For comprehensive testing of services with database and queue dependencies, eBPF is the strongest approach.
Protocol Support and Wire-Level Capture
eBPF captures raw bytes. Keploy's protocol decoders parse them into structured, human-readable test cases and mocks.
HTTP APIs
HTTP/1.1, HTTP/2
Method, path, headers, body, status code
RPC
gRPC
Service, method, request/response protobuf
SQL Databases
PostgreSQL, MySQL
Query text, parameters, result sets
NoSQL Databases
MongoDB, Redis
Commands, keys, documents, responses
Message Queues
Kafka
Topic, partition, key, message payload
GraphQL
GraphQL over HTTP
Query, variables, response data
This protocol breadth enables full dependency mocking. When Keploy records a test for an HTTP endpoint that queries PostgreSQL and calls a downstream gRPC service, the resulting test includes mocks for both. No live database or downstream service is needed during replay.
Performance Overhead Analysis
eBPF's low overhead comes from its execution model: programs are JIT-compiled to native machine code and run in a sandboxed context within the kernel. Data is buffered in kernel ring buffers and drained to user space asynchronously.
For most teams, we recommend recording in staging environments where the 1-3% overhead is inconsequential. During replay in CI/CD, there is zero production overhead since tests run against recorded data.

Limitations and Considerations
eBPF-based testing is powerful but not without constraints. Transparency helps teams make informed decisions.
Linux Only
eBPF is a Linux kernel technology. For development on macOS or Windows, Keploy provides Docker-based workflows where recording and replay happen inside a Linux container. CI/CD environments run natively.
Kernel Version Requirements
eBPF features require Linux kernel 4.15+, with full functionality on 5.x+. Ubuntu 20.04+, Amazon Linux 2, and Debian 11+ all meet this requirement.
TLS-Encrypted Traffic
Keploy uses eBPF uprobes on TLS library functions (SSL_write, SSL_read) to capture data before encryption and after decryption — working transparently for most applications.
Privileged Access
Loading eBPF programs requires elevated privileges (root or CAP_BPF). CI/CD containers run as root by default. eBPF programs are kernel-verified and sandboxed.
See eBPF-Based Testing in Action
How Keploy captures traffic at the kernel level and generates mocks automatically.