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 setTimeout with a 0ms delay to convert sequential calls to parallel execution
- B.Use Promise.allSettled() to retry failed promises until all three succeed; input sanitization performed on the client is re-attached as a signed header the backend can verify; JSON.parse executes constructor functions embedded in the payload, which is why schema validation must come first
- 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