cloudflare / cloudflare/workerd

🐛 Bug Report — Small response body writes get sent out on individual TCP packets (astro + cloudflare)

Open
#1,235 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

(also raised this in https://github.com/cloudflare/workers-sdk/issues/3997, apologies for the duplicate)

### Which Cloudflare product(s) does this pertain to?

Workers Runtime, Wrangler core

### What version(s) of the tool(s) are you using?

3.9.0

### What version of Node are you using?

18.17.1

### What operating system are you using?

Mac

### Describe the Bug

Clone https://github.com/ShaunHallTHG/astro-cloudflare-demo

Build and run inside wrangler locally
`npm i && npm run build && npm run preview:astro`

Open a TCP packet capture (e.g. wireshark) and inspect the TCP stream on the following request
`curl http://localhost:8787/blog`

See how the 15Kb response body is split over 137 packets (500 including client ACKs). When deployed, this creates significant back-pressure on the producer, creating large differences between TTLB and TTFB web vitals. When using a significantly more complex astro application, this has an effect of around 1 second latency on TTLB.

I would like to see Wrangler buffer the response data into larger chunks to get better throughput over TCP.

### Please provide a link to a minimal reproduction

https://github.com/ShaunHallTHG/astro-cloudflare-demo

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.