Professional Documents
Culture Documents
Scalability PDF
Scalability PDF
Scalability PDF
What is Scalability?
This lesson introduces scalability.
• What is scalability?
• What is latency?
• Measuring latency
• Network latency
• Application latency
• Why is low latency so crucial for online services?
This chapter is a deep dive into scalability. It covers all the frequently
asked questions about it, including what does scalability mean in the
context of web applications and distributed systems?
What is scalability?
Scalability means the application’s ability to handle and withstand
increased workload without sacrificing performance.
What is latency?
Latency is the time a system takes to respond to a user request. Let’s say
you send a request to an app to fetch an image and the system takes 2
seconds to respond to your request. The latency of the system is 2 seconds.
If the latency remains the same, we can say that the application scaled
well with the increased load and is highly scalable.
https://www.educative.io/module/lesson/web-application-architecture-101/N02LPnROXmv 2/5
04/02/2023, 10:55 What is Scalability? - Web Application and Software Architecture 101
A program with the complexity of O(n^2) where n is the size of the data set
is not scalable. As the size of the data set increases, the system will need
more computational power and other resources to process the tasks.
Measuring latency
Latency is measured as the time difference between the action that a user
takes on the website and the system’s response in reaction to that action.
The action can be an event like clicking a button, scrolling down a web
page, etc.
Network latency
Application latency
Network latency
Network latency is the time that the network takes to send a data packet
from point A to point B. The network should be efficient enough to handle
the increased traffic load on the website. To cut down the network latency,
https://www.educative.io/module/lesson/web-application-architecture-101/N02LPnROXmv 3/5
04/02/2023, 10:55 What is Scalability? - Web Application and Software Architecture 101
If you wish to understand the Edge locations and how apps are
deployed in the cloud. Check out my cloud computing 101 course on
my platform.
Moving on.
Application latency
If the visitor gets the response within a stipulated time, great otherwise,
they’ll bounce off to another website. There is ample market research that
concludes high latency in applications is a big factor in customers
https://www.educative.io/module/lesson/web-application-architecture-101/N02LPnROXmv 4/5
04/02/2023, 10:55 What is Scalability? - Web Application and Software Architecture 101
We can realize the importance of low latency by the fact that in 2011
Huawei and Hibernia Atlantic started laying a fiber-optic link cable across
the Atlantic Ocean between London and New York. This property was
estimated to cost approximately $300M just to save traders six
milliseconds of latency.
Back Next
Mark as Completed
https://www.educative.io/module/lesson/web-application-architecture-101/N02LPnROXmv 5/5
04/02/2023, 10:56 Types of Scalability - Web Application and Software Architecture 101
Types of Scalability
In this lesson, we will explore the two types of scaling: Vertical and Horizontal.
Vertically
Horizontally
https://www.educative.io/module/lesson/web-application-architecture-101/qArJ4LOJwl2 1/4
04/02/2023, 10:56 Types of Scalability - Web Application and Software Architecture 101
Ideally, when the traffic starts to build on the app, the first step should be
to scale vertically. Vertical scaling is also called scaling up.
In this type of scaling, we augment the power of the hardware running the
app. This is the simplest way to scale as it doesn’t require any code
refactoring or the need to make any complex configurations and so on. I’ll
discuss in the next lesson why code refactoring is needed when we
horizontally scale our app.
https://www.educative.io/module/lesson/web-application-architecture-101/qArJ4LOJwl2 2/4
04/02/2023, 10:56 Types of Scalability - Web Application and Software Architecture 101
With this, the increased traffic influx can be efficiently dealt with. And
there is no limit to how much we can scale horizontally, assuming we
have infinite resources. We can keep adding servers after servers, setting
up data centers after data centers.
Cloud elasticity
The most prominent reason cloud computing became mainstream in the
industry is the ability of the cloud to scale dynamically. In case of the
https://www.educative.io/module/lesson/web-application-architecture-101/qArJ4LOJwl2 3/4
04/02/2023, 10:56 Types of Scalability - Web Application and Software Architecture 101
traffic climb, the cloud adds additional servers to the hardware resource
pool and when it drops, the servers added are removed.
The ability to use and pay only for the hardware resources used by the
website got popular with businesses for obvious economic reasons.
If you wish to know in detail how cloud platforms scale our apps and
make them highly available. I’ve discussed the concept in my cloud
computing 101 course how clustering works and how cloud companies
deploy our apps across continents.
Having multiple server nodes on the backend also helps the website stay
online even if a few server nodes crash. This is known as high availability.
We’ll get to that in the upcoming lessons.
https://www.educative.io/module/lesson/web-application-architecture-101/qArJ4LOJwl2 4/4
04/02/2023, 10:56 Which Scalability Approach is Right for our App? - Web Application and Software Architecture 101
https://www.educative.io/module/lesson/web-application-architecture-101/JPQ6ny6oODK 1/4
04/02/2023, 10:56 Which Scalability Approach is Right for our App? - Web Application and Software Architecture 101
Also, whatever data static variables hold, it’s not application-wide. For this
reason, distributed memory like Redis, Memcache, etc., are used to
maintain a consistent state application-wide. When writing applications
for distributed systems, it’s a good practice to avoid using static instances
in the class. The state is typically persisted in a distributed memory store;
this facilitates components to be stateless.
https://www.educative.io/module/lesson/web-application-architecture-101/JPQ6ny6oODK 2/4
04/02/2023, 10:56 Which Scalability Approach is Right for our App? - Web Application and Software Architecture 101
If your app is a public-facing social app like a social network, a fitness app,
an online game, or something similar, where the traffic is unpredictable.
Got any feedback? Get in touch with us.
Both high availability and horizontal scalability are important to you.
Build these apps to deploy them on the cloud, and always have horizontal
scalability in mind right from the start.
Back Next
https://www.educative.io/module/lesson/web-application-architecture-101/JPQ6ny6oODK 3/4
04/02/2023, 10:57 Primary Bottlenecks That Hurt the Scalability of our Application - Web Application and Software Architecture 101
• Database
• Application design
• Not using caching in the application wisely
• Inefficient configuration and setup of load balancers
• Adding business logic to the database
• Not picking the right database
• At the code level
There are several points in a web application that can become a bottleneck
and hurt the scalability of our application. Let’s take a look at them.
Database
Imagine we have an application that appears to be well architected.
Everything looks good. The workload runs on multiple nodes, and it can
scale horizontally.
However, the database is a poor single monolith, where just one server
has the onus of handling the data requests from all the server nodes of the
workload.
This scenario is a bottleneck. The server nodes work well, handle millions
of requests at a point in time efficiently, yet, the response time of these
requests and the latency of the application are abysmal due to the
presence of a single database. There is only so much it can handle.
https://www.educative.io/module/lesson/web-application-architecture-101/YQxW727jNBA 1/4
04/02/2023, 10:57 Primary Bottlenecks That Hurt the Scalability of our Application - Web Application and Software Architecture 101
Application design
A poorly designed application’s architecture can become a major
bottleneck as a whole.
If the system has a lot of static data, caching can bring down the
deployment costs significantly. I’ve written an article on my blog: How
PolyHaven manages 5 million page views and 80TB traffic a month for less
than 400 USD.
https://www.educative.io/module/lesson/web-application-architecture-101/YQxW727jNBA 2/4
04/02/2023, 10:57 Primary Bottlenecks That Hurt the Scalability of our Application - Web Application and Software Architecture 101
The database is just not the place to put business logic. Business logic in
the database makes the application components tightly coupled. Imagine
how much code refactoring this would require when migrating to a
different database. Also, the testing gets complex.
Trying to pull things off with a not-so-suitable tech always has a profound
impact on the latency of the entire application in negative ways. More on
this in the upcoming lessons.
In this lesson, don’t worry if a few things are not clear to you, such as
strong consistency, how the message queue facilitates asynchronous
behavior, or how to pick the right database. I’ll discuss all that in the
upcoming lessons. Stay tuned.
Back Next
Which Scalability Approach is Right for our … How to Improve and Test the Scalability of o…
Mark as Completed
https://www.educative.io/module/lesson/web-application-architecture-101/YQxW727jNBA 4/4
04/02/2023, 10:57 How to Improve and Test the Scalability of our Application? - Web Application and Software Architecture 101
Now you might be wondering, “Why are you talking about performance
when you should be talking about scalability? Isn’t it what the lesson title
says?”
https://www.educative.io/module/lesson/web-application-architecture-101/39VNYBx7Z9r 1/5
04/02/2023, 10:57 How to Improve and Test the Scalability of our Application? - Web Application and Software Architecture 101
Profile the hell out of your app. Run application profiler and code profiler.
See what processes are taking too long and are eating up too many
resources. Find out the bottlenecks. Get rid of them.
Caching
Cache wisely, and cache everywhere. Cache all the static content. Hit the
database only when it is really required. Try to serve all the read requests
from the cache. Use a write-through cache.
CDN
Use a Content Delivery Network (CDN). Using a CDN further reduces the
application’s latency due to the proximity of the data from the requesting
user.
Data compression
https://www.educative.io/module/lesson/web-application-architecture-101/39VNYBx7Z9r 2/5
04/02/2023, 10:57 How to Improve and Test the Scalability of our Application? - Web Application and Software Architecture 101
Avoid unnecessary round trips between the client and server. Try to club
multiple requests into one.
These are a few of the things we should bear in mind in the context of
application performance.
The right approach for testing the application for scalability largely
depends on the design of our system. There is no standard formula for
this.
Testing can be performed at both the hardware and the software level.
Different services and components need to be tested—individually and
collectively.
During the scalability testing, different system parameters are taken into
account, such as:
CPU usage
Network bandwidth consumption
Throughput
Number of requests processed within a stipulated time
Latency
Memory usage of the program
End-user experience when the system is under heavy load and so on.
In this testing phase, simulated traffic is routed to the system to study how
the system behaves and scales under the heavy load. Contingencies are
planned for unforeseen situations.
some buffer.
Several load and stress tests are run on the application. Tools like JMeter
are pretty popular for running concurrent user tests on the application; if
you are on the Java ecosystem. There are a lot of cloud-based testing tools
available that help us simulate test scenarios just with a few mouse clicks.
Businesses test for scalability all the time to get their systems ready to
handle a traffic surge. If it’s a sports website, it prepares itself for the
sports event day. If it’s an e-commerce website, it makes itself ready for
festival season sale.
In the industry, tech like Cadvisor, Prometheus and Grafana are pretty
popular for tracking the system profile via web-based dashboards.
https://www.educative.io/module/lesson/web-application-architecture-101/39VNYBx7Z9r 4/5
04/02/2023, 10:57 How to Improve and Test the Scalability of our Application? - Web Application and Software Architecture 101
Back Next
Mark as Completed
https://www.educative.io/module/lesson/web-application-architecture-101/39VNYBx7Z9r 5/5