Durable Functions - basic concepts and justification

Recently team responsible for Azure Functions announced, that new cool feature is entering an alpha

Recently team responsible for Azure Functions announced, that new cool feature is entering an alpha preview stage - Durable Functions. Because this introduces a completely new way of thinking about serverless in Azure, I decided to go in-depth and prepare a few blog posts regarding both new capabilities and the foundations of Durable Functions.


Conceptually Durable Functions are something, what forces you to rethink what you've already learnt about serverless in Azure. When writing common functions like inserting something into a database or passing a message to a queue, you've always been trying to avoid storing state and perform all actions as quickly as possible. This had many advantages:

  • it was easy to write a simple function, which performs basic operations without preparing boilerplate code
  • dividing your module into small services really helped during maintaining your solution
  • scaling was quite simple and unequivocal

All right - it seems that we had all we needed, why one tries to introduce a completely different concept, which raises learning curve of Functions? 


Normally if you want to communicate between functions, you will have to use queues. It's a perfectly valid solution and in simple scenarios the whole solution won't be cumbersome. However if you're creating a bigger system with several functions orchestrating work between each other, sooner than later you'll hit a wall - communication using queues will become a bottleneck of your solution and maintenance will become a nightmare. 

Additionally - more advanced scenarios(like fan-in/fan-out) are ridiculously hard to achieve.

What about stateless?

For some people concept of introducing a state into functions destroys what is best about them - possibility to scale out seamlessly and treating them as independent fragments of your system. In fact, you have to distinguish "traditional" functions and durable ones - they have different use cases and reasoning between differs a lot. The former should be used as a reaction to an event, they're ideal when you have to take an action in answer to a message. The latter are more sublime during adoption - you'll use them for orchestrating workflows and pipelines, which let you easily perform an end-to-end processing of a message.


One more thing considering Durable Functions is pricing, mostly because it is what makes serverless so interesting. In Durable Functions it doesn't change - you'll still pay only for the time, when a function executes - when a function awaits for a result of running other functions, no cost is allocated here. This is thanks to the fact, that once a task is scheduled, execution of a function returns to the Durable Task Framework layer and waits for further actions there.

I strongly recommend you to take a look try something with Durable Functions. This feature is still in an early preview so it might be unstable in some way, but it gives so many possibilities now, that it's really worth a try. You can find more info here: Alpha Preview for Durable Functions.

Add comment