* [Topics](/en/topics "Topics")
* [Application development and delivery](/en/topics/application-modernization "Application development and delivery")
* Stateful vs. stateless applications
Stateful vs. stateless applications
===================================
Updated  January 22, 2025•*6*-minute read
Copy URL
Jump to section
---------------
OverviewStateful applicationsStateless applicationsStateful vs. statelessIs AI stateful or stateless?Containers and stateWhy choose Red Hat
Overview
--------
The state of an application (or anything else) is its condition or quality of being at a specific moment in time—its state of being. Whether something is stateful or stateless depends on how long the state of interaction with it is being recorded and how that information needs to be stored. A stateful application retains state or context about its interactions with users, systems, or components. The state is persisted on a durable storage solution, so that the application survives a restart. The main difference between stateful and stateless applications is that stateful applications save past and present information while stateless applications don’t.
[Transform your applications with Red Hat OpenShift](/en/resources/openshift-application-transformation-ebook)
What are stateful applications?
-------------------------------
Stateful applications and processes maintain their state by storing, recording, and returning to already established information and processes over the internet. In stateful applications, the server keeps track of the state of each session or interaction and maintains that information based on the user's past requests. Those sessions can be returned to again and again, like online banking or email. They’re performed with the context of previous transactions, and the current transaction may be affected by what happened during previous transactions. For these reasons, stateful apps use the same servers each time they process a request from a user.
If a stateful transaction is interrupted, the context and history are stored so you can pick up where you left off. Stateful apps track things like window location, setting preferences, and recent activity. You can think of stateful transactions as an ongoing periodic conversation with the same person.
#### Use cases for stateful applications
* **User-centric applications:** User-centric applications like social media apps and  e-commerce sites keep track of a logged-in user’s session, including their preferences or the items in their shopping cart.
* **IoT systems:** An [Internet of Things (IoT)](/en/topics/internet-of-things/what-is-iot) system works by continuously sending, receiving, and analyzing data in a feedback loop. Based on historical or real-time data, a device will respond to a changing state over time, like your home thermostat.
* **AI/ML model training:** [Artificial intelligence and machine learning (AI/ML)](/en/topics/ai) training models learn from data and remember that data. The maintained state of learning and remembering helps models function at their fullest capacity.
Accelerate your path to cloud-native applications
-------------------------------------------------
[Get the resource](/en/engage/path-to-cloud-native-applications-ebook "Get the resource")
What are stateless applications?
--------------------------------
A stateless application or process does not retain information about the user's previous interactions. There is no stored knowledge of or reference to past transactions. Each transaction is made as if from scratch for the first time. Stateless applications provide one service or function and use a content delivery network (CDN), web, or print servers to process these short-term requests.
An example of a stateless transaction would be doing a search online to answer a question you’ve thought of. You type your question into a search engine and hit enter. If your transaction is interrupted or closed accidentally, you just start a new one. Think of stateless transactions as a vending machine: a single request and a response.
#### Use cases for stateless applications
* **REST APIs:** [REST application programming interface (APIs)](/en/topics/api/what-is-a-rest-api) transfer a representation of the state of a resource to the requester or endpoint. Each API request is separate and the server does not store information about the previous request.
* **Microservices:** [Microservices](/en/topics/microservices/what-are-microservices) allow each core function within an application to exist independently. Because of that, microservices are well suited to both stateless and stateful applications.
* **Serverless architectures:** [Serverless](/en/topics/cloud-native-apps/what-is-serverless) architectures are designed to respond to events in isolation and do not retain context from previous actions and therefore do not need to maintain state. Serverless architectures are ideal for asynchronous, stateless apps that can be started instantaneously.
* **Large language models (LLMs):** At a technical level, LLMs operate in a stateless manner during inference. The model weights are fixed, and they don't change between each request.
[Learn how APIs help facilitate apps](https://www.redhat.com/en/engage/apiowner-manual-ebook-s-202002130435)
Stateful vs. stateless: a comparison
------------------------------------
The key difference between stateful and stateless is whether an application retains information about the current state of a user's interactions or if it treats each request as an independent, isolated transaction. However, there are also specific differences, including:
##### State retention
Stateful applications store information about the interaction, often in a database or in distributed memory. Stateless applications don’t store information about an interaction, so a transaction will need to start over.
##### Session dependence
With stateful applications, each request depends on data or context from previous interactions and transactions. Stateless applications have more independent sessions since each request is treated as new, but that means that the application must have all the information necessary to process the request.
##### Storage dependence
Stateful applications require persistent storage (like databases and distributed file systems). Stateful apps must rely on an underlying storage solution, and they need a scheme for synchronizing data between instances.
##### Resource utilization
Stateless applications often have lower resource utilization because there is no need to store and manage session data. Because stateful applications are more storage dependent, they may require more memory and processing power to handle and maintain session information.
##### Scalability
Stateless applications are generally more scalable, as each request is independent and can be handled by any available server using load balancing. Stateful applications have tightly coupled instances making it more difficult to scale. They may require more specific instances or pods in [Kubernetes](/en/topics/containers/what-is-kubernetes) to manage state, load balance, and manage sessions.
##### Fault tolerance
Stateless applications can be more fault-tolerant, as the loss of a server doesn't impact user sessions. In stateful applications, the loss of a server can result in the loss of session data unless additional measures, such as session replication or clustering, are in place.
##### Development complexity
Stateless applications can be simpler to develop and maintain, as there is no need to manage state across multiple requests. Stateful applications, on the other hand, require careful handling of session data and state management.
Is AI stateful or stateless?
----------------------------
While most AI systems are stateless, many AI applications are designed to emulate stateful behavior. Let’s break this down a bit more.
During the training phase, an AI model is stateful–the model is constantly changing and “learning” as parameters (or weights) are being adjusted.
Once training is complete, the state of the model freezes–becoming stateless. The model’s parameters are locked in and the learning process stops. There is no longer any internal change happening within the model. Even during [inference,](/en/topics/ai/what-is-ai-inference) the model remains stateless.
So, if the model is stateless, how is it possible to have a continuous conversation with an LLM? This is where the emulation of stateful behavior happens–also known as a context window. A context window functions as a model's “working memory.” It allows the model to understand and respond to prompts without losing track of earlier parts of the conversation.
Containers and state
--------------------
The majority of applications we use day to day are stateful, but as technology advances, [microservices](/en/topics/microservices/what-are-microservices) and [containers](/en/topics/containers) make it easier to build and deploy applications in the cloud.
As [cloud computing](/en/topics/cloud-computing) and microservices grow in popularity, so too has containerization of applications, whether stateful or stateless. Containers are units of code for an application that are packaged up, together with their libraries and dependencies. With containerized applications, they’re able to be easily moved and can run in any environment, whether on a desktop, traditional IT infrastructure, or on a cloud.
Originally, containers were built to be stateless, as this suited their portable, flexible nature. But as containers have come into more widespread use, people began containerizing (redesigning and repackaging for the purposes of running from containers) existing stateful apps. This gave them the flexibility and speed of using containers, but with the storage and context of statefulness.
Because of this, stateful applications can look a lot like stateless ones and vice versa. For example, you might have an app that is stateless, requiring no long-term [storage](/en/topics/data-storage), but that allows the server to track requests originating from the same client by using cookies.
With the growth in popularity of containers, companies began to provide ways to manage both stateless and stateful containers using data storage, [Kubernetes](/en/topics/containers/what-is-kubernetes), and [StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/). Statefulness is now a major part of container storage and the question has become not if to use stateful containers, but when.
Why choose Red Hat?
-------------------
When it comes to stateful or stateless applications, Red Hat has you covered. Whether you’re orchestrating stateful containers on our hybrid cloud application platform, [Red Hat® OpenShift®](/en/technologies/cloud-computing/openshift), or creating a unified environment for app dev with [Red Hat Application Foundations](/en/products/application-foundations), you’ll be backed by our [award-winning support](/en/services/support) and ecosystem of [partners](/en/partners).
Red Hat OpenShift provides a unified, security-focused, hybrid cloud application platform that allows organizations to accelerate innovation by helping modernize their application development and deployment and operational processes. Red Hat OpenShift provides features to support stateful applications like Kubernetes StatefulSets. With [Red Hat OpenShift Data Foundation](/en/technologies/cloud-computing/openshift-data-foundation), you can manage stateful data with a storage solution that provides software-defined storage and helps provision persistent volumes. Red Hat OpenShift also integrates stateful applications into DevOps workflows.  [Red Hat OpenShift Pipelines](/en/technologies/cloud-computing/openshift/pipelines) is designed to run each step of the [CI/CD pipeline](/en/topics/devops/what-is-ci-cd), which supports testing and deployment of stateful workloads alongside stateless ones.
Red Hat Application Foundations provides service composition and orchestration, application connectivity and data transformation, real-time message  [streaming](/en/topics/integration/what-is-streaming-data), [change data capture](/en/topics/integration/what-is-change-data-capture), and [API management](/en/topics/api/what-is-api-management)—all combined with a cloud-native platform and toolchain to support the full spectrum of modern application development.
Used together, Red Hat OpenShift and Red Hat Application Foundations provide an ideal platform to develop and deliver cloud native applications. Whatever your needs, our products help you build solutions, improve [developer productivity](/en/products/developer-productivity), and promote innovation—[the open source way](/en/about/open-source).
[Learn how Red Hat OpenShift supports applications](https://www.redhat.com/en/technologies/cloud-computing/openshift#use-cases)
Use case
Cloud-native application development with Red Hat OpenShift
-----------------------------------------------------------
Red Hat OpenShift provides a trusted platform for cloud-native application development, so you can deliver new features that serve customer needs.
[Learn more about this use case](/en/technologies/cloud-computing/openshift/cloud-native "Cloud-native application development with Red Hat OpenShift")
Innovate and transform with a modern application platform
---------------------------------------------------------
Discover current trends in application transformation and ways that you can modernize using hybrid cloud application platforms and cloud services.
[Get the resource](/en/engage/openshift-application-transformation-ebook "Innovate and transform with a modern application platform")
Keep reading
------------
### What is serverless?
Serverless is a cloud-native development model that allows developers to build and run applications without having to manage servers.
[Read the article](/en/topics/cloud-native-apps/what-is-serverless "article | what is serverless?")
### What is application migration?
Application migration is a process that can improve workloads by moving an application from one environment to another.
[Read the article](/en/topics/cloud-native-apps/application-migration "article | what is application migration")
### What is an application development platform?
An application development platform is a set of integrated technologies that enable teams to build software applications efficiently.
[Read the article](/en/topics/cloud-native-apps/what-app-dev-platform "article | what is an application development platform?")
Application development and delivery resources
----------------------------------------------
### Featured products
* #### [Red Hat OpenShift](/en/technologies/cloud-computing/openshift)
  A unified application development platform that lets you build, modernize, and deploy applications at scale on your choice of hybrid cloud infrastructure.
* #### [Red Hat Application Foundations](/en/products/application-foundations)
  A set of components engineered to help build, deploy, and operate applications. Includes Red Hat 3scale API Management, Red Hat Data Grid, Red Hat JBoss Web Server, Red Hat AMQ, Red Hat builds of open source technologies, and a migration toolkit for applications.
[See all products](/en/technologies/all-products "See all products")
### Related content
* Blog post
  [Meet the latest Red Hat OpenShift Superheroes](/en/blog/meet-latest-red-hat-openshift-superheroes-0)
* Blog post
  [Precision over perception: Why architecture matters in benchmarking](/en/blog/precision-over-perception-why-architecture-matters-benchmarking)
* Overview
  [Oil and gas giant achieves millions in savings with Red Hat](/en/resources/oil-and-gas-anon-overview)
* Blog post
  [JBoss EAP XP 6.0: Achieving observability with OpenTelemetry](/en/blog/jboss-eap-xp-60-achieving-observability-opentelemetry)
### Related articles
* [What is an image builder?](/en/topics/linux/what-is-an-image-builder)
* [Red Hat OpenShift for developers](/en/technologies/cloud-computing/openshift/developers)
* [What is a Linux container?](/en/topics/containers/whats-a-linux-container)
* [What is blue green deployment?](/en/topics/devops/what-is-blue-green-deployment)
* [Why choose Red Hat for Kubernetes?](/en/topics/containers/why-choose-red-hat-kubernetes)
* [What is CaaS?](/en/topics/cloud-computing/what-is-caas)
* [What is Podman Desktop?](/en/topics/containers/what-is-podman-desktop)
* [What is Podman?](/en/topics/containers/what-is-podman)
* [Containers vs. VMs: Similarities, differences, and combined approaches](/en/topics/containers/containers-vs-vms)
* [Edge computing with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/edge-computing)
* [What is CI/CD?](/en/topics/devops/what-is-ci-cd)
* [What is application lifecycle management (ALM)?](/en/topics/devops/what-is-application-lifecycle-management-alm)
* [What is container orchestration?](/en/topics/containers/what-is-container-orchestration)
* [What is Istio?](/en/topics/microservices/what-is-istio)
* [What is serverless?](/en/topics/cloud-native-apps/what-is-serverless)
* [What is a CI/CD pipeline?](/en/topics/devops/what-cicd-pipeline)
* [What is Kubernetes?](/en/topics/containers/what-is-kubernetes)
* [Red Hat OpenShift on VMware](/en/technologies/cloud-computing/openshift/vmware)
* [What is application migration?](/en/topics/cloud-native-apps/application-migration)
* [What is KubeVirt?](/en/topics/virtualization/what-is-kubevirt)
* [Why use Red Hat Ansible Automation Platform with Red Hat OpenShift?](/en/technologies/cloud-computing/openshift/ansible-on-openshift)
* [What is application integration?](/en/topics/cloud-native-apps/application-integration)
* [What is the Kubernetes Java client?](/en/topics/cloud-computing/what-is-kubernetes-java-client)
* [What are hosted control planes?](/en/topics/containers/what-are-hosted-control-planes)
* [What is kubernetes security?](/en/topics/containers/kubernetes-security)
* [Shift left vs. shift right](/en/topics/devops/shift-left-vs-shift-right)
* [How Kubernetes can help AI/ML](/en/topics/cloud-computing/how-kubernetes-can-help-ai)
* [What is Kubeflow?](/en/topics/cloud-computing/what-is-kubeflow)
* [What are microservices?](/en/topics/microservices/what-are-microservices)
* [What is container security?](/en/topics/security/container-security)
* [OpenShift vs. OpenStack: What are the differences?](/en/technologies/cloud-computing/openshift/openshift-vs-openstack)
* [What are sandboxed containers](/en/topics/containers/sandboxed-containers)
* [What is Buildah?](/en/topics/containers/what-is-buildah)
* [Why choose Red Hat for a DevOps Platform?](/en/topics/devops/why-choose-red-hat-for-devops)
* [Kubernetes vs OpenStack](/en/topics/openstack/kubernetes-vs-openstack)
* [What is DevSecOps?](/en/topics/devops/what-is-devsecops)
* [What are validated patterns?](/en/topics/cloud-computing/what-are-validated-patterns)
* [Kubernetes on AWS: Self-Managed vs. Managed Applications Platforms](/en/topics/containers/kubernetes-on-aws)
* [What is an application development platform?](/en/topics/cloud-native-apps/what-app-dev-platform)
* [Red Hat OpenShift vs. OKD](/en/topics/containers/red-hat-openshift-okd)
* [Red Hat OpenShift vs. Kubernetes: What's the difference?](/en/technologies/cloud-computing/openshift/red-hat-openshift-kubernetes)
* [Spring on Kubernetes with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/spring)
* [Why run Apache Kafka on Kubernetes?](/en/topics/integration/why-run-apache-kafka-on-kubernetes)
* [What is high availability and disaster recovery for containers?](/en/topics/containers/high-availability-containers)
* [Security in the software development lifecycle](/en/topics/security/software-development-lifecycle-security)
* [What is a golden image?](/en/topics/linux/what-is-a-golden-image)
* [What are Red Hat OpenShift cloud services?](/en/technologies/cloud-computing/openshift/what-are-red-hat-openshift-cloud-services)
* [VNF and CNF, what’s the difference?](/en/topics/cloud-native-apps/vnf-and-cnf-whats-the-difference)
* [What is a container registry?](/en/topics/cloud-native-apps/what-is-a-container-registry)
* [What are cloud applications?](/en/topics/cloud-native-apps/what-are-cloud-applications)
* [What is agile methodology?](/en/topics/devops/what-is-agile-methodology)
* [What is Skopeo?](/en/topics/containers/what-is-skopeo)
* [What are Red Hat OpenShift Operators?](/en/technologies/cloud-computing/openshift/what-are-openshift-operators)
* [Using Helm with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/helm)
* [Kubernetes security best practices](/en/topics/containers/kubernetes-security-best-practices)
* [Orchestrating Windows containers on Red Hat OpenShift](/en/technologies/cloud-computing/openshift/windows-containers-on-red-hat-openshift)
* [What is a Kubernetes operator?](/en/topics/containers/what-is-a-kubernetes-operator)
* [High performance computing with Red Hat OpenShift](/en/technologies/cloud-computing/openshift/high-performance-computing)
* [Advantages of Kubernetes-native security](/en/topics/containers/advantages-of-kubernetes-native-security)
* [What is KubeLinter?](/en/topics/containers/what-is-kubelinter)
* [Intro to Kubernetes security](/en/topics/containers/intro-kubernetes-security)
* [Container and Kubernetes compliance considerations](/en/topics/containers/compliance)
* [How microservices support IT integration in healthcare](/en/topics/microservices/microservices-in-healthcare)
* [Kubernetes cluster management](/en/technologies/cloud-computing/openshift/kubernetes-cluster-management)
* [Red Hat OpenShift on IBM IT infrastructure](/en/technologies/cloud-computing/openshift/what-is-red-hat-openshift-on-IBM-IT-infrastructure)
* [Red Hat OpenShift for business leaders](/en/technologies/cloud-computing/openshift/business-leaders)
* [How to deploy Red Hat OpenShift](/en/technologies/cloud-computing/openshift/deploy-red-hat-openshift)
* [Cost management for Kubernetes on Red Hat OpenShift](/en/technologies/cloud-computing/openshift/cost-management)
* [Kubernetes-native Java development with Quarkus](/en/technologies/cloud-computing/openshift/quarkus)
* [What is enterprise Kubernetes?](/en/topics/containers/what-is-enterprise-kubernetes)
* [What makes Red Hat OpenShift the right choice for IT operations?](/en/technologies/cloud-computing/openshift/it-operations)
* [What makes Red Hat OpenShift the right choice for SAP?](/en/technologies/cloud-computing/openshift/sap)
* [What is Kubernetes role-based access control (RBAC)](/en/topics/containers/what-kubernetes-role-based-access-control-rbac)
* [What is containerization?](/en/topics/cloud-native-apps/what-is-containerization)
* [What was CoreOS and CoreOS container Linux](/en/technologies/cloud-computing/openshift/what-was-coreos)
* [What is deployment automation?](/en/topics/automation/what-is-deployment-automation)
* [Learning Kubernetes basics](/en/topics/containers/learning-kubernetes-tutorial)
* [What is service-oriented architecture?](/en/topics/cloud-native-apps/what-is-service-oriented-architecture)
* [What is the Kubernetes API?](/en/topics/containers/what-is-the-kubernetes-api)
* [What is Kubernetes cluster management?](/en/topics/containers/what-is-kubernetes-cluster-management)
* [What is an SDK?](/en/topics/cloud-native-apps/what-is-SDK)
* [What is a Kubernetes deployment?](/en/topics/containers/what-is-kubernetes-deployment)
* [What is a Java runtime environment (JRE)?](/en/topics/cloud-native-apps/what-is-a-Java-runtime-environment)
* [Why choose the Red Hat build of Quarkus?](/en/topics/cloud-native-apps/why-choose-red-hat-quarkus)
* [What is an application architecture?](/en/topics/cloud-native-apps/what-is-an-application-architecture)
* [Introduction to Kubernetes architecture](/en/topics/containers/kubernetes-architecture)
* [Introduction to Kubernetes patterns](/en/topics/cloud-native-apps/introduction-to-kubernetes-patterns)
* [What is a Kubernetes cluster?](/en/topics/containers/what-is-a-kubernetes-cluster)
* [What is Quarkus?](/en/topics/cloud-native-apps/what-is-quarkus)
* [What are Java frameworks?](/en/topics/cloud-native-apps/what-is-a-Java-framework)
* [What is Jaeger?](/en/topics/microservices/what-is-jaeger)
* [What is container-native virtualization?](/en/topics/containers/what-is-container-native-virtualization)
* [What is an IDE?](/en/topics/platform-engineering/what-is-ide)
* [What is Clair?](/en/topics/containers/what-is-clair)
* [What is etcd?](/en/topics/containers/what-is-etcd)
* [What is Knative?](/en/topics/microservices/what-is-knative)
* [Why choose Red Hat for microservices?](/en/topics/microservices/why-choose-red-hat-microservices)
* [Why choose Red Hat for containers?](/en/topics/containers/why-choose-red-hat-containers)
* [What is Docker?](/en/topics/containers/what-is-docker)
* [What is a Kubernetes pod?](/en/topics/containers/what-is-kubernetes-pod)
[More about this topic](/en/topics/application-modernization "More about this topic")