Recently, after running tests for a few weeks I published the first stable version of QueueBatch. QueueBatch is an Azure Function trigger that enables you to process Azure Storage Queue messages in batches in a really performant way. One of the recent additions was ability to run a function even if there are no messages in the queue. How could this be useful? Wouldn’t it cost me money? Let me provide the answers below.
The first advantage that you might consider, for being notified on empty queue, is noticing an idle period of time. Having nothing to process means, that at least for now, when the call is made, there are no incoming messages. This time could be used for removing some old data, leasing blobs for some longer operations. The huge advantage over having an Azure Function timer trigger is following. When an empty queue is noticed, we know that the friction over leases or accessing different resources will be much smaller. In the next poll, there might be some messages, but at least for th is single spin there are none.
If you use this “empty queue” notification for doing some work, are you paying more money paid for running your app? I’d dare to say that it’s the same as you execute some kind of work that would need to be run anyway. You treat the empty queue just a special kind of a trigger.
One could argue that it’s not an idiomatic use of a function. Functions should serve a single purpose! Yes, it’s not idiomatic but useful, to progress with some work that requires less friction than usual operation. I’m leaving it up to the user what means an idiomatic function usage for an approach (FaSS) that is a few years old.
Knowing that there’s nothing to do can be useful. Spending this time on this other thing might help your application to progress with much smaller friction, in a much faster pace.
Oh, I can see, a new message batch arrived! Processing time!