AI Skills AI技能 6h ago Updated 2h ago 更新于 2小时前 43

Where Sandbox Ingress Speed Actually Comes From 沙箱入口速度究竟从何而来

Tensorlake rebuilt its sandbox ingress path by replacing an L7 reverse proxy hop with an L4 forwarder using kernel TLS (kTLS) and splice(2), achieving significant CPU and throughput gains Most performance improvement came from eliminating the application-layer request parsing overhead, not from kTLS itself as initially expected kTLS enabled a zero-copy path by moving TLS record processing into the kernel, adding a smaller but meaningful throughput gain on top of the L4 transition The edge gatewa Tensorlake将沙箱入口的L7反向代理重构为L4转发器,通过kTLS和splice(2)实现零拷贝传输 性能提升主要来自移除HTTP/2解析层而非kTLS本身,kTLS仅贡献约26%的CPU开销 边缘网关保持L7处理协议感知路由,数据面层改为L4仅负责字节转发 路由信息通过长度受限的前导码传递,存活检测改为基于字节计数的空闲超时机制 该方案跨AWS、GCP等云平台部署,避免依赖单一云厂商的网络原语

58
Hot 热度
72
Quality 质量
55
Impact 影响力

Analysis 深度分析

TL;DR

  • Tensorlake rebuilt its sandbox ingress path by replacing an L7 reverse proxy hop with an L4 forwarder using kernel TLS (kTLS) and splice(2), achieving significant CPU and throughput gains
  • Most performance improvement came from eliminating the application-layer request parsing overhead, not from kTLS itself as initially expected
  • kTLS enabled a zero-copy path by moving TLS record processing into the kernel, adding a smaller but meaningful throughput gain on top of the L4 transition
  • The edge gateway retained its L7 role because it performs protocol-aware routing, authentication, and request transformation that require application-layer visibility
  • L4 forwarding became viable for the dataplane hop because routing decisions were already made upstream, and missing L7 capabilities (routing, liveness) were rebuilt using connection-level mechanisms

Why It Matters

This case study provides a concrete, measured example of the L7-vs-L4 tradeoff that every AI infrastructure team faces when designing proxy chains for sandboxed or multi-tenant workloads. It challenges the common assumption that kernel TLS is the primary performance driver, showing instead that removing unnecessary parsing is often the bigger win—critical insight for practitioners optimizing ingress paths.

Technical Details

  • Architecture shift: The old path used two L7 hops (edge gateway with TLS + auth, followed by an L7 reverse proxy with mTLS and HTTP/2). The new path replaces the second hop with an L4 forwarder using kTLS and splice(2), forwarding plaintext to the sandbox app
  • Routing preamble: Since L4 cannot parse application protocols, routing information now arrives as a short, length-bounded preamble before tenant data, containing the sandbox ID and private target address (ip:port), learned from the scheduler
  • Liveness reconstruction: The idle timer mechanism was rebuilt by metering bytes per connection and reporting counts to the dataplane, which resets the sandbox idle timer as long as traffic flows
  • kTLS implementation: Uses Linux 6.x with CONFIG_TLS, software-based kTLS (CPU cryptography, no NIC offload), AES-256-GCM at ~7.9 GB/s per core, fail-closed design that refuses to start if kernel TLS ULP attachment fails
  • Measured performance: Plain L4 userspace-copy stage achieved 2.07 GB/s and 0.50 CPU-seconds per GB; kTLS added further gain with crypto accounting for ~26% of forwarder CPU, remainder from TCP handling and syscalls

Industry Insight

  • When evaluating performance optimizations in proxy chains, isolate each change incrementally rather than comparing only old vs. new systems; attributing gains to the wrong component (e.g., kTLS vs. removed parsing) leads to incorrect architectural decisions
  • L4 forwarding is a strong candidate for hops where upstream layers have already made protocol-aware decisions, but teams must budget engineering effort to rebuild routing, liveness, and error-handling capabilities at the connection level
  • Portability should constrain low-level networking choices; Tensorlake rejected VXLAN, eBPF, and CNI plugins in favor of application-layer L4 forwarding to maintain cross-cloud compatibility across AWS, GCP, and GPU neoclouds

TL;DR

  • Tensorlake将沙箱入口的L7反向代理重构为L4转发器,通过kTLS和splice(2)实现零拷贝传输
  • 性能提升主要来自移除HTTP/2解析层而非kTLS本身,kTLS仅贡献约26%的CPU开销
  • 边缘网关保持L7处理协议感知路由,数据面层改为L4仅负责字节转发
  • 路由信息通过长度受限的前导码传递,存活检测改为基于字节计数的空闲超时机制
  • 该方案跨AWS、GCP等云平台部署,避免依赖单一云厂商的网络原语

为什么值得看

本文提供了L7/L4代理分层设计的工程实践案例,帮助从业者理解协议解析成本与数据传输成本的分离方法。对于构建大规模沙箱或微服务架构的团队,该研究展示了如何通过精确测量验证技术假设,避免将性能收益错误归因。

技术解析

  • 架构变更:原路径为Client→Edge Gateway(L7)→L7 Proxy(mTLS+HTTP/2)→Sandbox,重构后变为Client→Edge Gateway(L7)→L4 Forwarder(kTLS+splice(2))→Sandbox(明文)。边缘网关继续使用Pingora处理TLS终止和协议路由,数据面层仅做字节转发。
  • kTLS实现细节:使用Linux 6.x内核的CONFIG_TLS支持,软件实现AES-256-GCM加密(约7.9 GB/s per core),通过splice(2)避免用户态缓冲区拷贝。设计为fail-closed模式,内核TLS ULP无法挂载时拒绝启动。
  • 路由与存活重建:L4转发器通过连接前导码(包含sandbox ID和目标ip:port)实现路由,替代原L7的HTTP路径解析。存活检测改为字节计量机制,转发器统计流量并重置沙箱空闲定时器。
  • 性能测量方法:采用三阶段对比测试(L7路径→L4+用户态拷贝→L4+kTLS),分离各组件贡献。实测L4转发器达到2.07 GB/s吞吐量,0.50 CPU-seconds/GB,其中加密占26%,其余为TCP处理和系统调用开销。

行业启示

  • L7/L4分层决策应逐跳评估:并非所有代理层都需要协议感知,当上游已完成路由决策时,下游可降级为L4转发以消除解析开销,但需重新设计路由和存活机制。
  • 性能归因需精确测量:kTLS等零拷贝技术常被高估,实际收益可能主要来自移除解析层。建议通过分阶段测试分离各组件贡献,避免错误归因导致架构决策偏差。
  • 跨云部署需避免厂商锁定:选择应用层机制而非VXLAN/eBPF等底层网络原语,可确保架构在不同云环境(包括GPU云)中保持可移植性。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Deployment 部署 Programming 编程 Research 科学研究