In Memory of Travails
summary
Node.js GraphQL subscriptions hit V8 OOM with thousands of connections; a local test with 4000 websockets delivered 16k Kafka messages in ~4.5 minutes as the baseline. Improvements include lazy-loading context objects via Proxy, memoizing repeated snake_case conversions, replacing lodash/Maps with in-place loops, compiling server code for Node 20, adding a subscription query cache and graphql-jit, and autoscaling plus nightly restarts. Instrumentation uses Heap snapshot diffs and Node Clinic; end result shows up to 6.3x speedup and much lower memory plateaus.
AI-written summary · about
chapters (20)
- 0:00Introduction to GraphQL server
- 1:04Problem with memory limits
- 3:32Lazy loading backend contexts
- 4:36Modernizing key conversion code
- 5:42GraphQL subscription mechanics
- 6:26Upgrading GraphQL engine
- 6:48Caching snake case conversions
- 7:51Horizontal Pod Autoscaling setup
- 9:14Optimizing Node.js compilation
- 10:18In-place array mutations
- 11:43Heap profiling techniques
- 13:08Removing location nodes
- 13:52Lazy data loaders
- 16:00Query cache implementation
- 17:24GraphQL JIT for large queries
- 18:28Memory usage improvements
- 18:49In-memory PubSub exploration
- 21:13Realistic load testing
- 21:34Key insights from optimization
- 22:59Q&A and closing remarks
related talks
39mGraphQL Accelerated
33mReaching Ludicrous Speed
40mThe Road to 2 Million Websocket Connections in Phoenix
38mWelcome to Mordor! Hunting Performance Issues in Node.js.
23mHow to edge cache GraphQL APIs
46m10 secrets to improve Javascript Performance
31mNode.js that's hugely reliable, fast, and scalable
53mMastering Node.js Performance
