Sign in

Architecting for non-functional requirements: scalability, availability, reliability, and performance

Master the principles of non-functional requirements to design software systems that handle high traffic, withstand node outages, and maintain low latency.

MonksBit Desk

November 18, 2026 · 8 min read · 180 views

Read

Non-functional requirements are operational criteria that define how a software system executes rather than what specific behaviors it performs. They specify constraints on system attributes such as scalability, availability, reliability, and performance under varying workloads and fault conditions.

You will need. Basic understanding of client-server network architecture · Familiarity with algorithm time and space complexity · Basic knowledge of multithreading or asynchronous programming

How well do you know this already?

The full lesson

Level 1 · Beginner: Understanding core non-functional metrics through request-response measurement

Software requirements split into two categories: functional requirements describe what features a system provides, such as creating a user account or computing an invoice total; non-functional requirements specify operational qualities such as response time, uptime, and load capacity.

Performance measures how efficiently a system handles operations, typically captured via latency (the time taken to complete a single unit of work) and throughput (the number of units completed per unit time). Latency is measured in units like milliseconds, while throughput is measured in requests per second.

Reliability and availability evaluate operational health. Reliability measures the probability that a system performs without failure over a stated period. Availability is the fraction of total scheduled time during which the system is operational and accessible to callers.

To understand these concepts concretely, consider a single service measuring its own latency and success rate under sequential mock operations. By tracking elapsed execution time and execution outcomes, we compute baseline performance and availability indicators.

Basic telemetry probe measuring latency and availability rate

import timedef execute_task(task_id: int) -> bool:    # Simulate variable latency and occasional node failure    if task_id % 5 == 0:        return False    time.sleep(0.01)    return Truedef run_benchmark(total_requests: int):    latencies = []    successful_requests = 0        start_time = time.perf_counter()    for i in range(total_requests):        req_start = time.perf_counter()        success = execute_task(i)        req_end = time.perf_counter()                latencies.append(req_end - req_start)        if success:            successful_requests += 1                total_time = time.perf_counter() - start_time    availability = (successful_requests / total_requests) * 100    throughput = total_requests / total_time    avg_latency_ms = (sum(latencies) / len(latencies)) * 1000        print(f"Availability: {availability:.2f}%")    print(f"Throughput: {throughput:.2f} req/s")    print(f"Average Latency: {avg_latency_ms:.2f} ms")if __name__ == '__main__':    run_benchmark(20)

Key takeaways

  • Functional requirements define capabilities; non-functional requirements govern system execution parameters.
  • Performance is quantified primarily through throughput (work over time) and latency (duration per task).
  • Availability reflects operational uptime percentage, while reliability measures failure-free execution integrity.

Level 2 · Intermediate: Designing for reliability and scale with retries, exponential backoff, and load balancing

Scaling is the capacity to handle increased load. Vertical scaling increases resources on a single machine, while horizontal scaling distributes load across multiple machines. Horizontal scaling requires load distribution algorithms such as round-robin or least-connections.

Reliability in distributed environments necessitates handling transient failures. A node might momentarily fail to respond due to network congestion or high load. Naive immediate retries can trigger a thundering herd problem, overwhelming the struggling dependency.

The standard algorithmic mitigation for transient errors is exponential backoff with jitter. Backoff exponentially widens the wait interval between attempts, while jitter adds bounded randomness to desynchronize concurrent retried requests.

We implement a load-balanced round-robin dispatcher combined with a resilient retry handler, demonstrating how software mechanisms directly preserve availability and reliability when facing underlying node disruptions.

Round-robin load balancer with retry policies and exponential backoff

import timeimport randomfrom typing import List, Optionalclass ServerNode:    def __init__(self, node_id: str, failure_rate: float = 0.0):        self.node_id = node_id        self.failure_rate = failure_rate    def process_request(self, payload: str) -> str:        if random.random() < self.failure_rate:            raise ConnectionError(f"Node {self.node_id} failed to process request")        return f"Ack from {self.node_id}: {payload}"class LoadBalancer:    def __init__(self, nodes: List[ServerNode]):        if not nodes:            raise ValueError("Server pool cannot be empty")        self.nodes = nodes        self._index = 0    def next_node(self) -> ServerNode:        node = self.nodes[self._index]        self._index = (self._index + 1) % len(self.nodes)        return nodedef invoke_with_retry(lb: LoadBalancer, payload: str, max_retries: int = 3) -> Optional[str]:    base_backoff_sec = 0.05    for attempt in range(max_retries):        node = lb.next_node()        try:            return node.process_request(payload)        except ConnectionError:            if attempt == max_retries - 1:                raise            backoff = (base_backoff_sec * (2 ** attempt)) + random.uniform(0, 0.02)            time.sleep(backoff)    return Noneif __name__ == '__main__':    pool = [ServerNode("A", failure_rate=0.7), ServerNode("B", failure_rate=0.1)]    router = LoadBalancer(pool)    for req_id in range(5):        try:            res = invoke_with_retry(router, f"request_{req_id}")            print(f"Success: {res}")        except ConnectionError as err:            print(f"Dropped request: {err}")

Key takeaways

  • Horizontal scalability distributes computational demand across stateless replicated nodes.
  • Exponential backoff spreads retry attempts over geometric time windows to avoid overwhelming failing dependencies.
  • Jitter introduces non-deterministic sleep offsets to prevent correlated client retry waves.

Level 3 · Advanced: Fault domain isolation, circuit breakers, and tail latency engineering

In distributed microservices, failing components can consume resources indefinitely on calling nodes, exhausting thread pools and causing cascading system-wide outages. Ensuring high availability requires defensive design patterns like circuit breakers and bulkheading.

A circuit breaker monitors consecutive failures. In the Closed state, traffic passes normally. If the failure threshold is crossed, the breaker trips to Open, instantly rejecting requests without consuming downstream resources. After a cooldown reset period, it enters Half-Open, admitting a canary request to test recovery.

High performance at scale is governed by tail latency rather than median latency. The 99th and 99.9th percentiles (p99 and p99.9) represent the slowest experiences that, in multi-fan-out architectures, dominate overall request duration. For example, a request that gathers responses from 100 backend servers will be delayed if even one backend hits its p99 latency.

Optimizing non-functional trade-offs involves navigating the CAP theorem and the PACELC extension: choosing between consistency, latency, and availability under partition and normal operating states.

Thread-safe circuit breaker state machine for availability preservation

import timefrom enum import Enumfrom threading import Lockclass BreakerState(Enum):    CLOSED = 1    OPEN = 2    HALF_OPEN = 3class CircuitBreaker:    def __init__(self, failure_threshold: int = 3, recovery_time_sec: float = 2.0):        self.failure_threshold = failure_threshold        self.recovery_time_sec = recovery_time_sec        self.failure_count = 0        self.state = BreakerState.CLOSED        self.last_state_change = time.time()        self.lock = Lock()    def allow_request(self) -> bool:        with self.lock:            now = time.time()            if self.state == BreakerState.OPEN:                if now - self.last_state_change > self.recovery_time_sec:                    self.state = BreakerState.HALF_OPEN                    self.last_state_change = now                    return True                return False            return True    def record_success(self):        with self.lock:            self.failure_count = 0            self.state = BreakerState.CLOSED    def record_failure(self):        with self.lock:            self.failure_count += 1            if self.failure_count >= self.failure_threshold:                self.state = BreakerState.OPEN                self.last_state_change = time.time()def protected_call(breaker: CircuitBreaker, action, *args, **kwargs):    if not breaker.allow_request():        raise RuntimeError("Circuit breaker is OPEN. Request rejected fast.")    try:        result = action(*args, **kwargs)        breaker.record_success()        return result    except Exception as exc:        breaker.record_failure()        raise exc

Key takeaways

  • Circuit breakers protect services from cascading failures by failing fast during degradation.
  • System latency in distributed topologies is constrained by tail latency percentiles (p95, p99, p99.9).
  • Trade-offs between performance, consistency, and resilience must be selected based on domain SLA contracts.

Complexity

  • Time: O(1) for dispatch and circuit breaker state evaluation
  • Space: O(N) where N is the number of monitored instances or bounded request buffers

Evaluating request state, round-robin counter increments, and circuit transitions execute in O(1) constant time without scanning unbounded history. Node pools and state tracking structures scale linearly with the number of discrete service instances.

Common mistakes

  • Retrying failures blindly without backoff and jitter, causing self-inflicted denial-of-service through retry storms.
  • Measuring performance using only mean or median latency, obscuring severe tail latency issues impacting edge users.
  • Neglecting timeouts on external network calls, causing unbounded resource starvation and thread pool exhaustion.
  • Treating availability as synonymous with reliability: an available system can return erroneous responses while maintaining 100% uptime.

Practice problems

  1. Throughput and Percentile Calculator (easy). Hint: Collect an array of request response times, sort it, and compute the 50th, 95th, and 99th indices directly.
  2. Token Bucket Rate Limiter (medium). Hint: Track refill rate against elapsed wall-clock time without spawning dedicated timer background threads.
  3. Degraded Graceful Fallback Cache (hard). Hint: Integrate a circuit breaker with a stale-while-revalidate local cache to maintain read availability during outages.

Summary

Non-functional requirements dictate the resilience, scale, and responsiveness of computational systems. Scalability distributes throughput, reliability mitigates errors through disciplined retry and failover strategies, availability safeguards continuous access using circuit breakers, and performance engineering minimizes tail latencies.

Was this helpful?

Comments (0)

Sign in or create an account to join the conversation.

  • No comments yet. Be the first!