Deploy a VLESS over WebSocket relay on Cloudflare Workers without managing your own server.
Study how the code batches small outgoing packets to reduce the number of send calls.
See how large downloads are sent directly while small chunks are grouped before sending.
Adjust the concurrent connection setting when moving the code from Workers to Cloudflare Snippets.
| toicf/graintcp | automationsmanufaktur-labs/open-invoice-germany | ballwictb/besur-themes | |
|---|---|---|---|
| Stars | 58 | 58 | 58 |
| Language | — | TypeScript | CSS |
| Setup difficulty | moderate | moderate | easy |
| Complexity | 4/5 | 3/5 | 1/5 |
| Audience | developer | pm founder | developer |
Figures from each repo's GitHub metadata at analysis time.
Relies on an undocumented Cloudflare Workers API and needs manual tuning of the concurrency setting outside Workers/Pages.
GrainTCP is a single JavaScript file that runs on Cloudflare Workers and acts as a relay for VLESS traffic sent over a WebSocket connection, allowing a client to reach the open internet through a Cloudflare Worker acting as a TCP proxy. The README describes it less as a project adding new protocol features and more as an exercise in squeezing extra performance out of the path data takes through the Worker. Rather than using Cloudflare's documented socket connection API, the code relies on an undocumented internal method it calls a grey area interface, which the author states still results in the same underlying TCP connection but through a smaller, less common code path. The README walks through several specific optimizations: moving the parsing of a client's identifying UUID out of the per request loop and into a one time setup step, which the author's own benchmarks show cutting matching time from around 53 nanoseconds to under 10, combining small outgoing data chunks into larger packets before sending them, guided by ideas borrowed from two existing streaming libraries, to reduce how often the underlying send function is called, and, for downloads, sending large chunks straight through immediately while only batching together chunks smaller than 32 kilobytes to cut down on the number of very small network frames. The README also documents a setting for how many TCP connections to attempt at once when first connecting, noting that the default of four assumes a normal Workers or Pages deployment and should be lowered to one if the code is instead run as a Cloudflare Snippet. A table lists every tunable value, including buffer sizes and thresholds, alongside their defaults. The project is released under the GPL 3.0 license, and the README links to a Telegram channel for discussion and to the two external libraries whose ideas informed the packet batching design.
A single file Cloudflare Worker that relays VLESS traffic over WebSocket, tuned with several low level tricks to reduce networking overhead.
Free to use and modify, but any distributed version, including one used to run a service, must also be released under the same license.
Setup difficulty is rated moderate, with roughly 1h+ to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.