Parallel API Calls
Learn how to achieve parallelism in API calls.
We'll cover the following
Parallelism
When serving an incoming request, we will run into scenarios where we must fetch data from multiple dependencies. When resolving various dependencies via API calls that are not dependent on each other, we should try to resolve these dependencies in parallel instead of sequentially. This will save us a lot of time and reduce our API latency. Because each API call is a blocking I/O operation, making multiple calls in sequence will mean that the sum of response times of all these APIs will be equal to our latency. On the other hand, if we use goroutines to parallelize our API calls, our API latency would only rely on the dependency with maximum response time.
Get hands-on with 1200+ tech skills courses.