A stateful app is a program that saves client data from the activities of one session for use in the next session. This data is called the application’s state.
Stateful and stateless are terms that identify whether an application is designed to note and remember one or more preceding events from previous interactions with a user, a device or another application or external element. Stateful apps store data from previous sessions, limiting the data that needs to be stored on the client end and retaining information on the server from one use to the next. This data may store user login information, preferences, variables for web service functions and more.
Stateful apps are used where operations that depend on previous sessions are common. Local PC applications, for example, are commonly stateful. The operating systems that applications run on are also typically stateful.
As HTTP is inherently stateless, if state is needed for web apps, it must be built into them. Stateless apps can be great for static pages, which serve the same content regardless of users. If desired, stateful features can be built in with dynamic pages. These pages can retain sessions by way of web address variables and server- and client-side stored data. Cookies and flash cookies are two ways such data might be stored. With stateful apps, a login session’s information is generally preserved until the session is logged out or expires with a predetermined time limit.
In web applications and especially cloud-based usage, stateful apps are becoming less common. This decline is partially because the commonly resulting file dependencies can cause complications in deployment for scalable apps. The I/O created by the requirements of remembering a session for stateful apps also makes for additional bandwidth and CPU overhead for servers. These complications are of particular concern in cloud environments and can restrict scalability by limiting data stores to specific locations.