28. Why is a function that synchronously invokes another function and waits for it considered an anti-pattern?
- Functions are technically unable to call other functions
- You pay for both while the first one waits, and timeouts and failures become coupled
- It always causes a recursive loop
- It disables logging for the second function
Show answer
Answer: You pay for both while the first one waits, and timeouts and failures become coupled
The caller is billed while idle, the chain's timeouts must nest, and one failure cascades. Queues or a workflow engine decouple the steps.
Lesson: Composition Patterns: Choreography, Orchestration and Fan-Out
29. An API gateway times out at 29 s, the function at 60 s, and its database call has no timeout. What is the main problem?
- The database call is too fast for the function
- Nothing; longer inner timeouts are always safer
- The client may get a gateway timeout while the function keeps running and billing with no one waiting
- The function will be retried automatically by the gateway
Show answer
Answer: The client may get a gateway timeout while the function keeps running and billing with no one waiting
Inner timeouts should be shorter than outer ones. Otherwise work continues after the caller has given up, wasting money and hiding the real error.
Lesson: Common Pitfalls and How to Avoid Them