
Module 9 Lesson 1: Wait & Backoff Strategies
Patience pays off. Learn how to use the 'Wait' node for more than just pauses, including how to implement custom backoff strategies to handle intermittent API failures.
Module 9 Lesson 1: Wait & Backoff Strategies
In Module 5, we learned about basic retries. But sometimes a server is down for 10 minutes, not 10 seconds. A Backoff Strategy ensures you don't keep "Hammering" a dead server.
1. Simple Wait vs. Dynamic Wait
- Simple Wait: "Pause for 2 minutes."
- Dynamic (Exponential) Wait: "If it fails, wait 1 minute. If it fails again, wait 2 minutes. Then 4, 8, 16."
- This is the standard way huge companies (like Amazon or Google) handle server stress.
2. Implementing Backoff in n8n
You can use the Wait node with an Expression.
- Use a Counter (variable
attempt). - Formula:
{{ Math.pow(2, $json.attempt) * 60 }}(results in 60, 120, 240 seconds). - Connect the Wait node back to your failing Action node.
3. The "Wait Until" Feature
Instead of "Wait for X minutes," you can "Wait until a specific date/time."
- Scenario: "A user signs up on Thursday night. You want to send them an email on Monday morning at 9:00 AM."
- You use Luxon (Module 4) to calculate "Next Monday 9am" and feed that into the Wait node.
4. Why Use Wait for Reliability?
It prevents your workflow from being a "Rogue Script" that gets your IP blocked by an API provider. By being "Polite" and waiting during errors, you build a system that is trusted by other servers.
Exercise: The Patient Pioneer
- Create a loop that fails.
- Add a Wait node. Use an expression so that each iteration waits double the time of the previous one.
- Test a "Wait Until" node. Set it to wait until
1 minute from now. Observe the execution log. - Why is "Exponential Backoff" safer for a database than a constant "Retry every 1 second"?
- Research: What happens to a "Waiting" execution if you restart the n8n container? (Hint: Does it stay in memory or the database?)
Summary
Patience is a technical requirement. By Mastering the Wait node and implementing backoff strategies, you move from "Brittle" automation to "Enterprise-grade" systems that respect server load and recover gracefully from outages.
Next Lesson: Invisible data: Debugging Binary Data and Files.