Building Scalable Web Applications in 2021: Proactive Approach Saves Millions and can Serve Millions
11-minute read
Published 25, Jan 2021
According to Statista, there were 2,870,000 apps on Google Market Play alone as of the 3rd quarter of 2020. Mobile app development is a relatively new specialization that's seen exponential growth within less than two decades.
Number of apps available in leading app stores os of 3rd quarter of 2020
Statista
According to AndroidRank, 296,515 of the apps have at least 10 thousand downloads, and 43,896 of the apps have more than 1 million downloads as of the early days of 2021. That's a lot of loads to withstand. Let's see what it takes to build a scalable web application that is ready for high loads, is fault tolerant of increases and decreases in queries, and can quickly regain its working capacity.
App downloads distribution
AndroidRank

What is scalability?

Scalability is one of the key principles of web and app design, which suggests the initial conceptualization of systems and networks in a way that the final product’s capacity can be increased or decreased on-demand by adding more components without having to change the hierarchy of the core node. Such a system set up allows sustaining high load performance without experiencing downtime. The addition of supplemental components is mostly about adding hardware (servers, nodes, processors) to increase computational power. There is a distinction between horizontal and vertical scaling.
It is not uncommon to mistake scalability with a high-performance application. While both suggest the usage of extra computational power elements, only the scalable design also implies a pre-determined purposeful architecture of the app that is engineered for such usage peaks and valleys initially. However, the high-performance application can be achieved by adding more computational capacity to any poorly-conceived network. It is reactive though (unlike proactive scaling), so it will cost more than the scalable architecture and is not sustainable in the long run.

Horizontal vs Vertical Scaling

When your servers cannot cope with the number of requests and responses coming in and out when more users start wanting your software product, you can scale the capacity in 2 ways:
  • By adding more machines = horizontal scaling
  • By adding bigger machines = vertical scaling
In vertical scaling, all hardware components of the system get upgraded to their more powerful counterparts in terms of agility, speed, capacity – so that they can process more data faster and minimize downtime this way. In horizontal scaling, more individual hardware elements are added to the system with balancers working as mediators, and traffic controllers distributing the requests and channeling responses across the network of these components. Let's consider the advantages and disadvantages of each method:

Horizontal scaling:

Advantages: + resilient (if one element fails, the request is redirected to another one) + unlimited scaling (you can keep adding elements on demand) Disadvantages: - it needs a load balancing element because requests have to be directed to different machines. - slower performance (network calls need to be made to process requests) - data inconsistency (transactions flow among multiple elements)

Vertical scaling:

Advantages: + no need for balancing elements (single element only, nothing to balance) + faster (inter process communication, data is processed inside one machine) + consistent (data doesn’t need to travel between elements) Disadvantages: - Single point of failure as there is no additional element to redirect a request for processing if the only element fails. - Limited capacity (how ever expanded, the hardware element has a maximum limit)

Why do you need to think about designing a scalable app at first sight?

Some circumstances predetermine that you can build an app that is not scalable to start with:
  1. You need to quickly test a business theory of demand and are happy to invest quickly into the development of a new scalable application only if the idea proves popular.
  2. Your time-to-market is limited and you need to show the result quickly for investor and public relations purposes.
  3. You are creating a niche product with limited demand and no peak usage is expected due to a small addressable market.
But in many real-life cases, mobile or web applications need to be scalable from the conception stage. This is why:
  1. Prevention is better than cure. Moreover, prevention is cheaper than cure in most cases, even though it seems like you are investing in something that can be avoided at this early stage. Scalable web app design offers that very prevention that is cheaper than a cure at the end of the day.
  2. Not many business people create an app to sell to 10-20K users. The majority of business plans have user acquisition in hundreds of thousands of users in the first year to pay for its bills in a year or two. Consequently, creating an app that is not scalable is a waste of time and resources. Moreover, if an app proves popular but cannot sustain a significant volume of requests, you are shooting yourself in the foot: you managed to conceive a popular business idea but failed to sustain it technically.
  3. Traffic growth causes reduced performance and multiplies system failures.
  4. eCommerce inventory management and expansion, as well as order processing, become cumbersome under conditions of increased queries from users.
  5. Risks associated with changing the code structure grow exponentially, jeopardizing the entire operability of the application.

How to improve the Scalability of a web application: Techniques & Principles

Index tables for data management: ideal for small to medium data sets

Indexation is the process of data retrieval based on the creation of index tables that organize data in tables facilitating quicker search results even if the data is distributed across different physical devices. As an example, imagine a telephone book with name, surname, address, and a number. Instead of going through all of the entries in a phone book, indexation will allow you to go through the surname first, then narrow down the field by matching name and address to give out the phone number. While this works efficiently for small and mid-sized databases, it does get overly complex for huge databases with multiple columns. Caching is a widespread method of scalable web app design because of its simplicity and usability. The idea behind caching is that popular searches and queries get inquired about repetitively. For example, a home page of a web app will be viewed on multiple occasions with high probability. Creating a cache essentially means creating a mini repository on a user’s side for quicker access to popular queries. The cache can be employed across diverse levels of the hierarchy: either  distributed globally or on the node level.

Service-Oriented Architecture (SOA)

This is one of the most fundamental principles of the process of building scalable web sites and apps. This technique suggests that the architecture of the software is designed in such a way that every service or function is run as independently from the other ones as possible, with a separate set of hardware servicing it. In such a manner, all features and nodes are operating irrespective of each other, having little-to-no impact on other processes, allowing each other's further alterations, malfunctioning, and failures with the least detriment to other parts of the software solution. This method is also referred to as decoupled architecture or stateless services.

Watchtowers to Monitor your load

Another technique that is used when building scalable applications deals with monitoring the level of the load of incoming requests and queries. It is recommended that you ensure you have a dashboard designed to keep an eye on the load, alert you to high loads, and able to increase capacity if using AWS or similar cloud services, which can shrink and expand depending on the traffic. If using an outside cloud service provider, it's the best practice to set an upper limit for cloud service capacity consumption so that you don’t end up with sky-high bills after overnight activity.

Load Balancers for Horizontal Scaling

When you decide to increase the capacity of your elements by multiplying them (i.e., using horizontal scaling), you will need to use load balancers. They are responsible for redirecting the queries to independent nodes. Load balancers are used when the number of connections at the same moment increases and it is often amplified by caching and use of cookies.
Load Balancers for Horizontal Scaling
Microsoft Azure load balancer

Asynchronous Communications & Queues

Some work can be done in the background without much effect on the user. This is why message queues and other asynchronous processes were invented. They are programmed to send some of the non-urgent queries to the queue, which keeps checking back for new requests while doing all the work in the background. This takes away the stress from the application and has minimal impact on user experience.

Design for Fault Tolerance: No Chance for Single Point Of Failure

This technique suggests that you know your system will fail you and prepare for it as much as possible. With this mindset, software developers are prepared for stress and take preventive measures to counteract potential disasters. Along with such a mentality, a fault-tolerant scalable application will have no SPOF – single points of failure, like a single provider of cloud service, single disk, or a single database.
Design for Fault Tolerance: No Chance for Single Point Of Failure
AWS autoscaling

Afterword: Build a Scalable App with multiple variables in mind

When it comes to the performance and scalability of web applications, everything matters. There is architecture that needs to be proactively planned and thought through. There is a framework to be chosen based on your ambitions, time-to-market, and potential growth plan. There is load testing and quality coding. There are hardware constraints too, that need to be foreseen and accounted for. Most importantly, there are partners to be carefully chosen, as 3rd party integration problems are the most frequent cause of downtime and failures. A multi-factor mission such as creating a scalable application requires a team of professionals with years of experience and many cases in their portfolio. If you are choosing an app developing company to take care of your mobile and web applications, talk to the Zoolatech team. Zoolatech knows how to scale a web application with millions of users with minimal downtime and cost at every stage of the process from conception, framework choice, and vendor selection to testing and maintenance.
Let's build great productstogether!
Contact us