George Francis Jr
1 min readJan 13, 2021

--

Thank you Silvino. When developing HTTP request handlers, I tend to think of goroutines as a performance optimization. I recommend starting with the simplest solution first (make it work) and then iterate on it. Here are a few questions I use to help guide my approach:

* What is the expected average response time for the request? Does the synchronous approach meet that response time?

* How does it perform in load testing?

* Does the handler execute 2 or more independent subtasks (network, web service, db call, etc). If "Subtask A" takes 1 second to complete and "Subtask B" takes 1 second, a synchronous approach would mean at least a 2 second response time. By running these tasks concurrently (asynchronously) we could reduce the response time down to 1 second

* Are there any expensive "fire & forget" tasks that can be executed in the background?

I hope this helps

--

--

George Francis Jr
George Francis Jr

No responses yet