A Go program pipes three worker pools (request generation, sending, response handling) through concurrency-safe queues. It runs as pods on Kubernetes on DigitalOcean, scaled up and down by a small script according to how many targets are queued.
Section: Designing the HTTP/1.1 sending cannon | Section: Scalling the cannon with Kubernetes | Section: Custom autoscroller
Components
Component
Role
Where
Request generation pool
Produces the hand-crafted HTTP/1.1 requests to send.
Section: Designing the HTTP/1.1 sending cannon
Sender pool
Goroutines that each take a fasthttp client from a pool, send a raw request to a pre-resolved IP, and return the client.
Section: Designing the HTTP/1.1 sending cannon | Near: I created n (number of HTTP Sender | Section: Skipping DNS resolution
Response handler pool
Processes the responses coming back from the sender pool.
Section: Designing the HTTP/1.1 sending cannon
massdns
Resolves all target DNS records before sending starts, so no request waits on DNS.
Near: I just used massdns
Queue service
Receives regular pings from each sender pod as proof that the pod is still alive.
Near: Each HTTP cannon pod was pinging queue
Custom autoscaler script
A JS script that calls the Kubernetes API to scale the sender Deployment up and down by how many targets are queued.
Section: Custom autoscroller
Figures, as the source states them
Figure
As stated
Note
Where
HTTP/1.1 requests sent in the run
500,000,000 requests
Total over the run, which took a couple of hours
Near: Sent 500 million HTTP/1.1 requests to 2.5
Target hosts
2,500,000 hosts
Total over the run
Near: Sent 500 million HTTP/1.1 requests to 2.5
Upper end of reported per-pod request rate
400 requests per second
Upper end of the stated range of 100 to 400 per pod
Near: Each pod achieved 100-400 requests per second
Pods at peak scale
60 pods
Maximum the autoscaler reached
Near: It scaled from 0 to 60 pods | Near: Scaled to 60 pods
Hosts per work chunk
200 hosts
Near: split the work into 200 hosts per
Time before the first request byte on a new connection
160 milliseconds
Approximate; DNS plus new TLS connection to a fast site, measured from the author's machine
Send hand-crafted requests with a forked fasthttp client in Go, skipping request normalisation and DNS lookups
moczadlo-2024-http-request-cannon#d1at corpus version 26a1b3a7e3dd
Chosen
The sender is written in Go on the fasthttp library, forked to drop its per-request normalisation and to add a method for sending raw, non-RFC-compliant requests. Each request dials an already-resolved IP directly through an overridden Dial function.
Near: I ended up with fasthttp library | Section: Optimizing the library | Section: Skipping DNS resolution
Rejected
Rust. The author tried it but found async tokio types too hard to work with.
Near: Yes, I tried implementing it in Rust
Go's standard net/http client. The author knew it was not the fastest; fasthttp's benchmarks claim its client is up to 10 times faster.
Section: Choosing right HTTP library
What forced it
The requests had to reach many different hosts on different networks, so the author could not rely on reusing connections, and in his laptop tests DNS plus a new TLS connection to a fast site took about 160ms before the first byte; the requests were also hand-crafted, so parsing and normalising them was wasted work.
Near: I can't rely on reusing connections | Near: my server spent ~160ms before sending a | Near: We are crafting HTTP/1.1 requests by hand
Reasoning
The author picked Go for simplicity, concurrency support and speed, and removed whatever steps could be removed from each request, preferring not to build performant DNS resolution himself.
Near: I chose Go because it is simple | Section: How can we optimize it?
Outcome
The author reports that removing the normalisation step saved a lot of CPU cycles.
Pipe separate worker pools for generating, sending and handling requests through concurrency-safe queues
moczadlo-2024-http-request-cannon#d2at corpus version 26a1b3a7e3dd
Chosen
Three worker pools (request generation, sender, response handler) are joined by concurrency-safe queues, and objects and memory are reused instead of creating new objects and goroutines per request.
Section: Designing the HTTP/1.1 sending cannon
Reasoning
The author likes simplicity and wanted to reuse as many objects and as much memory as possible.
Section: Designing the HTTP/1.1 sending cannon
Outcome
The author's own verdict is that it worked great: each part was separate and could be scaled on its own, and it was easy to debug and reason about.
Near: It worked great, each component was separated
Run the sender as pods on DigitalOcean Kubernetes, fed chunks of 200 hosts and scaled from queue length by a small script
moczadlo-2024-http-request-cannon#d3at corpus version 26a1b3a7e3dd
Chosen
Work is split into chunks of 200 hosts, each run to completion by a single worker before it moves on. Pods run on Kubernetes on DigitalOcean, and a JS script calls the Kubernetes API to scale the Deployment by the number of queued targets.
Section: Splitting the work into chunks | Section: Scalling the cannon with Kubernetes | Section: Custom autoscroller
What forced it
The job had to cover 2.5 million hosts with about 200 requests each without overwhelming any one target server, so the load had to be spread across many servers.
Near: I had 2.5 million hosts and wanted | Near: we do not want to overwhelm any
Reasoning
The author wanted the run done in a couple of hours. Chunks were meant to finish within a couple of minutes yet be big enough not to waste time on new connections; he found 200 optimal and wanted to limit the requests lost when failure-prone pods died. DigitalOcean was chosen for cost, as it gives 2TB+ of bandwidth per droplet and the job sent terabytes.
Near: ideally in a couple of hours | Section: Splitting the work into chunks | Section: Scalling the cannon with Kubernetes
Outcome
The autoscaler took the deployment from 0 to 60 pods in a couple of minutes.
The sender's own traffic saturated the network, so pod liveness pings were lost and kubelet killed the pods
moczadlo-2024-http-request-cannon#f1at corpus version 26a1b3a7e3dd
Trigger
The pods generated so much traffic that the author describes it as DDoSing himself; DigitalOcean's network could not cope.
Section: DDoS as a Service
How it failed
Each pod pinged the queue service to show it was alive, but under its own outbound load the pings were not sent at all, and after a couple of minutes kubelet killed the pod.
Near: Each HTTP cannon pod was pinging queue
Impact
Kubelet killed sender pods after a couple of minutes without pings.
Near: after a couple of minutes kubelet would
Fix
The author gives this as another reason to decrease the number of hosts per chunk; the post does not say what size was used before or after.