How HTTP request is processed by webhook and worker in queue mode?

Suppose we have:

  • n8n configuration in queue mode with main n8n instance, load balancer, webhook instances and worker instances.
  • a workflow with webhook node and some computation intensive nodes. Webhook respond “When last node finishes”.

Now this system receives HTTP request. Load balancer passes it into webhook instance. I want to understand in detail what will happen next. I will write my assumptions and ask you to correct me and give your comments.

  • Webhook starts processing HTTP request. And puts request data into redis queue for worker node.
  • Webhook is not finishing its process and HTTP request also keeping in in-progress state. Webhook will wait in this state until worker returns a result.
  • Free worker picks up the tasks from redis. And executes workflow.
  • Webhook gets notified that job is done, gets result (from worker?) and only at this point responds to HTTP request with result. This is important part of my question. Is this correct? So everything is processed within a single HTTP request even in queue mode, right?

This might be one for @krynble to answer with certainty, but it sounds to me like your assumptions are correct.

I’ve tested this this in a dummy setup (one main instance, one worker) and this workflow like below:

My main instance has received the webhook, the execution took place on the worker as expected, and only then was the response sent back to my client. The default logs would look like so:

27089-n8n-queue-mode-n8n-1         | Started with job ID: 1 (Execution ID: 4)
27089-n8n-queue-mode-n8n-worker-1  | Start job: 1 (Workflow ID: 2 | Execution: 4)

Let’s wait for Omar to confirm though to be safe here :slight_smile:

1 Like

Oh sorry for the long time it took me to see this one, I totally lost this notification, but you are 100% correct @perseus-algol , including the fact that even in queue mode, the http request will be hanging waiting for the worker to finish.

Just to clarify your question mark, the execution data is retrieved from the db, so basically the worker writes the execution result to DB, notifies Redis which in turns gets back to the webhook process, which reads from DB and responds the http request.

1 Like

Thank you for clarification!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.