7 Things You’ve Always Wanted to Know About Stateful vs. Stateless but Didn’t Want to Google

Unless you’re a software engineer, you may have not heard the term ‘stateless’ mentioned very often. If you have heard of the term ‘stateless’ at all, chances are you’ve heard it in the context of an individual’s geopolitical relationship to their country of origin. At Stateless Inc., we use the term often to refer to the unique way our software system is designed.

This article is focused on answering the question, “What is Stateless” in the context of networking software architecture so let’s dive in to answer some of those questions.

1. What is 'State'?

First, let’s define ‘state’ in the context of networking. State information is used in a variety of ways in networking. In simple terms, you can think of ‘state’ as the status of something right now.

For example, if you’re reading this article online your web browser has created a connection to our web server. The fact that this connection is active now, is state information. Someplace in your network, there’s a router that is keeping the information about this connection (the connection state) so that the router knows that it is ok to send any data you’re requesting from our webpage to your browser. If the router didn’t know that there was an active connection it wouldn’t send the data and you’d probably have to push the refresh button on your browser to cause your router to rebuild its state information.

In networking, state information is used for routing, security, traffic management, and many more purposes. But for all the value that state information provides, managing network state information is a big challenge. Remember that ‘state’ reflects the status of something right now. The status of the network right now depends on knowing what just happened in the context of the status of what just happened before. If this seems confusing, think about it in this way. If I gave you $10 dollars and you put it into your wallet with your other cash, that state of the cash in your wallet would be $10 plus whatever money you already had. There’s no way for me to know the current state of the cash in your wallet without having this other information. If you think about a router in a network that is trying to keep track of all the open existing connections, if the router misses a request to either open or close a connection, its view of what connections are currently active is going to be wrong. Its state information isn’t going to accurately reflect what is going on in the network right now. Why would this be a problem? Read on…

2. What is the downside to having to maintain 'State' information in each network device?

The trouble with how state information is managed in the network today is that each network device has to keep track of its own state. For example, your router keeps track of your open connections. If your router fails, or it misses a connection request it’s state information will be wrong. This mismatch in state information will mean that all of your connections will need to be reestablished.

Now imagine the number of connections that an Internet core router has to keep track of. Multiply this number by a million or two and you’ll begin to understand why managing ‘state’ information in a network is a big task. This is also why network outages are so difficult to resolve. State issues in one device are cascaded through the network and can cause issues in all the other devices.

You might think that we’re making a big deal about something that isn’t really a problem. Most of the time networks work well, right? Check out downdetector.com. Open the report for any popular internet service provider (ISP) and you’ll see something like this picture:

Networks fail and fail often. Picture of Internet Service Provider outages and issues report
We’ve redacted the name of the internet provider but you’ll find that this picture is similar for all ISPs. The bottom line is that networks fail, and they fail often. Everytime there is a problem why are we told to turn our modem off and then back on? Because by powering the device on and off we cause it to rebuild its state information.

Even if there isn’t a problem, since state is maintained in each network device, the devices are difficult to upgrade and maintain. Tasks that should be simple such as upgrading software or increasing a device’s capacity are service disrupting.

3. What is the best way to manage 'State' information?

Networks need ‘state’ to operate correctly, so there isn’t such a thing as a ‘stateless’ network. But we can separate the task of managing the ‘state’ from the process of moving data. and the network processes or functions that are used to build networks can be made to be ‘stateless’.

For example, routers are one of the most common types of networking devices. Routers contain a tremendous amount of state information so we’ve created a ‘stateless’ routing microservice network function that you can use in place of a router. I like to explain it this way. To build a network we need routing but we don’t need a router. A stateless routing microservice network function is a highly efficient piece of software that forwards packets to the proper destination. But we know that for a routing function to work properly we need state information, such as what connections are active. The trick to building a ‘stateless’ networking function is to store the state information somewhere else.

4. Can you store 'State' information somewhere else?

Network functions do need state, but the state information doesn’t need to be kept in the network function. At Stateless, we took the state information and placed it in a separate data store. When a routing function needs state information, it requests the information from the state store through a software orchestration layer. Taking the state out of the network function means that the function is ‘stateless’; the function doesn’t contain state information. If the function fails, we can just start a new function without the need of rebuilding the state information. Since we don’t need to rebuild the state this means that in the event of a failure we can start a new function and continue to route packets without service disruption.

5. So, what does 'Stateless' mean?

Stateless describes a process or function that doesn’t store information about the status of the network. By making network functions ‘stateless’, we’ve changed the fundamental way that networks operate. Stateless network functions are fault-tolerant, they can be upgraded while in-service (say goodbye to network maintenance windows), and they can scale as needed. These are only a few examples of the benefits gained when the state is maintained separately from the network function.

6. Why isn't everything 'Stateless'?

You might be wondering why networking devices are still being built using stateful processes. The issue is that in order for a process such as routing to operate efficiently it needs to be able to read and write state information very VERY quickly. Let’s do some math.

Let’s assume that we’re running a router on a moderately fast network. For example, let’s use a data rate of 1 Gbps (1 x 10^9 bits per second). For context, this is a typical rate for a fast LAN; 5G could be as fast at 10 Gbps, and core optical networks operate at 400 Gbps. At 1Gbps, it takes about 7 nanoseconds to read one byte. A typical data packet contains about 1,000 bytes so it takes about 7 x 10^9 x 1,000 or 7 microseconds to read an entire data packet. So our theoretical router would need to be able to process and forward packets at an average speed of 7 microseconds per packet in order to keep up with a data rate of 1 Gbps. 

The RAM inside your computer can read and write data with about a 20 nanosecond delay. This is more than fast enough for routing packets IF we keep the state information inside the routing program. So we can build fast but ‘stateful’ routing functions this way.

If we want to separate the state information and store it in a database then we need to consider how long it takes to read/write from a database. A normal database read/write operation typically requires about 1,000 microseconds, or about 150 times the amount of time it takes to read a packet. So, a typical database is far too slow, it has too much latency to allow us to process packets fast enough.

So how did we build a system that can process packets at network speeds and use a distributed database to store state? It’s no secret, you can read about it in our patent. Some of the key parts of our invention is that we applied the latest cloud-native software development techniques such as the use of parallel processing, batching of database queries and we used a RAM-based database called RAMCloud. RAMCloud can return database queries in a little as 5 microseconds. That’s about 200 times faster than a normal database. When we combine modern software design techniques, along with our patented processes and with the speed of RAMCloud, we end up with a new kind of networking tool that can be used to construct networks that use stateless network microservices.

7. What are the benefits of using 'Stateless' network functions?

Stateless network functions are a completely new type of tool for building networks. Consider it this way, let’s say you wanted to build a tiny house. Your tools might include hammers, screwdrivers, tape measures, etc. But if you were to build a tiny house the ‘Stateless’ way you’d print it on your 3D printer. The 3D printer method is immensely more flexible, faster, and more cost-effective than traditional techniques.

Building networks using stateless network functions has the same type of advantages. You can build networks using yesterday’s tools or you can build them with a stateless network functions platform. Regardless of the way you build them you end up a similar construct. But if you choose to build your networks using stateless tools you’ll get these benefits as well:

  • Speed – use, configure and manage only the functions you need
  • Scale-out, not up – one cluster can handle thousands of interconnections
  • End-to-end visibility– manage interconnections that span many stateless network functions as a single traffic flow – view the entire flow and each function within it
  • Flexibility to adjust, scale, or remove functions on-demand – evolve and innovate with 100% API control – you define how your network functions/interconnections operate.
  • Incredible resiliency – always on, always available – no disruptions for updates, inherently HA and built-in protection from software or hardware failures
  • True multi-tenancy – full hierarchical, per tenant, control plane & data plan isolation. Even your tenants can have tenants

Like this post? Share it and spread the word!



Subscribe to the Stateless blog for monthly updates

This website uses cookies to ensure you get the best experience on our website. We use cookies to provide social media features and to analyze our traffic.