A bidding server keeps 6 CPU cores making copies of ad requests and throwing them away

Updates10 Nov 2026Damian Naglak
A bidding server keeps 6 CPU cores making copies of ad requests and throwing them away

Garbage in a bidder costs CPU as well as memory. The garbage collector spends that CPU checking the data the bidder keeps, again and again, and a bidder pays for it in cores or in spare memory.

Last week I showed the memory side: inside the exchange’s cluster, the bidder can read a request in place instead of copying it, so it makes far less garbage. This post is about CPU. The garbage collector frees memory the bidder no longer uses, but it has no list of what that memory is. So it marks everything still in use, following every link from a campaign to its line items and from a line item to its creatives, through all 2 GB of campaigns, and frees whatever it did not reach. Marking is CPU work, done on the same cores that answer bid requests.

It works like a full phone where you can’t pick photos to delete, only tick the ones to keep. Everything not ticked is deleted. Next time the phone is full, you tick them all again, even the ones you ticked last week. In a bidder, the photos you keep are the campaigns, and the bid requests are millions of new photos every minute that you never tick.

So two things decide the CPU cost. The campaigns decide how long one cleanup takes, because they are what gets marked. The bid requests decide how often it happens, because they fill the free memory. More free memory means fewer cleanups, which is the trade between memory and CPU. Less garbage per request also means fewer cleanups, without the extra memory.

I measured it on the same 20,000 real bid requests as my zero-copy posts: one bidder on 4 cores, 2 GB of campaign-sized data, 30 seconds per format. With Go’s default of as much free memory as live data, 2.5 GB, protobuf left 4,432 bytes of garbage per request and spent 1.7 µs per request on cleaning. FlatBuffers left 77 bytes and spent 0.04 µs, about 40 times less. With only 0.25 GB free, protobuf’s cleaning rose to 10 µs per request, while FlatBuffers stayed at 0.2 µs. At 1 million requests per second, a protobuf bidder needs about 16 cores and a FlatBuffers bidder about 10. Most of the 10 is network work that every format pays. The other 6 cores go to copying requests and cleaning up after them, and protobuf needs 2.5 GB of spare memory on top to keep it at 6.

Programmatic is billions of requests a day, and most of them end without a bid, so the cost of handling one request decides how many a bidder can afford to see. A bidder written in Go, Java, C# or any other language with a garbage collector pays a version of this cost today without seeing it, because it shows up only as more machines. A containerized bidder runs inside the exchange’s cluster, where it can drop compression and read requests in place, so it stops paying for most of that garbage. The CPU it saves goes to bidding, so the same machines take more traffic, and impressions aren’t lost to a cap before any buyer sees them.