Company
Date Published
Author
Jens Neuse
Word count
2913
Language
English
Hacker News points
1

Summary

This summary highlights the key points of the text, which discusses implementing GraphQL Subscriptions in Go using Epoll and an event-driven architecture. The author initially implemented a naive approach that was sufficient for the first iteration but had limitations, including creating 4 goroutines per client and Subscription, allocating excessive memory, blocking in the ServeHTTP method, and blocking to read from the connection. To address these issues, the author introduced an event-driven architecture using Epoll/Kqueue, which reduced the number of goroutines by 99% and memory consumption by 90%. The optimized implementation uses a thread pool to handle events, limits concurrent updates, and reuses tools efficiently. The changes were validated using pprof, and the author concludes that the new implementation is fast, efficient, and maintainable.