Company
Date Published
Author
Alberto GarcĂ­a Hierro
Word count
1894
Language
English
Hacker News points
4

Summary

We've optimized large GraphQL operations in Go by using the pprof tool to identify performance bottlenecks. Our customer was running a mutation against their GraphQL server directly, which took around 1 minute, but routing it through our gateway (built on top of graphql-go-tools) reduced its execution time to around 20 seconds, a 98.71% reduction. We narrowed down the problem by reproducing it and identifying a pathological case where data was being manipulated in an inefficient way. Our approach balances maintainability with writing fast code, using Go's excellent testing, debugging, and profiling tools. By optimizing JSON encoding and input value injection, we reduced execution times from 4.3 seconds to 10ms and 61% respectively. We also found that the operation is now faster when using the gateway than when using the GraphQL server directly due to our optimized parser and normalization engine.