Browse Chapters

Statelessness

Statelessness is a feature of modern microservices and serverless functions. As a design paradigm, it has gained traction in the last decade.

A program that runs for a long time and handles many requests may store information in memory for a long time. This same information may be used from one request to another. We often refer to this pattern as statefullness. That is, the program maintains state information in memory.

Serverless apps do not stay running between requests. Therefore, they cannot store state information in memory and use it from one request to the next. Any state information must be stored somewhere else. Therefore, serverless apps are stateless.

Statelessness is considered a good practice in general, and applications that adhere to the microservice design pattern (such as applications that run in Kubernetes) are also stateless. Therefore, this is not a technique unique to serverless apps.

To learn more about stateless apps that behave like stateful apps, read The Next Generation of Serverless is Happening.

How do serverless apps preserve state information? Most store information somewhere outside of the app. Spin provides built-in key/value storage (sometimes called NoSQL) to quickly store and retrieve data between requests. Other serverless app platforms like Google Functions or AWS Lambda require you (the developer) to find your own place to store state information. Of course, each of these platforms provides database, object storage, and disk-based storage services that you can attach to your serverless app for a fee.

Browse Chapters

Quickstart Your Serveless Apps with Spin

Get Started