DEV Community

Cover image for Building Scalable and Resilient Web Applications: Strategies for Developers
Developer Nation Survey
Developer Nation Survey

Posted on • Originally published at developernation.net

Building Scalable and Resilient Web Applications: Strategies for Developers

By Srdjan Gombar

Currently, there are 6.9 billion people with access to smartphones and at least some form of internet worldwide. This means that, when developing an app, you have a potential audience of well over 80% of humankind.

Now, while it’s unrealistic to expect any app to pull these numbers (even Instagram is used by “just” 2.35 billion), the tipping point past which your app can no longer function as before is far closer than you assume.

To make matters worse, it takes just a couple of (very) dissatisfied users to ruin your rating and leave enough bad reviews to ruin your app’s reputation. This is why you must ensure that your app is scalable and resilient. Here are the top six strategies to help you with that.

1) Horizontal scaling
When structuring your servers, vertical scaling makes the most sense. After all, upgrading the server, you’re already using or starting with an impressive server (the one that gives you room for growth) is intuitive. The problem is that this system is not the most reliable. Instead, horizontal scaling, where you add more servers instead of improving a single one, might provide you with more value.

Horizontal scaling is impressive because it will allow you to withstand much higher traffic. For an app developer, having more users is the optimal end goal, so not having a plan for success simply makes no sense.

Horizontal scaling improves performance, and it’s much more cost-efficient. Adding a server sounds expensive, but it offers you flexibility and simplicity. After all, you can add more servers as you go. This means you don’t have to start too ambitious (like with vertical scaling).

Most importantly, you have the privilege of isolating services from one another. This way, you gain a lot of resilience because a flaw, a failure, or an attack on a single service won’t compromise the rest. This also makes troubleshooting a lot easier.

The biggest challenge of horizontal scaling is achieving data consistency; however, there are more than a few ways to overcome this.

Want to share your opinion? Take the global Developer Nation Survey and shape the key trends among developers for 2023. Take a look.

2) Work on load balancing
Previously, we’ve talked about the imperative of working on multiple servers. Without load balancing, this would be like having five rooms in a home and spending 90% of the time in a single one. With the help of load balancing, you can evenly distribute this and get the most out of the servers you’re using.

There are numerous load-balancing techniques:

  • Hardware load balancers: This is the simplest form of load balancing since it relies on having a device that distributes traffic when it reaches a certain load.
  • Software load balancers: This is a part of the application stack. These are virtual machines that act in a similar way to hardware load balancers.
  • Content delivery networks: A content delivery network is located in different locations. This caching service is scattered across the globe to provide you with an even higher service resilience.

The best thing about load balancing is that it’s incredibly scalable. This is why the sooner you start doing this, the better results you will face. When your audience outgrows your current capacity, you can provide consistent performance across peak hours.

More importantly, load balancing boosts the availability of your application. This means that, in the scenario where one of the servers falls, your app will not be completely unavailable. You’ll try to avoid this worst-case scenario at any cost.

3) Use mobile IP proxy in research and testing
As a web developer, you have to do a lot of research. Now, some of this research will be unavailable due to geographical restrictions. This is why you must use a mobile IP proxy while researching.

While doing research, you’re assuming a role of a customer, which means that various competitor platforms you’re researching target you based on your history. Because your research patterns may take you to the most unexpected places, the experience you get when you try to emulate the customer experience will be all but authentic.

It’s also worth mentioning that mobile IP proxy helps you avoid being blocked or flagged. Some platforms will do this if you make too many requests, which is sensible from their standpoint but may seriously slow down your research.

Then, there’s the issue of load testing and scalability. You need to see how the platform will behave when accessed through a different IP, especially one using a different locale. This way, you test whether the experience provided by your app gives a consistent experience.

Finally, you can avoid captchas and bot detection measures by rotating IP addresses. Sure, this is not a huge problem, but it’s a slight annoyance that you can easily bypass with the right approach.

4) Embrace asynchronous processing
Imagine a scenario where you plan a five-course meal at a restaurant but refuse to order all the meals simultaneously. Imagine waiting until you finish the first course only to request the second, the third, and so on. It would be inefficient, waste everyone’s time and cause a massive hold-up in the operations.

This is what synchronous processing is like. It’s a system where you make one request at a time and must wait for the current task to be completed to move to the next one. It will slow down the application process and make your audience perceive your application as slow and inefficient.

The solution is asynchronous processing, which makes all the necessary requests without waiting for previous tasks to finish. Since modern apps and servers running them can run multiple processes in the background, there’s no good reason not to use all this computing power.

The benefits of this process are numerous:

  • Improved responsiveness
  • Reduced latency
  • Scalability
  • Parallelism

In other words, you improve your app in all fields, directly contributing to a superior UX.

Most of these tasks are achieved through asynchronous APIs, background tasks, and non-blocking I/O libraries. The latter performs network communication without blocking the main application thread.

5) Look into auto-scaling
Real-time demand will consistently change. Even in video game apps, you have peak times on servers. In the past, some games tried to handle this by adding a user queue. This is hardly a technique that would work in web applications. Instead, you must create a system with enough elasticity to handle increased traffic.

More importantly, you need a system capable of efficiently managing these resources and automatically adjusting to the increased demand.

The way this functions is quite simple – you have a system that monitors the application’s performance across all users. Instead of allowing the service to slow down during peak, the system would utilize a cloud-based environment to improve CPU utilization quickly. This can be set to happen as soon as the number of incoming requests passes a certain threshold. Even here, you need the right strategy.

If we compared this to naval combat, it would be like firing your cannons seconds before the enemy vessel enters your range just because you know the shell will take a while to reach the target. In other words, you need to develop an in-depth understanding of your traffic patterns and create a system that will instantly respond (far quicker than a human-issued command ever could).

This way, you will get the optimal cost-efficiency, availability, and, most importantly, optimal performance.

The key, however, lies in finding the right auto-scaling triggers. The most effective ones are usually:

  • Incoming traffic
  • CPU utilization
  • Response time

The last one is a bit imperfect because, from a user’s perspective, it’s reactive rather than proactive.

Double down on performance testing
Previously, we’ve discussed using an IP proxy to test how your platform behaves when accessed from different locations. However, this is not the only metric that you should test. You must also test the following:

  • Load
  • Stress
  • Endurance
  • Spike
  • Scalability
  • Volume

Besides determining the subject of your tests, you must also figure out the KPIs you’re looking into.

  • Response time: The most important aspect of user experience is response time. People hate using laggy apps. Chances are that they’ll switch to an alternative, provided that there is one.
  • Concurrency: Users only assess your app’s performance from their personal experience, which may vary based on the time of day when they access it. With scalable development, you’ll be able to achieve a pretty similar consistency around the clock.
  • Error rate: Does the app break often? What are the odds of requests failing? Sure, people are more tolerant of this, but if your response time is slow, restarting the app or trying again will be even worse.

In the end, you can see how these KPIs stack. A poor response time can make a critical error exponentially worse. This is why you can’t afford to ignore a single problem.

With the right strategy, your web applications will be more scalable and resilient

Top comments (0)