Repository navigation
Description
What is the issue?
I've been replacing the previous iteration of the VPN we use for managing our network equipment with Tailscale and ran into a snag.
Last night I put Tailscale on our BGP router. It's a Supermicro 5018D-FN8T with a 4 core, 8 thread Broadwell-based Xeon D-1518 running Ubuntu 22.04 and FRR. We're getting full IPv4+IPv6 tables – 1.07 million routes – from a single upstream provider (our backup is just sending a default route).
Without Tailscale, our CPU usage is basically zero – htop reports a load average of between 0.1 and 0.2 out of 8, or between 1.25 and 2.5% total utilization.
With Tailscale, Load average is between 1.6 and 1.8, and htop reports tailscaled using between 150% and 300% CPU. I took this measurement while SSH'd in via a public IP address, so there was no traffic going over tailscale0.
After running tailscale down and tailscale logout, tailscaled uses less CPU, but it still runs hot – Between 20% and 170% CPU with a load average of ~0.5.
Here's the output of the top command in go tool pprof on the results of tailscale debug --cpu-profile while Tailscale was logged in and running:
(pprof) top 20
Showing nodes accounting for 20.07s, 73.03% of 27.48s total
Dropped 218 nodes (cum <= 0.14s)
Showing top 20 nodes out of 125
flat flat% sum% cum cum%
7.62s 27.73% 27.73% 7.62s 27.73% runtime/internal/syscall.Syscall6
1.69s 6.15% 33.88% 7.02s 25.55% runtime.mallocgc
1.65s 6.00% 39.88% 1.65s 6.00% runtime.memclrNoHeapPointers
1.50s 5.46% 45.34% 5.61s 20.41% runtime.scanobject
0.95s 3.46% 48.80% 1.56s 5.68% runtime.findObject
0.85s 3.09% 51.89% 1.91s 6.95% runtime.greyobject
0.84s 3.06% 54.95% 0.88s 3.20% runtime.pageIndexOf (inline)
0.62s 2.26% 57.21% 0.62s 2.26% runtime.memmove
0.61s 2.22% 59.43% 0.61s 2.22% runtime.nextFreeFast (inline)
0.47s 1.71% 61.14% 0.47s 1.71% runtime.madvise
0.46s 1.67% 62.81% 0.52s 1.89% runtime.writeHeapBits.flush
0.42s 1.53% 64.34% 1.54s 5.60% github.com/mdlayher/netlink.(*Attribute).unmarshal
0.42s 1.53% 65.87% 0.43s 1.56% runtime.heapBitsForAddr
0.29s 1.06% 66.92% 8.26s 30.06% github.com/mdlayher/netlink.(*conn).Receive
0.29s 1.06% 67.98% 6.12s 22.27% runtime.gcDrain
0.29s 1.06% 69.03% 0.38s 1.38% runtime.spanOf (inline)
0.28s 1.02% 70.05% 4.10s 14.92% github.com/jsimonetti/rtnetlink.(*RouteAttributes).decode
0.28s 1.02% 71.07% 0.28s 1.02% runtime.writeHeapBits.write
0.27s 0.98% 72.05% 0.27s 0.98% runtime.heapBits.nextFast (inline)
0.27s 0.98% 73.03% 1.13s 4.11% runtime.heapBitsSetType
Seeing netlink in there increases my confidence that the issue has to do with the size of or the churn in the routing table. I've attached the CPU profile.
For now, I've removed Tailscale from the router. It isn't the end of the world – the router's at the edge of our network, so it's publicly addressable – but the non-uniformity makes our setup a bit harder to maintain and document.
Expected behavior
Tailscale doesn't take much CPU to run, and its CPU utilization is proportional to the amount of traffic going over the tunnel. Having a large routing table with regular churn does not effect Tailscale's CPU usage.
Actual behavior
Having a large routing table with regular churn causes Tailscale to use almost 1/3 of the available CPU on a moderately powerful system.
Let me know if there's any other data that would be helpful.
Steps to reproduce
No response
Are there any recent changes that introduced the issue?
I just put Tailscale on this box, so I'm not sure.
OS
Linux
OS version
Ubuntu 22.04
Tailscale version
1.38.1
Other software
- FRR -
bgpd,bfdd,staticdandzebra. - iptables (netfilter backend) + conntrack for local traffic destined to and originating from the router. No filters on forwarded traffic.
- Two non-Tailscale WireGuard tunnels using the
wireguardkernel module.
Bug report
BUG-7a32503ac49e9b8957ba8fe91a4af06754123ea68440265d49a7fc5c636752a5-20230320220414Z-d196d3a42f9b574a
Activity
davidbalbert commentedon Mar 20, 2023
Should have added: This system wasn't acting as an exit node or subnet router.
[-]High CPU usage in the face of routing table churn (Tailscale 1.38.1, Ubuntu 22.04)[/-][+]High CPU usage with 1 million routes in table[/+]lukegb commentedon Apr 15, 2023
For my purposes here I use a custom build of Tailscale using approximately this Nix derivation:
This is obviously much less good at noticing network condition changes, but on routers I don't mind so much and trading that off against having Tailscale not output millions of log lines while consuming 1.5 cores all the time is probably for the best.
If we could have an environment variable tunable to switch to the polling monitor, or possibly some heuristic inside the netlink-based one that notices that it's very expensive/high churn rate (something like "have I been woken up every debounce interval for the last 10 debounce intervals"?), that would probably help significantly.
There are still some CPU spikes, but nothing as drastic as the current situation.
bradfitz commentedon Apr 17, 2023
@davidbalbert, FWIW I have the same SuperMicros and also run Tailscale (albeit an old version) on a full router with the ~same number of routes. I wonder if this is a regression. I'd already done some work to optimize this in the past. I'll upgrade my Tailscale and look what's happening.
davidbalbert commentedon Apr 17, 2023
@bradfitz thank you! Curious to see what you find.
bradfitz commentedon Apr 17, 2023
On my router, I ran:
Then copied the to my desktop and ran:
/cc @andrew-d
bradfitz commentedon Apr 17, 2023
The earlier optimization was 2a67bea but we can do more.
net/interfaces: cache "home" router lookup on big Linux routers
13 remaining items
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: move network monitoring from wgengine/monitor to net/netmon
all: avoid repeated default interface lookups
all: avoid repeated default interface lookups
all: avoid repeated default interface lookups
all: avoid repeated default interface lookups
gucki commentedon Jul 18, 2023
I'm also running Tailscale (1.44.0) on a full-table bgp router (using bird) and only see around 5% CPU usage. However, Tailscale seems to produce a lot of traffic to the control-plane and the logs get flooded with:
What's the reason that Tailscale has to send all route changes to the control-plane? What about implementing a configuration option to make this configurable?
kotiktr commentedon Sep 13, 2025
BUG-27d07a97c6f3c6cd7b5d1522bed9875b3a05d436c032e288469fa60f1b4cbf80-20250913200340Z-157c023c3ae310a6
I had high CPU usage problem, after so many tries, found out that it was caused because I activated Services on admin panel. It might be your problem too.
sfllaw commentedon Mar 19, 2026
On modern Linux systems (post CentOS/RHEL 6), could we avoid parsing the virtual files in /proc/net over and over again? I suspect that we’re burning CPU formatting and parsing when we could be using netlink sock_diag(7) to do things a lot more efficiently. Note that I haven’t tried this for real yet.