Understanding Scalability in System Design: Insights from Harvard CS 75

Shivani Sidigidda
5 min readAug 13, 2024

--

In today’s digital age, scalability is crucial for maintaining a robust and responsive web application. Based on Lecture 9 of Harvard’s Web Development CS 75 by David Malan, this article delves into key aspects of scalability and system design, exploring web hosting options, scaling strategies, load balancing, RAID configurations, caching, and replication.

Web Hosting and Its Implications

Types of Web Hosts

Web Hosts such as Bluehost, Dreamhost, and GoDaddy offer various levels of service. However, it’s essential to be aware of the features they offer:

  • Accessibility: Some hosts may block access from certain countries or regions, which can affect your global user base.
  • SFTP vs. FTP: For secure file transfers, SFTP (Secure File Transfer Protocol) is preferred over FTP, as it encrypts all traffic, protecting sensitive information such as usernames and passwords.
  • Feature Claims: Be cautious of hosts that offer “unlimited” storage or bandwidth at a low cost. This may indicate that resources are shared among many users, potentially leading to performance issues.

Virtual Private Servers (VPS)

A VPS provides a virtualized operating system on a shared physical machine. This setup offers greater privacy and control compared to standard shared hosting. Examples include AWS EC2, which allows you to scale resources based on demand, paying per minute of usage.

For those requiring even more privacy, operating your own servers might be the solution. This approach ensures that only your team has access to the infrastructure.

Dedicated Servers

For maximum privacy and control, operating your own servers is ideal. This setup is more expensive but ensures that only you and your team have access to your data and infrastructure.

Scaling Techniques

Vertical Scaling

Vertical Scaling involves adding more resources (e.g., CPU, RAM, disk space storage) to a single machine. While straightforward, this approach can become costly and has limitations based on the maximum capacity of the hardware.

Horizontal Scaling

Horizontal scaling, on the other hand, involves adding more machines to handle increased load. This approach uses multiple servers to distribute the workload.

Load Balancing

Load Balancing

Purpose and Implementation

A load balancer distributes incoming HTTP requests across multiple servers. It has a public IP address, while the servers have private IP addresses, enhancing security. With IPv4 addresses becoming scarce, this method helps manage IP allocation efficiently.

Load Balancing Techniques

  1. Round Robin: Distributes requests in a rotating manner across servers. However, it might lead to uneven distribution of workload, where some servers handle more intensive tasks than others.
  2. DNS Load Balancing: Uses DNS to rotate between different server IP addresses. This approach can lead to issues with session consistency, as users may be directed to different servers on subsequent requests.

RAID Configurations

RAID (Redundant Array of Independent Disks) provides redundancy and performance improvements:

  • RAID 0: Stripes data across multiple disks for faster performance but lacks redundancy.
  • RAID 1: Mirrors data across disks, providing redundancy in case of disk failure.
  • RAID 10: Combines RAID 0 and RAID 1 for both performance and redundancy. Requires at least four disks.
  • RAID 5: Uses parity for redundancy with less overhead than RAID 1. Requires at least three disks.
  • RAID 6: Similar to RAID 5 but with dual parity for higher fault tolerance. Requires at least four disks.

Session Management and Load Balancing

Session Stickiness

Maintaining user sessions across multiple servers can be challenging. Here are two common approaches:

  • Shared Storage: Stores session data on a centralized server or database, which can be accessed by all servers. This approach requires robust backup and redundancy solutions.
  • Cookies: Stores session identifiers in cookies to direct requests to the appropriate server. Be cautious of exposing private IP addresses through cookies.

Caching Strategies

Caching improves performance by reducing the need to reprocess or retrieve data:

  • HTML Caching: Caching HTML files reduces database load and speeds up page delivery but requires careful management to ensure updates are reflected across all cached pages.
  • MySQL Caching: MySQL can cache results of queries to improve performance. However, managing cache sizes and expiration times is crucial to prevent stale data.
  • Memcached: Memcached stores expensive results in memory with expiration times. It can handle large cache sizes but may require careful management to avoid excessive memory usage.

Replication

Master-Slave Replication

In this setup, the master database handles all writes and reads, while slave databases replicate the master’s data. This configuration improves read performance and provides redundancy, though writes are still a single point of failure.

Upsides of Master-Slave Replication:

  1. Read Scalability: Distributes read queries across multiple slaves, reducing the load on the master and improving performance for read-heavy applications.
  2. Redundancy: If the master database fails, slaves can continue to provide read access, increasing overall system availability.
  3. Backup and Recovery: Slaves can be used for backups without impacting the master’s performance, allowing for more efficient data recovery processes.
Master-Slave

Master-Master Replication

Allows writes to be performed on either of two master databases, with changes replicated to the other. This approach simplifies write operations but requires careful conflict resolution.

Master-Master

Load Balancing and Replication

Active-Active

Both load balancers are operational and handle incoming traffic, improving availability and reliability. They communicate regularly to ensure they are in sync.

Active-Passive

One load balancer handles all traffic, with the second taking over if the primary fails. This setup ensures failover capability but requires effective failover mechanisms.

High Availability

Combining redundant load balancers and master databases replicating each other ensures high availability and resilience against failures.

Conclusion

Understanding scalability involves a comprehensive approach to designing systems that can handle growing demands efficiently. By leveraging appropriate web hosting options, scaling strategies, load balancing techniques, RAID configurations, and caching mechanisms, you can build robust systems capable of delivering reliable performance even as usage scales.

If this article helped you in some way, don’t forget to 👏 👏 👏 it.

--

--