Patterns to build stateful applications with serverless: solving the data problem
Serverless computing has gained a lot of popularity in the last few months and years, especially amongst developers. With serverless, developers are promised an experience of being able to finally Just Write Code™️.
Serverless providers make this possible by forcing developers to remove any stateful code from their business logic. By design, code deployed as a serverless function cannot access the disk, or share in-memory data with other invocations of the serverless functions. While this makes it easy for infrastructure solutions to provide on-demand scaling it makes it hard for developers to build applications because traditional ways of handling state don't work.
In this talk, I will highlight the problems and solutions associated with 3 different stateful use-cases:
1. Accessing data: Serverless functions can't connect directly to database because the functions are ephemeral and there is no notion of a connection pool.
2. Persisting data: Serverless functions can't persist data directly to disk, because there is no persistent filesystem attached to a serverless function
3. Sharing data: Serverless functions can't share in-memory data across invocations. Often complex applications cache or memoise data, or share state across different invocations. This is no longer possible, because a serverless function is ephemeral and the lifetime of the underlying memory associated with the function is not available in the next invocation of this serverless function!
The rough outline of my talk is as follows:
1. Introduction to serverless with a live demo and some coding
2. Understanding the benefits of serverless
3. Understanding the underlying stateless model for serverless
4. Problems and solutions for accessing data
5. Problems and solutions for persisting data
6. Problems and solutions for sharing data across serverless functions