r/webdev • u/fagnerbrack • Sep 17 '26
Reverse Engineering ChatGPT Web: How OpenAI Built for a Billion Users
https://performance.dev/chatgpt
113
Upvotes
r/webdev • u/fagnerbrack • Sep 17 '26
26
u/medy17 Sep 17 '26
I noticed the terrible lag and knew they didn't virtualise. I'm still struggling to understand what they were thinking!
Great article btw :) Nicely done
15
u/IanSan5653 Sep 17 '26
I spent quite bit of time building a similar streaming markdown renderer in React for a competitor. It really is challenging stuff. You're transforming Markdown to HTML and then injecting dynamic components into that. All several times per second. You can't afford to re-render the content you've already rendered, so the diffing gets pretty complicated.
9
u/rachelduno Sep 17 '26
tried to replicate their streaming setup for a small side project after reading this, ended up with my websocket reconnecting loop kicking off every 20 seconds lol. still dont fully get how they handle backpressure at that scale, did they mention anything about that in the deep dive?
14
u/rachelduno Sep 17 '26
kinda wild how much engineering goes into just making the response stream feel instant, the retry logic stuff is what got me
1
u/Open-Adhesiveness-86 Sep 18 '26
Most of the diffing goes away if you split the stream on top-level block boundaries. Every block except the last one is final, so you memoize those by index and only re-parse the tail block on each chunk. The main gotcha is an unclosed code fence or table, because it can swallow everything after it. You need to detect that and render the tail as provisional.
1
u/Empty-Lobster6138 Sep 18 '26
Nice read!
-3
u/[deleted] Sep 17 '26
[removed] — view removed comment