Show Menu
Cheatography

System Scalability Cheat Sheet (DRAFT) by

A scalable system is one that can handle rapid changes to workloads and user demands. Scalability is the measure of how well that system responds to changes by adding or removing resources to meet demands.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

System scalab­ility

System scalab­ility refers to the ability of a computer system, network, or software applic­ation to handle an increasing amount of work, such as additional users, higher data volumes, or more complex proces­sing, while mainta­ining acceptable perfor­mance levels. Scalab­ility is a crucial aspect of system design, partic­ularly in enviro­nments where growth, fluctu­ations in demand, or changes in requir­ements are expected. Here are some key aspects of system scalab­ility

Scalab­ility vs Perfor­mance

Scalab­ility refers to the ability of a system to handle an increasing workload or user base while mainta­ining acceptable perfor­mance levels. It focuses on the system's ability to scale up or scale down in response to increa­sed­/de­creased demand.
Perfor­mance refers to how well a system performs a specific task or operation, often measured in terms of speed, response time, throug­hput, or latency.
Unlike perfor­mance, scalab­ility should always be measured under variable load
Perfor­mance optimi­zation aims to maximize the speed, effici­ency, and respon­siv­eness of the system under a fixed workload

Scalab­ility principle

Decent­ral­ization
Indepe­ndence
Modularity

Decent­ral­ization

Monolith is an anti-p­­­a­ttern for scalab­­ility.
Involves distri­­­b­uting tasks, respon­­­s­i­b­­i­­li­­­ties, and resources across multiple nodes.

Indepe­ndence

Indepe­ndence refers to the ability of system components to operate autono­­mously and indepe­­nd­ently of each other.

Modularity

Scalable archit­­­e­c­tures often start with modula­­­rity
Allows components to be indepe­­­n­d­ently developed, deployed, and scaled
Each module performs a specific function
can be replicated or distri­­­buted as needed

Scalab­ility Types:

Vertical scaling
Horizontal scaling

Vertical scaling

Increase the resources (CPU, RAM, etc.) of a single server.
Enhancing the capabi­­lities of existing hardware
Benefits
Easier to implement
Easier to manage
Challenges
Limited scalab­ility
Hardware constr­aints
Single Point of Failure
Cost-E­ffe­cti­veness

Horizontal scaling

Adding more servers or machines or nodes
Additional resources work in parallel to distribute the load
Allows the system to handle increased traffic
Benefits
Unlimited scalab­ility
Better Perfor­mance
High Availa­bility
Cost-E­ffe­cti­veness
Challenges
Hard to achieve
Data Consis­tency

Horizontal scalab­ility

Replic­ation
Services
Caching
Asynch­ronous process
Partit­ioning

Replic­ation applic­ations

Stateless:
Code replic­ation
Stateful:
Code & Data replic­ation
 

Stateless replic­ation

Each request is processed indepe­ndently
Each replica can operate autono­mously
Does not maintain any state or session data
Components can be replicated across multiple servers or instances
Lower commun­ication overhead
Challenges
Session Management
Consis­tency and Synchr­oni­zation
Monitoring and Load Balancing

Stateful replic­ation

Maintains session data or other infos of users/­ses­sions
All replicas maintain synchr­onized state
Includes database replic­ation across instances
Challenges
Session Management
Data Consis­tency
Synchr­oni­zation Overhead
Failure Handling

Database replic­ation

Benefits
Higher data availa­bility
Reduced server load
More reliable data
Better protection
Lower latency
Better applic­ation perfor­mance
Challenges
Incons­istent data
Lost data
Database replic­ation types
Master­-Slave Replic­ation
Master­-Master Replic­ation
not going to discuss about in details about types as most of are aware of it

Database replic­ation

Caching

Alleviates the load on backend resources
Improves system perfor­mance
Reduces latency
cached data across multiple cache servers or instances
support horizontal scaling

Partit­­ioning

Splits a large dataset or workload into smaller ones
Distri­­buted across multiple servers or nodes
Benefits
Handles increased data volume
Handles higher user concur­­rency
Handles workload demand more effect­­ively
Types:
Vertical Partit­­ioning
Horizontal Partit­­ioning
 

Vertical partit­­ioning

Splits a large dataset into smaller partit­­­ions based on the functi­onality
Completely decouples services and databases for higher scalab­ility
Benefits
Efficient Resource Utiliz­ation
Flexible Scalab­ility Options
Tailored Data Management
Challanges
Data Distri­bution and Access Patterns
Limita­tions in number of partit­ioning
Data Locality and Access Patterns

Vertical partit­­ioning

In the image DB are splitted into Inventory, Order, Catalog and User

Horizontal partit­ioning

Splits a large dataset horizo­­ntally into smaller partit­­ions. Rows are divided into smaller sets, and each set is stored separa­tely.
Partition based on ranges of data, hash values, or other partit­­ioning keys.
Distri­butes data and workload across multiple servers
Handle increased data volume
Benefits
Increased Throughput
Enhanced Scalab­ility
Partit­ioning Strategies
Challanges
Data Distri­bution
Data Consis­tency and Integrity
Partition Management and Mainte­nance

Horizontal partit­ioning

Load Balaner

Distri­butes incoming traffic
Ensures optimal perfor­mance and reliab­ility
Types
Hardware Load Balance
Supports L4* and L7*
Higher cost
Limited flexib­ility and agility compared
Software Load Balancer
Supports only L7*
Lower cost compared to HLB
Greater flexib­ility and agility in deployment and manage­ment.
L4 - Transport Layer of the OSI includes UDP,TCP, SCTP
L7 - Applic­ation Layer of the OSI which is highest layer includes HTTP, HTTPS, SFTP etc

Asynch­ronous services

 

Asynch­ronous services

Decoupling tasks or processes from synchr­onous execution
Improves system respon­siv­eness, resource utiliz­ation, and fault tolerance

DNS as load balancer

Involves leveraging DNS to distribute incoming client requests across multiple backend servers or resources.
Returns single IP in round robin fashion
can be configured along with health checks
Drawback
Indefinite caching
Low or zero TTLs
Very high load on DNS

SAGA Pattern

Atomic Transa­ctions
Asynch­ronous Commun­ication
Horizontal Scaling
Fault Tolerance
Dynamic Adaptation
Isolation of Operations

Micro service archit­ecture style

Shared Nothing archit­ecture
Services developed and deployed indepe­ndently
Achieved through vertical partit­ioning
Vertic­al/­Domain partit­ioning
Indepe­ndent schema­/da­tabase
Loosely coupled services interf­ace­(REST interf­aces)
No reusable libraries except utlities
Challenges
Duplicate codebase
Transa­ction failures
Transa­ction rollbacks

Discovery services

Manage servic­e-t­o-s­ervice commun­ication in a distri­buted system
Facilitate the dynamic discovery
Contin­uously monitors the health and availa­bility of registered micros­erv­ices.
Benefits
Service Regist­ration and Discovery
Dynamic Load Balancing
Fault Tolerance and Failover
Service Scaling and Elasticity

Conclusion

Scalable systems are decent­ralized and functions indepe­ndently
To make a system scalable
Cache frequently read and rarely mutating data
Asynch­ronous or Event driven process
Vertical partit­ioning of functi­onality into indepe­ndent, stateless, replicated services
Partit­ioning and replic­ation for extreme scalab­ility
Scalable systems infra
Load balancers - Hardware based & Software based
Discovery services for service discovery and health checks
DNS as load balancer
Micros­ervices
Fully vertically partit­ioned services and databases leads to eventual consis­tency