Fault Tolerant n8n Automation for High Volume API Workflows

Hello I’m building an n8n automation that receives data from a webhook, processes it, calls multiple external APIs, and stores the results in a database. I want the workflow to remain reliable even when API calls fail, requests increase, or the same data is received multiple times.
Example Code:
const data = $json;
return {
userId: data.userId,
requestId: data.requestId,
timestamp: new Date().toISOString()
};
Please guys How would you architect this n8n workflow to handle high traffic, prevent duplicate executions, implement retries and error recovery, manage API rate limits, and maintain data consistency across multiple services?

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Roseline, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@Niffzy - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Roseline I would make the workflow idempotent, queue-based, and state driven rather than having the webhook directly handle every API call.

Start by making requestId unique at the database level:

CREATE UNIQUE INDEX request_id_idx
ON requests (request_id);

Then use an atomic insert:

INSERT INTO requests (request_id, user_id, status, created_at)
VALUES ($1, $2, ‘pending’, NOW())
ON CONFLICT (request_id) DO NOTHING
RETURNING id;

If nothing is returned, that request was already received, so you can safely stop the duplicate execution.

Keep the webhook lightweight and move the heavy processing to workers. That way, a sudden increase in requests doesn’t overwhelm n8n or your database.

For temporary API failures like 429 and 5xx, use exponential backoff:2s → 4s → 8s → 16s

Respect Retry-After when the API provides it, and set a maximum retry count before moving the job to a failed/dead-letter state.

For consistency, track the job state:pending → processing → completed
failed

Also make your database updates idempotent so retries don’t create duplicate records.

For multiple external APIs, I’d avoid trying to keep everything inside one huge transaction. A queue + state tracking + retry/outbox pattern is much safer.

@Niffzy If the workflow crashes after an external API succeeds but before PostgreSQL is updated, how would you guarantee consistency and prevent the API operation from being executed twice?

You can’t guarantee this with a normal n8n retry alone because the API and PostgreSQL are two separate systems.

The safest approach is idempotency + a durable operation state.

Before calling the API, store the operation with a unique key:

INSERT INTO api_jobs (request_id, status)
VALUES ($1, ‘pending’)
ON CONFLICT (request_id) DO NOTHING;

Send the same request_id as the API’s idempotency key. If n8n crashes after the API succeeds, the retry sends the same key, and the API should return the original result instead of performing the operation again.

Then update PostgreSQL:

UPDATE api_jobs
SET status = ‘completed’,
external_id = $2
WHERE request_id = $1;

If the API doesn’t support idempotency keys, I wouldn’t claim you can guarantee exactly-once execution. In that case, use an outbox/reconciliation pattern and make the operation itself safely repeatable.

Hi @Roseline
In queue mode, n8n 2.0 removed the Bull retry for stalled jobs, so a worker killed mid-execution never gets its job re-run and the row stays at processing forever. Have the Schedule Trigger claim expired leases alongside new rows, in one atomic query:

UPDATE requests
SET status = 'processing', claimed_at = NOW(), attempts = attempts + 1
WHERE id IN (
  SELECT id FROM requests
  WHERE status = 'pending'
     OR (status = 'processing' AND claimed_at < NOW() - INTERVAL '5 minutes')
  ORDER BY created_at
  LIMIT 50
  FOR UPDATE SKIP LOCKED
)
RETURNING *;

SKIP LOCKED lets several drain runs work the table at once without two of them picking up the same row. Set the interval comfortably above your slowest normal run, otherwise you reclaim jobs that are still working.