Nameko service event_handler as a PULL job worker


#1

From @rizplate on Tue Mar 13 2018 04:22:53 GMT+0000 (UTC)

1- Can the event.handler/pub-sub be used as a job worker?
i.e. instead of nameko pushing the event to the service.handler, can the service pull the message so as to implement a pull based events?

2- If one event.handler event-let is taking 1 hr to complete? is every other event waiting to be delivered? i.e. none of other event.handler will run or does event-let primitively pause the green-thread and give resources to other green-threads? I think resource hogger event.handler will block the whole system. any way around it?

3- Can you explain the message data flow of inbound and outbound calls of rpc i.e. which objects of nameko are doing what when the message is received.

Copied from original issue: https://github.com/nameko/nameko/issues/522


#2

From @mattbennett on Tue Mar 20 2018 12:15:22 GMT+0000 (UTC)

> 1- Can the event.handler/pub-sub be used as a job worker?

Not sure what you mean by “job worker” here. Actually services do pull messages from the broker, even event handlers, but perhaps what’s not obvious is that they pull up to a certain amount at a time (the “prefetch count”). By default in Nameko this value is inherited from the max_workers config value, which is 10.

You can make your services look more like workers that “pull” work when the existing work is done by reducing the value of max_workers.

Have I understood the question correctly?

2- If one event.handler event-let is taking 1 hr to complete? is every other event waiting to be delivered? i.e. none of other event.handler will run or does event-let primitively pause the green-thread and give resources to other green-threads? I think resource hogger event.handler will block the whole system. any way around it?

Eventlet will yield any thread that blocks for I/O, so unless your " resource hogger" thread is unyielding then other threads will still run. If you have a workload that is unyielding, you should delegate it to a tpool to avoid blocking the event loop.

3- Can you explain the message data flow of inbound and outbound calls of rpc i.e. which objects of nameko are doing what when the message is received.

See this thread on the mailing list