Sitemap
Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

499 new links made the network count 608x slower

It worked in dev · Episode 18 · technique: connected components, one sweep

10 min read6 days ago

--

Press enter or click to view image in full size

How many separate networks are in the service mesh — groups of services that can reach each other and nothing outside? The platform team runs it after every routing change, to catch a cluster that has been cut off.

With 500 teams running their own clusters, it took 2.82 ms. Then the teams added 499 cross-team links, one each, so the whole mesh became one network. Same 5,000 services. The count took 1.71 seconds, and allocated 1.97 GB to return the number 1.

The problem

// adj[s] holds every service s has a link with. Links are two-way.
type Mesh [][]int

Count the networks: the groups where every service can reach every other one, directly or through others, and none can reach a service outside the group.

Press enter or click to view image in full size

What you would write

The admin UI already had a blast-radius page: pick a service, see everything a failure in it could reach. So Reachable existed, and it was tested:

--

--

Archit Agarwal
Archit Agarwal

Written by Archit Agarwal

PMTS @ Oracle | Golang | Docker | Kubernetes| Typescript | Node.js | .NET | Angular | AWS Certified Cloud Practitioner | Educator