A developer builds a Node.js microservice that calls three other services to compose a response. All three calls are independent. The code currently uses sequential await calls. A performance review flags this.
What is the correct pattern to call three independent async APIs in parallel in Node.js, and what is the performance gain?
- A.Use a for loop with await (a sequential pattern): each call starts after the previous one finishes, giving a total time equal to the sum of all three calls, with no gain over a serial script
- B.Use Promise.race([a(), b(), c()]) to start all three calls at once: the first response ends the wait, giving a total time equal to the fastest call with the other two results discarded
- C.Use Promise.all([serviceA(), serviceB(), serviceC()]) to initiate all three requests concurrently; total wait time equals the longest single request rather than the sum of all three, reducing latency proportionally to the number of sequential calls