Guide contents

Lesson 3 of 129

Functional and Non-Functional Requirements

Requirements define what a system must do and how well it must do it. Functional requirements describe behavior: the operations users and other systems can perform. Non-functional requirements (also called quality attributes) describe measurable properties of that behavior: how fast, how available, how consistent, how durable, how secure. Architecture is driven mostly by the non-functional requirements, because many designs can satisfy the same functional list.

Functional requirements

A functional requirement names an actor, an action, and a result: "a user posts a message and followers see it in their feed".

Guidelines for gathering them:

  • Write them as short verbs plus nouns: create link, follow user, upload file, search product.
  • Prioritize. Keep the two to four core flows and state the rest as out of scope.
  • Identify actors: end users, administrators, other services, external partners.
  • Identify the read and write operations separately, since they usually scale differently.
  • Ask about data lifetime: is data kept forever, or deleted after a retention period?
flowchart TD
    P["Vague prompt"] --> Q["Clarifying questions"]
    Q --> F["Functional list: core flows"]
    Q --> N["Non-functional targets"]
    Q --> O["Out of scope"]
    F --> D["Design"]
    N --> D

Non-functional requirements

Attribute Definition Typical way to state it
Latency Time to complete one request. "p99 read latency under 200 ms".
Throughput Amount of work completed per unit time. "50,000 requests per second at peak".
Availability Fraction of time the system serves requests correctly. "99.99 percent monthly".
Consistency Whether all clients see the same data at the same time. "Reads see the latest write" or "eventual".
Durability Committed data is not lost. "No acknowledged write is lost after a single node failure".
Scalability Ability to handle growth by adding resources. "Support 10 times current users".
Security Confidentiality, integrity, access control. "Data encrypted at rest and in transit".
Maintainability Cost of operating and changing the system. "Deployments without downtime".

Latency and throughput

Latency is measured per request and reported as percentiles: p50 (median), p95, p99. Averages hide slow requests, so percentiles are used. A p99 of 200 ms means 99 percent of requests complete within 200 ms and 1 percent are slower. Fan-out amplifies the tail: if a request calls 100 backends in parallel and each backend is slow on 1 percent of calls, the probability that at least one call is slow is 1 - 0.99^100, about 63 percent. Throughput is measured in requests per second (QPS) or bytes per second. The two are related but not interchangeable: batching increases throughput and typically increases latency for individual items.

Availability

Availability is the fraction of time a service is operational. It is expressed in "nines":

Availability Downtime per year (approx.)
99 percent 3.65 days
99.9 percent 8.8 hours
99.99 percent 52.6 minutes
99.999 percent 5.3 minutes

The requirement should state which operations must stay available. Redirects in a URL shortener may need 99.99 percent, while link creation may tolerate less.

Consistency

Consistency here means whether reads reflect the most recent writes across replicas. Strong consistency means every read returns the latest acknowledged write. Eventual consistency means replicas converge if writes stop, but reads may return stale data in the meantime. Financial balances and inventory counts commonly require strong consistency. Like counts and feed ordering commonly tolerate eventual consistency. See consistency models for precise definitions.

Durability

Durability means an acknowledged write survives failures. It is achieved by writing to non-volatile storage (a write-ahead log) and replicating to more than one machine or failure domain before acknowledging. Durability is separate from availability: a system can be down and still not have lost data.

Scalability

State the expected growth: users, requests, data volume, over a time horizon. This determines whether the design must be partitioned from the start or can begin on a single primary database.

Security

Ask what must be protected and from whom: authentication, authorization, encryption of data in transit and at rest, audit logging, and regulatory constraints such as data residency.

Trade-offs between attributes

Non-functional requirements conflict. Stating a target for each makes the conflicts visible.

Conflict Reason Example
Consistency vs availability During a network partition a replicated system must reject some requests or serve possibly stale data. See CAP theorem and PACELC. A bank ledger rejects writes; a social feed serves stale data.
Consistency vs latency Synchronous replication waits for remote replicas. Cross-region synchronous commits add round-trip time.
Durability vs write latency Flushing to disk and replicating before acknowledgment takes time. Acknowledging after fsync versus after memory write.
Latency vs throughput Batching improves throughput and delays individual items. Message batching in producers.
Cost vs availability Each extra nine requires more redundancy. Multi-region active-active deployment.
Security vs latency Encryption, authentication, and checks add work per request. TLS handshake on new connections.

Worked example: photo feed

Prompt: "design a photo-sharing feed". Clarifying answers produce the following list.

Category Requirement
Functional (in scope) Upload a photo; follow a user; view a feed of followed users' photos.
Out of scope Direct messages, ads, photo editing.
Latency Feed load p99 under 500 ms.
Availability Feed reads 99.9 percent monthly; uploads may degrade during incidents.
Consistency A new photo may appear in followers' feeds after several seconds (eventual). The uploader sees their own photo immediately.
Durability An acknowledged upload is never lost.
Scale 100 million daily active users, 10 to 1 read/write ratio.

Each row maps to a decision. Eventual consistency for feeds permits precomputed feeds and asynchronous fan-out through a queue. Durability of uploads requires replicated object storage before acknowledgment. The 99.9 percent target on reads permits a monthly downtime budget of about 43 minutes, which requires redundancy but not multi-region active-active deployment.

Turning requirements into design decisions

  • Read-heavy with relaxed consistency: caching, read replicas, CDN.
  • Write-heavy: partitioning, log-structured storage, asynchronous processing through queues.
  • Strict consistency on a small dataset: a single leader with synchronous replicas or a consensus-based store.
  • High availability: redundancy at every layer, no single points of failure, health checks and failover.
  • Low latency for global users: data and compute placed near users, caching at the edge.

Interview questions

  • Why are non-functional requirements more important than functional ones for architecture? Functional requirements determine which operations exist. Non-functional requirements determine the load, the failure tolerance, and the data guarantees, which decide storage, replication, and partitioning choices.
  • Why use percentiles instead of average latency? A small fraction of slow requests is invisible in the mean but affects users, particularly when a request fans out to many backends and the slowest response determines total latency.
  • What is the difference between availability and durability? Availability is whether the service responds now. Durability is whether committed data persists. A system can be unavailable temporarily without losing data.
  • How should conflicting requirements be handled? State the priority explicitly per operation. For example, choose strong consistency for payments and eventual consistency for view counts within the same product.