In the world of cloud computing, big data and IoT, system and application requirements have changed by leaps and bounds in recent years. Even the challenges being faced by developers and enterprises today are way different from the ones that they faced, say, a decade or two earlier. Applications are being built for mobile devices and deployed on the cloud.
A recent Ericsson Mobility Report has said that the Internet of Things (IoT) will leave mobile devices behind to become the largest category of connected devices. Software applications have to evolve accordingly to accommodate such rapid changes in the digital world and the traditional three-tier software architecture will not be able to keep up the pace.
This is where the concept of Reactive Systems comes in. Before we understand what reactive systems are, let’s first get to know how they fit into the modern business model and why businesses will lag behind if they do not go the Reactive way.
Why choose Reactive Systems?
If you go back in time to the year 1999, the internet was being used by merely 280 million people. Fast forward to today, even one single website handles more traffic than that figure. Take the example of an online retail giant, Amazon.com, which handles monthly traffic of 2.4 billion, mobile and desktop combined.
Times have certainly changed and user expectations have gone high. They want a seamless experience with application usage as they are flooded with options in the form of your competitors. Your application should be built on a robust architecture that can respond to change, handle load spikes, and adapt to failures. As such, terms like ‘distributed’, ‘scalable’ and ‘modularity’ have become buzzwords within the tech industry especially with the rise of phenomena like IoT, mobile, cloud and containerization.
To understand how reactive systems come into the picture to accomplish all that, we need to dive deeper into the four reactive principles.
The four Reactive Principles
Reactive Systems will exhibit these four properties.
A reactive system will be responsive, which simply means that it will respond instantly to different scenarios in real-time, be it a positive or a negative one so that the user experience is not affected under any circumstance. If a system is responsive, the user will be satisfied with his experience irrespective of the device he’s using (desktop or mobile), a sudden burst in traffic, or any partial failures.
Rapid response time is essential in building up the confidence of your users and ensuring that customer relations are maintained in the long run. Take the example of eCommerce companies that cannot compromise on consistency. If they announce a sale or lucrative offers, one expects a sudden surge in traffic as the sale or offer goes live. A responsive website ensures that the website can handle that kind of a spike and users don’t encounter a situation of a website crash or failure.
The other two reactive principles, elasticity & resilience, together make a system responsive. So, let’s understand these terms as well.
Resilience simply means that the system can respond instantly in the case of any kind of failure. In a real-world scenario, things can go wrong anytime. Your system should be responsive in the face of infrastructure failure or a security breach or any other kind of unexpected event.
To understand the importance of resilience, consider this case study. An American global financial services firm lost close to a whopping $440 million after a software update went horribly wrong in 2012. As the software update was initiated on the production servers, an obsolete, old application got initialized incorrectly. As a result, as the New York Stock Exchange opened for trading, the company’s trading system swamped NASDAQ with 4 million erroneous trades and brought the company on the brink of bankruptcy.
This happened because of the plain and simple fact that even though the software system of the financial services firm displayed good levels of performance in normal circumstances, it wasn’t resilient enough to respond to an abnormal situation like this. The program that got fired up was only supposed to run in the test environment and there was not even a mechanism in place to abort the program despite the fact that it had the ability to drain out all the company reserves within a short span of 45 minutes.
Elasticity and scalability are two interchangeable terms which mean that your system can react and respond to varying load conditions. A reactive system will be able to decide what amount of resources to be allocated should the incoming traffic surge or drop accordingly. Elasticity is ensured by three alternatives – by scaling up which means adding more powerful machines to enhance the resource of a single server, scaling out which means adding more machines to the system and scaling down which means bringing down the allocated resource count.
Scaling down often takes a backseat though it is equally important as it helps in saving up of unnecessary bills and preventing over-utilization of resources. Tech businesses like Netflix and Gilt make use of something called predictive scaling. Predictive scaling helps a system to decide when to scale. It is already aware of the times when heavy traffic is expected and it helps provisioning servers for those time periods.
For instance, Gilt, a flash sale site knows quite well that the traffic is going to hit an all-time high when a sale is announced at noon, so the system spins up nodes when spikes are expected and frees up servers when the requirement lowers down. This is how smart businesses ensure elasticity which helps them not only to prepare for higher load but also save up cost, effort, and resources when the demand decreases.
The ‘message-driven’ property of reactive systems is what makes scalability and resilience a reality. The components of a reactive system communicate through an asynchronous, non-blocking methodology of message passing that allows for a temporal boundary between components. This asynchronous boundary makes it possible to allow loose coupling between components that further makes isolation and location transparency possible.
Isolation is what makes the system resilient. Since components are isolated, failure in one of them does not affect the other. Processes can be segregated according to their properties like how likely they are to fail, what is their performance, CPU usage and more. Since the nature of message passing is asynchronous, system components do not sit around waiting for a response from the other component to function and that’s how they can work independently even when components fail.
Another concept that is worth mentioning is an actor-based concurrency. This concept is an extension to the message-driven architecture where messages are meant for a particular recipient which are called actors. An actor happens to be a construct which has its own mailbox, an actor’s logic and an isolated state instead of a shared state. These actors can exchange messages to themselves and even have them directed to themselves. These messages can surpass thread boundaries and be delivered to another actor’s mailbox on a disparate server.
What this means for your system is that it can be scaled out spanning network boundaries while avoiding callback hell. An actor-based application can prove to be powerful for your business by giving you applications that can be hyper scalable while being easy to design, build and maintain. Instead of worrying about time and space, developers can only focus on how messages will be passed through between actors.
Want to leverage the benefits of reactive systems? We can help out…
With mobile, IoT and data-driven applications, it has become imperative for businesses to respond to customers in real-time with responsiveness being the buzzword in the industry. Businesses cannot afford to have fragile and static architectures and need to upgrade to reactive models.
As official Lightbend partners, we at Knoldus have helped companies successfully integrate scalable, fault-tolerant solutions through Reactive Systems on Scala, Spark, Lagom, Akka, Kafka, and Play. Leverage our expertise to build modern, Reactive systems that meet the performance, scalability, and reliability needs of today’s cloud-native applications. Book a meeting or drop us a message here or at firstname.lastname@example.org and we’ll help you get started.