Durable Functions: Answer to Serverless Needs
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Alternative Title |
| |
Title of Series | ||
Number of Parts | 130 | |
Author | ||
License | CC Attribution - NonCommercial - ShareAlike 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Identifiers | 10.5446/49945 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
00:00
Function (mathematics)Functional (mathematics)Limit (category theory)NeuroinformatikSelf-organizationPresentation of a groupMeeting/Interview
00:21
Function (mathematics)Server (computing)DreizehnCloud computingDifferent (Kate Ryan album)Software developerMaxima and minimaCartesian coordinate systemLimit (category theory)Axiom of choiceEvent horizonFunctional (mathematics)Data storage deviceCodeFront and back endsComputer architectureKeyboard shortcutElectronic data processingBitDatabaseInformationService (economics)Source codeInternet service providerBuffer overflowScaling (geometry)Multiplication signStack (abstract data type)State of matterRegular graphClient (computing)Task (computing)Server (computing)Complex (psychology)Data structureWorkloadProfil (magazine)Identity managementQuicksortArithmetic meanNetwork topologyFunktionenalgebraMobile appCopyright infringementMatching (graph theory)MassBasis <Mathematik>Process (computing)Staff (military)FreewareWritingDemosceneGraph (mathematics)Product (business)ArmFormal language
06:27
Server (computing)Function (mathematics)Function (mathematics)Limit (category theory)Presentation of a groupPattern languageSequenceQuicksortEntire functionFunctional (mathematics)Interactive televisionProcess (computing)Data storage deviceMultiplication signOrder (biology)Instance (computer science)NumberFrequencyDataflowCodeComplex (psychology)DatabaseServer (computing)Type theoryTask (computing)Queue (abstract data type)Computer fileScalabilityMultiplicationWebsiteCASE <Informatik>Surjective functionContent (media)ResultantMobile appSystem callChainLogicPoint (geometry)Source codeRegular graphError messageTwitterStapeldateiData managementState of matteroutputTraffic reportingAutomatic differentiationComputer configurationSuite (music)Bit rateService (economics)CircleBoss CorporationAutomationVotingHand fanStress (mechanics)Pulse (signal processing)Matching (graph theory)ArmSerial portKeyboard shortcutGroup action3 (number)Patch (Unix)
12:34
Server (computing)Function (mathematics)Functional (mathematics)Meeting/Interview
Transcript: English(auto-generated)
00:07
Hi, everyone. Welcome to our poster presentation today on durable functions. This is our answer to serverless needs. Today we'll be talking about what serverless computing is. We'll
00:21
be talking about the limitations on serverless's initial offerings and how durable functions give users more freedom to do what they require. We'll go over a few scenarios as well as where durable functions make something much easier to do or just plain possible.
00:41
So why serverless? Let's get one thing clear. Serverless doesn't mean that there aren't any servers. It just means that the user no longer has to worry about the nitty-gritties of setting up and managing VMs or provisioning services. It means that by extracting all of that infrastructure, you can focus primarily on your code and really dig deep
01:02
on a microservice architecture. With a serverless architecture, you focus purely on the individual functions in your application code. Also, while traditional servers or cloud applications might be bulkier in upfront costs, the benefit of using serverless is that you pay as you use your service. This is because you're only charged when your function is called. So in a traditional
01:26
serverless function, the cost would be calculated by the invocation of that function, as well as the time required to run the full function to completion.
01:42
And lastly, this also means that your serverless helps you scale. Because the cloud provider manages all of the services behind the scenes, they can scale you up or down depending on traffic coming into your function. Not only that, it's easy to deploy, you can write simplified backend code without worrying about dealing with other frameworks, and developers can add and
02:02
modify code on a piecemeal basis. So it's a little bit faster, it's a little easier to deal with. And so ultimately, why serverless? Because it lets the user deal purely with your code by bringing it up into the individual functions that can be invoked and scaled as such. So what's a serverless function? Well, serverless functions are cloud-based solutions for getting
02:25
serverless out there. Different providers of different names, for example, AWS's Lambda, Azure uses functions, but they all try to solve the problem of serverless architecture. The individual functions that can be broken out from your application then are stateless and
02:40
short-lived, which means that once they're triggered, that existing code is run and doesn't mean any state before or after the event. It's asynchronous, meaning that each function happens purely based off the triggers and unaware of what happens in other functions. They're flexible,
03:01
because you can use your own dependencies, you have a couple choices of languages, and you can use different deployment and development tools to get you to production. And again, because as stated before, they can be broken up into piecemeal functions that users can work out of with one another. And lastly, one of the things that Microsoft
03:27
offers in Azure is that they are event triggered with findings. So most of the other functions deal with things that are event triggered, such as going off of timers, HTTP requests,
03:43
such as being able to do things with storage. But Microsoft offers availability to use something called bindings, which allows you to bypass having to use the SDK so that you can trigger functions based off of when something is uploaded into a storage database or a GraphQL
04:05
database or Postgres database. And so a couple of different reasons why people would use functions is because they want to do some data processing, something that does extracting and transforming and loading that information elsewhere. For example, if you wanted to take
04:21
all of Stack Overflow's questions and try and filter it out into different tags, you could have a function that runs every morning at 8 a.m., a timer function, that takes in information from a data source. So this would be just a data collecting function. Then you can do some data processing on that once it's uploaded to the storage,
04:44
which is a storage binding based function, and then have it uploaded to another database. So this would just be another HTTP function or a database binding function. You could use it for automation and you could use it also for simple backend APIs. So downsides of servers,
05:07
downsides of serverless, what's happening? They seem great, but there are a few limitations on what these serverless functions can do. They have a max timeout of 10 minutes. This is normally set at five for Azure functions, but you can set it up to 10. And
05:24
this is a problem across all serverless functions, regardless of cloud providers. They have a max request size of five megabytes, so anything larger than that needs to be broken up. And they're stateless. So if you want to do more complex architecture around serverless, it would mean that you'd have to store that state somewhere else, then pull it out
05:43
from with another function. So with these few downsides, it could be really difficult or complex or even impossible to do some of the tasks that you want to do. So Microsoft has this thing called Durable Functions, which just released Python support
06:03
recently, and it doesn't have limits on time. Requests can be broken apart, and through stateful orchestrator functions, you can maintain a managed state. And what orchestrator functions do is it describes a workflow that orchestrates other functions. An activity function is called by the orchestrator function that performs work and optionally returns
06:25
a value. And the client function is a regular Azure function that starts an orchestrator function. This can be triggered like any other regular Azure function. So I just wanted to go into a couple of examples. The first one is called Function Chaining. And if you scroll in
06:41
or zoom into the code here, you can see that there is an orchestrator function, and this function runs like any other function, but it's a little bit magical. And this takes in function one, calls it, yields it up, and then once that's completed,
07:00
it calls this function two with the output from function one. Then lastly, function three is invoked after function two is completed with the output from function two, all to get the result in function four. And so function training in general is a pattern
07:20
where users execute a sequences of functions in a particular order. This outputs, the outputs of each of those functions could be necessary for the inputs of each subsequent one. And it's much simpler to do using durable functions, because if you were to use regular functions, because of the state management, as you recall, it would be much more difficult to have to deal
07:44
with storing it into a database or some sort of blob storage, pulling it back out, going back in, pulling it back out. And it can lead to a lot of sources of error. And because this is all done in one orchestrator function, it's more robust, there's better error handling,
08:03
it doesn't rely on triggers and bindings. And if there is a point of failure, you can have try and retry logic to help you get through it without having to restart every single thing from the beginning again. Secondly, we have this thing called fanout fanin. It's another
08:23
pattern of executing multiple functions concurrently and then performing some aggregation on that result. For example, if you wanted to back up all of an app's site content onto Azure storage using regular functions, you would have to have one that handles everything or multiple that call one another as increments of that site are uploaded. This has issues of scalability.
08:44
If you use one function to do all of that, the throughput is limited by the single VM that it's on. Also, if it fails midway or if the process is longer than the function limit, then the entire function would need to be restarted or it would just not be able to finish. And so this is
09:01
using durable functions is a much more robust approach and in our case requires writing two regular functions, one that enumerates the files and adds files names to a queue and another to read from that queue and upload to blob storage. So in this scenario, an orchestrator function is called where f1 gets the work batch, then run all of the parallel tasks in f2 to write everything
09:22
out. And lastly, f3 would finish up the entire process by returning what the user desired. Again, so this is a little bit, this is more scalable, more reliable, and you can have everything worked concurrently within the f2 functions. Lastly, we have human interaction
09:42
patterns. A lot of automated processes today involve some sort of human interaction. This could be that there are many, many number of serverless functions or other automated things that need to happen. But at a certain point, human interaction might be required.
10:00
This specific interaction we're dealing with as an example, is we're looking for manager approval for an expense report. If the manager doesn't approve in the 72 hours, the escalation process kicks in or they can just process the approval. Ordinary serverless functions are stateless, so these types of interactions involve using a database or storage to maintain state.
10:24
The interaction must be broken up into multiple functions, coordinated together using a timeout to get everything working. The complexity is reduced greatly when you have to or when you can use durable functions. The orchestrator function can manage the stateful interaction easily and without involving any external data stores. Because the orchestrator
10:43
functions are durable, these interactive flows are also highly reliable. And lastly, because they are running for long periods of time, people might think that they cost more. So for this instance, we're assuming that a human interaction is required within 72 hours. So in a regular
11:02
function, you might use a timeout or you might use some sort of time triggered one. In this case, we wouldn't charge you for the 72 hours that it's waiting. It would only charge you for the exact instance where the function is invoked and for the duration of that invocation
11:26
process. So actually, the price and costing of durable functions is basically the same as what you would see in a regular serverless function. So that kind of concludes my presentation
11:42
with durable functions. I'm not saying that durable functions will be the answer to all of your serverless needs, but they do answer a couple of questions where limitations are met, where you need something to do something for longer than 10 minutes. You need something that requires you
12:01
to take in batches that are bigger than five megabytes. And in that situation and scenario, durable functions might be the answer for you. Thanks for your time. If you have any questions, please ask me or Anthony on this chat or if you'd like to reach out to us on Twitter or GitHub. Microsoft also has a Discord server for Python and Azure offerings. We are very,
12:24
very communicative there and try to do more for our community there. That's it. Thanks for your time. Does anyone have any questions? Also, I think if no one has any questions,
12:44
there is also a breakout room. I don't know if I can link to that or not. But yeah, if you scroll down to posters, more durable Azure function
13:01
is one of the breakouts. And if you have any questions there, feel free to ask questions about it.