Hands-On Serverless Computing
上QQ阅读APP看书,第一时间看更新

State

Functions, as they run in ephemeral containers, have significant restrictions when it comes to management of state. You need to design your functions in such a way that the subsequent run of your function will not be able to access state from a previous run. In short, you should develop your functions with the point of view that they are stateless.

This affects how you design the architecture for your application. Considering that functions are stateless, you need to use external resources to manage the state of your application so that the state can be shared between runs of the functions. Some of the popular external resources that are widely using the FaaS architecture are Amazon S3, which provides a simple web services interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web, caching solutions, such as Memcached or Redis, and database solutions, such as Amazon DynamoDB, which is a fast and flexible NoSQL database service for any scale.