跳到主内容
@wquguru
精选88Hacker News Best(web_list)技巧与观点

Tailscale 性能优化:多队列与内存管理技术详解

Making Tailscale Faster

原文
发到 X
推荐理由

深入解析了 Tailscale 在多队列、内存分配和内核交互层面的工程实践,对关注网络架构与性能优化的开发者极具参考价值。

Blog|productSeptember 22, 2026

博客 | 产品 2026年9月22日

We’re making Tailscale faster

我们正在让 Tailscale 更快

Authors

作者

Kabir Sikand

Kevin Purdy

Contributors

贡献者

Alex Valiushko

Claus Lensbøl

Michael J. Fromberger

Jordan Whited

If you’ve been following Tailscale at all, you know we’re really just a bunch of geeks who care a lot about internet connectivity. One thing we love to talk about is NAT Traversal. That’s one of the core value-adds with Tailscale: we tamed NAT. Not every network is friendly, but Tailscale can still find a path in a wide range of conditions. That’s not the only important thing for an internet protocol: the data plane also has to be performant.

如果你一直关注 Tailscale,你就知道我们其实是一群非常关心互联网连接性的极客。我们喜欢谈论的话题之一是 NAT 穿透。这正是 Tailscale 的核心增值之一:我们驯服了 NAT。并非所有网络都友好,但 Tailscale 仍能在各种条件下找到路径。但这并不是互联网协议唯一重要的方面:数据平面也必须具备高性能。

Over the years we’ve been investing in making Tailscale fast. We started by increasing TCP throughput on Linux devices. Then we made significant breakthroughs in wireguard-go to surpass 10Gb/s on bare metal. We later leveraged segmentation offloads to increase throughput over 4x for UDP-based applications. Alongside these improvements to our data plane, we built primitives like Tailscale Peer Relays, which can improve network performance in tricky conditions.

多年来,我们一直在致力于提升 Tailscale 的速度。我们从提高 Linux 设备上的 TCP 吞吐量开始。随后,我们在 wireguard-go 中取得了重大突破,在裸机上实现了超过 10Gb/s 的速率。后来,我们利用分段卸载技术,使基于 UDP 的应用程序吞吐量提高了 4 倍以上。伴随这些对数据平面的改进,我们还构建了诸如 Tailscale Peer Relays(对等中继)这样的基础组件,它可以在棘手条件下改善网络性能。

All of this has made Tailscale practical for more performance-sensitive workloads. It means you can use Tailscale for continuous integration, agentic workflows, remote development environments, robotic edge devices, heavy data and telemetry workloads, and more. Tailscale helps those devices connect across a wide range of network conditions.

所有这些使得 Tailscale 能够应用于更多对性能敏感的工作负载。这意味着你可以将 Tailscale 用于持续集成、智能体工作流、远程开发环境、机器人边缘设备、重型数据和遥测工作负载等。Tailscale 帮助这些设备在各种网络条件下进行连接。

So yeah, we think Tailscale is fast. But we also think we can make it faster.

所以,是的,我们认为 Tailscale 很快。但我们认为我们还可以让它更快。

Today we’ll detail how we’re boosting throughput for app connectors, subnet routers, and exit nodes, with some multi-queue technology (landing in the second half of 2026). We’ll also preview some throughput and memory overhead improvements we’re deploying in upcoming stable client releases. And we’ll look at some performance tooling issues we want to solve for our customers.

今天,我们将详细介绍如何通过一些多队列技术(将于 2026 年下半年上线)来提升应用连接器、子网路由器和出口节点的吞吐量。我们还将预览一些即将在后续稳定版客户端发布中部署的吞吐量和内存开销改进。此外,我们还会探讨一些我们希望为客户解决的性能工具问题。

Less memory overhead for small packets

减少小数据包的内存开销

Most network packets are tiny, like 1 KiB. But to use Linux’s most efficient throughput tools, like Generic Receive Offload (GRO), Tailscale has to be ready to accept 64 KiB of traffic at once. It’s a bit like container shipping: the ports, ships, and trucks are built for one container shape, however full it happens to be.

大多数网络数据包都很小,例如 1 KiB。但要使用 Linux 最高效的吞吐量工具,如通用接收卸载(GRO),Tailscale 必须准备好一次性接受 64 KiB 的流量。这有点像集装箱运输:港口、船只和卡车都是为一种集装箱形状设计的,无论其装载量如何。

Tailscale has to unpack those containers—every packet gets decrypted and delivered on its own. The wireguard-go implementation that informs Tailscale’s cryptography and networking essentials, only offers one 64 KiB buffer size to unpack into. So a 1 KiB packet is copied into its own 64 KiB buffer, every time. That’s a rich optimization target.

Tailscale 必须解包这些容器——每个数据包都会被单独解密并交付。负责 Tailscale 加密和网络核心功能的 wireguard-go 实现仅提供一个 64 KiB 的缓冲区用于解包。因此,每次都要将 1 KiB 的数据包复制到其专属的 64 KiB 缓冲区中。这是一个极具潜力的优化目标。

On Linux and Android, Tailscale now leaves those packets where they landed. It identifies where each one starts and ends inside the single large read instead of copying it somewhere new. Small packets stay small in memory, many share one allocation, and they spend less time being copied. In itself, this led to a roughly 5% speed-up in many network configurations.

在 Linux 和 Android 上,Tailscale 现在让数据包停留在它们到达的位置。它在单个大读取操作中识别每个数据包的起始和结束位置,而不是将其复制到其他新位置。小数据包在内存中保持较小体积,多个数据包共享同一块分配空间,从而减少了复制所需的时间。仅此一项改进就在许多网络配置中带来了约 5% 的速度提升。

Separately, we shortened packet queues—the lines packets wait in between stages of the pipeline. The queues are there to absorb bursts of traffic. Testing showed that most of that depth went unused, while shorter queues meant less waiting time and less memory overhead.

此外,我们缩短了数据包队列——即数据包在流水线各阶段之间等待的队列。这些队列的存在是为了吸收流量突发。测试表明,大部分队列深度并未被使用,而较短的队列意味着更少的等待时间和更低的内存开销。

What do we do with all that freed-up memory space? We passed the savings on to some of the hardest-working nodes: subnet routers and app connectors.

那么,我们如何处理所有释放出来的内存空间呢?我们将节省下来的资源惠及了一些最繁忙的节点:子网路由器和应用连接器(app connectors)。

Multi-queue for subnet routers, app connectors, and exit nodes

为子网路由器、应用连接器和出口节点实施多队列机制

Subnet routers can look completely different across different tailnets. For someone running a small homelab network, a subnet router can easily handle a small set of 192.168.x.y non-Tailscale devices. A subnet router that fronts a cloud deployment, one with hundreds of peers, will carry substantially more traffic.

子网路由器在不同的 tailnet(尾网)中可能看起来截然不同。对于运行小型家庭实验室网络的用户来说,子网路由器可以轻松处理一小部分非 Tailscale 的 192.168.x.y 设备。而位于云部署前端、拥有数百个对等节点的子网路由器,则需承载显著更多的流量。

Until recently, subnet routers, app connectors, and exit nodes processed packets for multiple independent streams in one ordered, single-thread pipeline. That meant a single lane was shared across many connections, because a receiving application must never see its own packets arrive out of order.

直到最近,子网路由器、应用连接器和出口节点都在一个有序的单线程流水线中处理来自多个独立流的数据包。这意味着单条通道被众多连接共享,因为接收应用程序绝不能看到自己的数据包乱序到达。

Having reduced our memory footprint, we had capacity to implement a multi-queue system: several lanes instead of one, scaled to the machine’s resources rather than the number of peers. Each stream of packets gets a lane and stays there, while the lanes run in parallel, allowing work to spread across CPU cores.

在缩减了内存占用后,我们具备了实施多队列系统的条件:用多条通道替代单条通道,并根据机器的资源而非对等节点的数量进行扩展。每条数据包流获得一条专属通道并保持其中,同时各通道并行运行,使工作负载能够分散到各个 CPU 核心上。

It results in higher aggregate capacity and lower delay between receiving and forwarding packets for subnet routers and app connectors. Hardware you already have gets used more efficiently. App connectors and exit nodes, typically serving many users with short-lived connections, get a particularly noticeable boost.

这带来了更高的总容量,并降低了子网路由器和应用连接器在接收与转发数据包之间的延迟。你现有的硬件得到了更高效的利用。应用连接器和出口节点通常服务于许多具有短生命周期连接的用户,因此获得了尤为显著的提速效果。

“This translates into lower latency, essentially faster processing of data from the moment we read it off the wire to the moment we send it to the OS,” said Alex Valiushko, member of technical staff at Tailscale.

"这转化为更低的延迟,本质上是从我们读取网络数据到将其发送给操作系统的那一刻起,数据处理速度更快。" Tailscale 技术团队成员 Alex Valiushko 表示。

Throughput gains with writev

writev 带来的吞吐量提升

Taking advantage of Linux’s writev capabilities in the Tailscale client, Tailscale can pass multiple pieces of packet data to the Linux kernel in one operation, rather than having to copy and combine those pieces before passing them to the kernel. The v in writev stands for “vector”: Tailscale can describe separate pieces of data that need to be moved, without moving them. It means fewer copies of packet data in memory, fewer write operations, and higher throughput.

通过在 Tailscale 客户端利用 Linux 的 writev 功能,Tailscale 可以在一次操作中向 Linux 内核传递多个数据包片段,而不必在传递给内核之前复制并合并这些片段。writev 中的 v 代表“向量”(vector):Tailscale 可以描述需要移动的不同数据片段,而无需实际移动它们。这意味着内存中数据包副本更少、写入操作更少,从而带来更高的吞吐量。

Faster startup with netmap caching

通过 netmap 缓存实现更快的启动

For now, these speed-ups are available only on Linux and, where applicable, Android systems. But we’ve also been working on features that apply to other systems. Tailscale clients will soon be able to use netmap caching to start more quickly in many conditions.

目前,这些加速功能仅在 Linux 以及适用的 Android 系统上可用。但我们也在开发适用于其他系统的功能。Tailscale 客户端很快将能够使用 netmap 缓存,在许多情况下更快地启动。

A machine connecting to Tailscale usually starts by connecting to Tailscale’s control plane, in something like 100 milliseconds on a typical network. The machine authenticates and gets a "network map" (netmap) describing the devices it can reach and how to reach them. This startup process should feel fast, maybe instantaneous, and with a good network connection, it typically does.

连接到 Tailscale 的机器通常首先连接到 Tailscale 的控制平面,在典型网络上大约需要 100 毫秒。该机器进行身份验证并获得一个“网络映射”(netmap),描述它可以访问哪些设备以及如何访问它们。这个启动过程应该感觉很快,也许是瞬间完成的,在网络连接良好的情况下,通常确实如此。

But when you’re on bad airplane Wi-Fi, or inside a hotel with aggressive filtering, or other not-great connectivity setups, it can take a while for the machine to reach the control plane—and sometimes you may not be able to reach it at all. It’s often not obvious where the problem is, but the effect is that you can’t reach other devices.

但是,当你处于糟糕的飞机 Wi-Fi 环境下、在有严格过滤措施的酒店内,或其他网络连接不佳的情况下,机器可能需要一段时间才能连接到控制平面——有时甚至根本无法连接。问题所在往往不明显,但其结果是无法访问其他设备。

Even under ideal network conditions, 100 milliseconds of startup latency may be too much for some latency-sensitive workloads.

即使在理想的网络条件下,100 毫秒的启动延迟对于某些对延迟敏感的工作负载来说可能也太长了。

Netmap caching helps machines get connected when the control plane is not quickly reachable. When it’s enabled, each device on your tailnet stores a copy of the netmap on disk. When a device starts up, it can use that cached copy to establish connections with other devices on the tailnet, until it’s able to contact the control plane to get the latest info. (These connections are negotiated between the devices directly, and Tailscale does not see any of the traffic, as usual).

Netmap 缓存在控制平面无法快速访问时帮助机器建立连接。启用后,你 tailnet 上的每个设备都会在磁盘上存储一份 netmap 的副本。当设备启动时,它可以使用该缓存副本与 tailnet 上的其他设备建立连接,直到它能够联系控制平面以获取最新信息。(这些连接由设备之间直接协商,Tailscale 不会看到任何流量,一如往常)。

“Bad network conditions—that’s really the space where people can get a lot of utility out of netmap caching,” said Claus Lensbøl, member of technical staff. “[A device client says], ‘You know what? We haven’t talked to control yet. We’ll probably get there soon. In the meantime, you can still start doing something.’”

“糟糕的网络条件——这确实是人们可以从 netmap 缓存中获得大量实用价值的场景,”技术团队成员 Claus Lensbøl 表示。“[设备客户端会说]:‘你知道吗?我们还没跟控制平面联系过。我们可能很快就能连上。在此期间,你仍然可以开始做点什么。’”

There are a few limitations. Caching can only work if the device has previously connected to the tailnet at least once, to fetch a network map from the control plane. In addition, netmap caching requires the device to have persistent disk space to store the cache. We’ve taken care to minimize unnecessary disk writes, but in some cases you may not want to enable it. For example, on exceptionally large tailnets, updating a cache may require a lot of disk traffic. Likewise, devices that use slow or wear-sensitive storage like SD cards may prefer not to enable netmap caching.

存在一些限制。缓存仅在设备之前至少连接过一次 tailnet(以便从控制平面获取网络映射)时才能工作。此外,netmap 缓存要求设备拥有持久化的磁盘空间来存储缓存。我们已采取措施尽量减少不必要的磁盘写入,但在某些情况下您可能不希望启用它。例如,在规模异常大的 tailnet 中,更新缓存可能需要大量的磁盘流量。同样,使用慢速或易磨损存储介质(如 SD 卡)的设备可能更倾向于不启用 netmap 缓存。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件