Untitled

Chapter 2: Defining Nonfunctional Requirements

The Nature of the Internet as a Resource

  • The Internet is often perceived as a natural resource (like the Pacific Ocean) due to its scale and reliability rather than a man-made technology.
  • Alan Kay observed that it exhibits an unprecedented level of error-free operation compared to other technologies.

User Interaction on a Social Network

  • Daily Activity Stats:
    • 500 million posts per day.
    • Average of 5,800 posts per second.
    • Spikes can reach 150,000 posts per second.
  • User Dynamics:
    • Average user follows 200 accounts and has 200 followers, although many have significantly fewer, with celebrities having up to 100 million followers.

Database Representation of Users and Posts

Schema Overview
  • Expectation includes three tables:
    • Users table
    • Posts table
    • Follows table
  • Main Functionality: Home timeline displaying posts from followed users, NO ads or non-followed content included for simplicity.
SQL Query Example
  • To generate a home timeline for a particular user, the SQL command is:
  SELECT posts.*, users.* 
  FROM posts 
  JOIN follows ON posts.sender_id = follows.followee_id 
  JOIN users ON posts.sender_id = users.id 
  WHERE follows.follower_id = current_user 
  ORDER BY posts.timestamp DESC 
  LIMIT 1000
  • Explanation: This command retrieves relevant posts by filtering who the current user follows, sorting by the most recent timestamps.

Fan-out Concept in Data Processing

  • Definition of Fan-out: Refers to the number of resultant requests generated from a single initial request.
  • Example Calculation:
    • At a rate of 5,800 posts per second, a typical post reaching 200 followers results in:
      5,800extposts/secondimes200extfollowers/posto1,160,000exttimelinewrites/second5,800 ext{ posts/second} imes 200 ext{ followers/post} o 1,160,000 ext{ timeline writes/second}
    • Reduction from 400 million lookups per sender to 1 million writes considerably enhances efficiency.
Handling Load Spikes
  • During surges in posting activity, posts can be queued for later timeline updates. Even under heavy load, timelines remain efficient by using cached data.
  • For celebrity accounts with vast followings, optimizations depend on merging these posts into materialized timelines accordingly.

Performance Characteristics

Response Time Management
  • The response time for services generally declines as user load increases, due to:
    • Inherent system delays,
    • Temporary halts on error-prone services to prevent overload (using circuit breakers or load shedding).
  • Performance Metrics:
    • Response time primarily affects user perception, while throughput determines resource allocation and costs associated with service operation.
    • A scalable system is defined as one whose throughput can grow by adding more computational resources.

Statistical Analysis of Response Times

  • Latency Representation:
    • Illustrative diagrams show the flow of requests and responses through the system, highlighting typical response times versus outliers.
  • Users show varying tolerance towards delays; for example:
    • Significant Findings:
      • A 400 ms latency increase can decrease daily search volume by 0.6% (Google: 2009).
      • A 2-second load time increase could reduce ad revenue by 4.3% (Bing: 2009).
Insights into Tail Latency
  • Tail Latency Amplification: When an end-user request necessitates multiple back-end calls, any slow request significantly impacts the overall request time, leading to wider implications on user experience.

Service Level Objectives (SLO) and Agreements (SLA)

  • SLO Definition:
    • Specifies target metrics for system operation (e.g., median response time < 200 ms, 99th percentile < 1 second).
  • SLA Definition:
    • Contracts describing what occurs if SLOs are missed (e.g., user refunds).
    • Challenges arise concerning the establishment of reliable availability metrics.

Reliability, Fault Tolerance, and Definitions

Faults and Failures
  • Fault: A malfunction in a specific system component (e.g., hard drive failure).
  • Failure: Overall system breakdown in providing required service due to faults.
  • Distinction is vital — a fault can exist without being a failure in fault-tolerant systems.
Implementing Fault Tolerance
  • A fault-tolerant system continues to offer services despite faults.
  • Single Point of Failure (SPOF): A component failure leads to total system failure due to lack of redundancy.
  • In managing systems, provisions for every fault type enhance resilience and operational efficiency.
Case Study: Social Network Fault Tolerance
  • In scenarios where the fan-out process fails, redundancy and machine assignment are crucial for uninterrupted service.
Chaos Engineering
  • Practicing fault insertion to strengthen fault tolerance can provide insights into real-world performance under failure conditions.

Hardware and Software Faults

Hardware Faults
  • Hardware is subject to failures (e.g., disk error frequency).
  • Reliability metrics and trends indicate that hardware failures, while becoming less frequent, can still significantly impact performance.
Software Faults
  • Software faults complicate prediction and often lead to greater systemic failures compared to hardware errors.
  • Example faults include faulty algorithms that trigger under certain conditions, impacting overall system performance.
Human Reliability Factors
  • Emergent behaviors can arise within systems due to component interactions and can lead to unforeseen failures.

Principles for Scalability

  • Proper scalability assessment involves understanding aside from performance:
    • Future growth handling strategies,
    • Computing resource enlistment options,
    • Architectural limits concerning growth expectations.
Implementation Strategies
  • Adaptive architectures prioritize adaptability in growth contexts, letting designers address issues as they arise based on real system behavior and demand.
  • Discussing architectures should focus on optimal rather than arbitrary scalability for implementation.

Operability and Complexity Management

Simplifying Maintenance and Operations
  • Simplifying operational processes directly affects the capacity for maintaining extensive systems.
  • Scalable operations involve both automation and manual interventions when necessary for efficient management.
The Role of Automation
  • While vital, increased automation raises complexity in error resolution.
  • Systems should prioritize operability, easing system interaction and management while maintaining efficiency across processes.