The Hitchhiker’s Guide to Telco Transformation - Part 6
Stateful Versus Stateless
So in the previous blogs in this series we’ve talked about a variety of subjects, the first blog discussed the basics of the aaS and cloud architectures, in our second we discussed the transition from hardware to services, in the third blog we reviewed the different types of PaaS’ available. The forth blog gave some insight into machine learning. My last blog took on the subject of VMs versus containers.
This blog will attempt to give short explanation or two about ‘stateful’ versus ‘stateless’ design, and the pros and cons of each. Stateful versus stateless design is perhaps new to us networkers, but has been embraced wholeheartedly by the cloud community. It has to do with the information saved and processed when dealing with the different inputs.
To understand these terms, one must understand statefulness. A “state” is simply the condition or quality of an entity at an instant in time, and to be stateful is to rely on these moments in time and to change the output given the determined inputs and state. According to Wikipedia ‘a program is described as stateful if it is designed to remember preceding events or user interactions; the remembered information is called the ‘state of the system’. So it goes to say, that statelessness doesn’t use prior or other information and deals with the input independently from any other information the system may have learned or experienced.
Let’s talk about a specific example of a stateful application: Assuming we manage an ecommerce website and someone surfs the site.
The user clicks on a product he or she would like to buy. The application stores the information about this event under the current session. This information may be stored in order to personalize the experience and to display more relevant information on the next click (users who bought this also bought that).
Now if the server goes down, we may lose all the stateful information. As a result, the next page the customer clicks might just display items which are not necessarily related to the product the customer was looking for in the first place. The result could be the potential loss of the customer altogether.
So the benefits of stateful applications include:
- Better personalization
- Better cross-sell/up-sell success
But there are also downsides:
- States need to be saved – i.e. storage is needed
- Processing time is longer, as background information needs to be retrieved and analyzed
We all use a variety of stateless applications on a daily basis without even knowing it. http is a stateless protocol, so we all surf the internet statelessly by default. Statelessness has its benefits as well for example:
- Stateless apps provide more efficient resource utilization for most uses.
- Stateless apps do not impact the session limit quota.
- Stateless apps dramatically reduce the complexity and cost of development
- Stateless apps achieve a higher level of concurrency
New architectures enable combination of Stateful and stateless, as well as containers and VM such that there is no need for and either/or mentality. For example the application or service can be containerized statelessly, while the Stateful information is stored in a separate Stateful DB. That said, using a mix and match approach also requires architecting the service in such a way as to access the proper information at the correct time.
Here’s an example:
Instead of storing the click data in the session, we could, for example, store all that information in the fast backend service, such as Amazon Dynamo DB and so avoid any loss because of such unpredicted event. Dynamo DB is a NoSQL data base. Amazon has geared it for speed using solid-state disks. Benchmarks show consistently low latency which is crucial for storing session level data.
So, when thinking about a cloud design, we need to recode our legacy applications and instead of storing state information locally by using well-known solutions (such as enterprise application server or local database) we can just put all information into a Dynamo DB, or a similar solution.
Whilst managing web-scale application using a resilient infrastructure, your business information will be kept secured even if some of the application servers experience failures. If your application is resilient, your business is resilient too.