Skip to main content

Horizontal Scaling VS Vertical Scaling in Database Systems

 

Vertical vs. Horizontal Scaling

Introduction

Scaling is the process of increasing a system's capacity to handle more load. There are two main types of scaling: vertical and horizontal.

Vertical Scaling (Scaling Up)

Definition:

Vertical scaling involves adding more resources (like CPU, RAM, or storage) to a single existing machine.

Key Points:

  • Increases the power of a single machine
  • Easier to implement
  • Has a limit (the maximum capacity of a single machine)

Example:

Imagine your computer is struggling to run multiple programs at once. Vertical scaling would be like:

  • Adding more RAM (from 8GB to 16GB)
  • Upgrading the CPU (from dual-core to quad-core)
  • Installing a faster SSD

Real-world Analogy:

It's like replacing a small moving truck with a larger, more powerful truck to handle more goods.

Horizontal Scaling (Scaling Out)

Definition:

Horizontal scaling involves adding more machines to your system to share the load.

Key Points:

  • Distributes load across multiple machines
  • More complex to set up and manage
  • Virtually unlimited scaling potential

Example:

Instead of upgrading a single web server, you add more servers:

  • Start with one server handling 10,000 users
  • Add a second server to handle 20,000 users
  • Keep adding servers as user count grows

Real-world Analogy:

It's like adding more checkout counters in a supermarket to serve more customers simultaneously.

Comparison Table

Aspect

Vertical Scaling

Horizontal Scaling

Implementation

Upgrade existing hardware

Add more machines

Complexity

Simpler

More complex

Scalability Limit

Limited by hardware

Virtually unlimited

Downtime

Often requires downtime

Can be done without downtime

Cost

Can be expensive for high-end hardware

Can use cheaper, commodity hardware

Examples in Database Systems

Vertical Scaling:

  • Upgrading a MySQL database server:
    • Increase RAM from 16GB to 64GB
    • Upgrade CPU from 4 cores to 16 cores
    • Expand storage from 1TB to 4TB SSD

Horizontal Scaling:

  • Implementing a MongoDB cluster:
    • Start with one MongoDB server
    • Add more servers to the cluster
    • Distribute data across multiple servers
    • Use a load balancer to distribute requests

When to Use Each

Use Vertical Scaling When:

  • You have a smaller application with predictable growth
  • You need a quick, simple solution
  • Your application isn't designed for distributed computing

Use Horizontal Scaling When:

  • You expect rapid, unpredictable growth
  • You need high availability and fault tolerance
  • Your application can be easily distributed

Comments

Popular posts from this blog

ORACLE Express Edition: Getting Started

1. Introduction to Oracle Database 21c Express Edition (XE) - Free, lightweight version of Oracle Database - Ideal for learning and small-scale applications - Limited to 12GB of user data and uses up to 2GB of RAM 2. Installation and Setup 2.1 Installing Oracle 21c XE 1. Download Oracle 21c XE from: https://www.oracle.com/database/technologies/xe-downloads.html 2. Run the installer:    - Windows: Double-click the .exe file    - Linux: Use `rpm` or `yum` command 3. Follow the installation wizard:  Accept the license agreement Choose an installation location (default is usually fine) Set a password for the SYS, SYSTEM, and PDBADMIN accounts (write this down!) Select the option to start the database service automatically (recommended)  4. Complete the installation: Wait for the installation process to finish Note down the database connection details provided at the end The default container database (CDB) name is XE The default pluggable database (PDB) nam...

Practical 1: Getting Started with MYSQL

 Getting Started with MySQL Introduction to MySQL Definition: MySQL is an open-source relational database management system (RDBMS) Uses: Web applications, data warehousing, e-commerce, logging applications Key features: Speed, reliability, scalability, and ease of use Installing MySQL Download MySQL Community Server from official website Follow installation wizard for your operating system Set root password during installation Verify installation: mysql --version MySQL Command-line Client Accessing MySQL: mysql -u root -p Basic commands: SHOW DATABASES ; CREATE DATABASE mydb ; USE mydb ; SHOW TABLES ; MySQL Workbench Introduction: Visual tool for database design and management Key features: SQL development Data modeling Server administration Example: Creating a new connection New Connection > Enter details (hostname, username, password) PHPMyAdmin Web-based MySQL administration tool Often comes pre-installed with web hosting packag...

MYSQL Constraints

 PK - Primary Key: Uniquely identifies each record in a table. NN - Not Null: Ensures a column cannot have a NULL value. UQ - Unique: Ensures all values in a column are different. B - Binary: Stores binary byte strings. UN - Unsigned: For numeric types, allows only non-negative values. ZF - Zero Fill: Pads numeric values with zeros to the left. AI - Auto Increment: Automatically generates a unique number for new records. G - Generated Column: Value is computed from an expression. PK - Primary Key A primary key uniquely identifies each record in a table. It must contain unique values and cannot have NULL values.  Example: CREATE TABLE Students ( StudentID INT PRIMARY KEY , Name VARCHAR ( 50 ) , Age INT ) ; Here, StudentID is the primary key. NN - Not Null  This constraint ensures that a column cannot have NULL values.  Example: CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY , Name VARCHAR ( 50 ) NOT NULL , Email VA...