🌍 Back-end Web Developement · subject

Back-end Web Developement Performance Optimization Syllabus

The Performance Optimization syllabus for Back-end Web Developement in full: 3 chapters and 9 topics, every one listed below, plus 51 Performance Optimization flashcards with answers.

3Chapters
9Topics
51Flashcards

Performance Optimization syllabus: all 3 chapters

Expand any chapter to see its topics and sub-topics.

  1. Caching

    3 topics
    • Redis
    • Memcached
    • CDN
  2. Load Balancing

    3 topics
    • Round Robin
    • Least Connections
    • IP Hash
  3. Profiling & Monitoring

    3 topics
    • New Relic
    • Prometheus
    • Grafana

Back-end Web Developement Performance Optimization flashcards — 51 questions with answers

  1. What is Redis, and what type of data store is it?

    Redis (REmote DIctionary Server) is an open-source, in-memory data structure store used as a database, cache, and message broker. It keeps data in RAM for microsecond-level access and can optionally persist to disk.

  2. Name five core data structures natively supported by Redis.

    Strings, Lists, Sets, Sorted Sets (ZSets), and Hashes. It also supports Bitmaps, HyperLogLog, Streams, and Geospatial indexes.

  3. What two persistence mechanisms does Redis offer?

    RDB (Redis Database) point-in-time snapshots, and AOF (Append-Only File) which logs every write operation. They can be used separately or together for durability.

  4. Is Redis single-threaded or multi-threaded for command execution?

    Redis executes commands on a single main thread (an event loop), which guarantees atomicity per command. Recent versions add threaded I/O for network reads/writes, but command processing remains single-threaded.

  5. What is Memcached, and what is its primary use case?

    Memcached is an open-source, high-performance, distributed in-memory key-value store designed for caching. Its primary use is to speed up dynamic web applications by caching results of database calls, API calls, or page rendering.

  6. How does Memcached handle threading compared to Redis?

    Memcached is multi-threaded, scaling across multiple CPU cores for high-throughput simple key-value workloads. Redis is (for command execution) single-threaded.

  7. Compare Redis and Memcached on data structures and persistence.

    Redis supports rich data structures (lists, sets, hashes, sorted sets) and offers persistence (RDB/AOF), replication, and clustering. Memcached supports only simple string key-value pairs, is multi-threaded, and offers no persistence or replication.

  8. What eviction algorithm does Memcached primarily use when memory is full?

    LRU (Least Recently Used). Memcached uses a slab allocator and evicts the least recently used items within a slab class when memory limits are reached.

  9. Define the cache hit ratio and give its formula.

    The cache hit ratio is the fraction of requests served from the cache. $$\text{Hit Ratio} = \frac{\text{Cache Hits}}{\text{Cache Hits} + \text{Cache Misses}}$$

  10. Define cache miss ratio in terms of hit ratio.

    $$\text{Miss Ratio} = 1 - \text{Hit Ratio} = \frac{\text{Cache Misses}}{\text{Total Requests}}$$

  11. Give the formula for the effective (average) access time of a two-level system with a cache in front of a slower store.

    $$T_{\text{avg}} = H \cdot T_{\text{cache}} + (1 - H) \cdot T_{\text{store}}$$ where $H$ is the hit ratio, $T_{\text{cache}}$ the cache access time, and $T_{\text{store}}$ the backing-store access time.

  12. What is TTL (Time To Live) in the context of caching?

    TTL is the expiration time assigned to a cached entry. After the TTL elapses, the entry is considered stale and is evicted or refreshed. It bounds data staleness and helps free memory.

  13. Explain the cache-aside (lazy loading) caching pattern.

    The application first checks the cache. On a hit it returns the cached value; on a miss it reads from the database, writes the result into the cache, then returns it. The cache is populated lazily on demand.

  14. Explain the write-through caching strategy.

    In write-through, every write goes to both the cache and the backing database synchronously. This keeps the cache always consistent with the database at the cost of higher write latency.

  15. Explain the write-back (write-behind) caching strategy and its main risk.

    In write-back, writes go to the cache first and are asynchronously flushed to the database later. It gives low write latency and high throughput, but risks data loss if the cache fails before the flush completes.

  16. What is a cache stampede (thundering herd), and one way to mitigate it?

    A cache stampede occurs when a popular key expires and many concurrent requests simultaneously miss and hit the database. Mitigations include request coalescing/locking (only one recompute), staggered TTLs (jitter), or early/probabilistic refresh.

  17. Define cache penetration and how it differs from a stampede.

    Cache penetration is repeated querying for keys that do not exist in cache or database, so every request bypasses the cache and hits the backend. It differs from a stampede (which involves valid but expired keys). Mitigation: cache null results or use a Bloom filter.

  18. What is a CDN and what problem does it solve?

    A CDN (Content Delivery Network) is a geographically distributed network of edge servers that cache and serve content close to end users. It reduces latency, offloads origin servers, and improves availability and throughput for static and cacheable content.

  19. What is an 'edge server' (PoP) in a CDN?

    An edge server, located at a Point of Presence (PoP), is a CDN cache node positioned geographically near end users. It serves cached content locally to minimize round-trip distance to the origin.

  20. How does a CDN reduce latency? Reference the role of distance.

    A CDN reduces the physical distance data travels, lowering propagation delay. Since $t_{\text{prop}} = \frac{d}{v}$ (distance over propagation speed), serving from a nearby edge shortens $d$ and thus round-trip time, in addition to reducing origin load.

Show the other 31 Performance Optimization flashcards
  1. Distinguish a CDN cache HIT, MISS, and origin fetch.

    A HIT means the edge serves content directly from its cache. A MISS means the edge lacks the content, so it fetches from the origin (or an upstream tier), caches it, then serves it. The origin fetch adds latency only on the miss.

  2. What is cache invalidation / purging in a CDN?

    Purging (invalidation) removes or marks stale specific cached objects at the edge so the CDN re-fetches fresh content from the origin. It is used when content changes before its TTL expires.

  3. What HTTP header primarily controls how long a CDN/browser caches an object?

    The Cache-Control header (e.g., max-age, s-maxage, no-cache, private/public). s-maxage specifically targets shared caches like CDNs; Expires and ETag also influence caching and revalidation.

  4. What is load balancing, and why is it needed?

    Load balancing distributes incoming network/application traffic across multiple backend servers. It prevents any single server from being overloaded, improves throughput and response time, and increases availability and fault tolerance.

  5. Describe the Round Robin load-balancing algorithm.

    Round Robin assigns each incoming request to the next server in a cyclic sequence: server 1, 2, 3, ..., n, then back to 1. It distributes requests evenly by count, ignoring current server load or connection count.

  6. For n servers under Round Robin, which server handles request number k (1-indexed)?

    $$\text{server} = ((k - 1) \bmod n) + 1$$ so requests cycle through the servers $1, 2, \dots, n, 1, 2, \dots$

  7. What is the main limitation of plain Round Robin load balancing?

    It assumes all servers have equal capacity and all requests cost the same. It ignores actual load, active connections, and response times, so heterogeneous servers or uneven request costs can cause imbalance.

  8. Describe Weighted Round Robin and its purpose.

    Weighted Round Robin assigns each server a weight proportional to its capacity; higher-weight servers receive proportionally more requests within each cycle. It handles heterogeneous server capacities that plain Round Robin cannot.

  9. In Weighted Round Robin, what fraction of traffic does server i with weight $w_i$ receive?

    $$\text{fraction}_i = \frac{w_i}{\sum_{j=1}^{n} w_j}$$

  10. Describe the Least Connections load-balancing algorithm.

    Least Connections routes each new request to the server currently handling the fewest active connections. It adapts to real-time load and suits long-lived or variable-duration connections better than Round Robin.

  11. When is Least Connections preferable to Round Robin?

    When requests have widely varying durations or resource costs (e.g., long-lived sessions, streaming, WebSockets). Least Connections balances by actual concurrent load rather than raw request count, avoiding pile-up on slow servers.

  12. What is Weighted Least Connections?

    A variant that selects the server minimizing the ratio of active connections to its weight (capacity), i.e., it picks the server with the smallest $\frac{\text{active connections}_i}{w_i}$, combining real-time load with server capacity.

  13. Describe the IP Hash load-balancing algorithm.

    IP Hash computes a hash of the client's source IP address (sometimes source+destination) and uses it to deterministically select a backend server. The same client IP consistently maps to the same server, providing session affinity (sticky sessions).

  14. For IP Hash across n servers, express which server a client is assigned to.

    $$\text{server} = \text{hash}(\text{client IP}) \bmod n$$ mapping the hashed IP deterministically to one of the $n$ servers.

  15. What is the primary advantage and the primary drawback of IP Hash?

    Advantage: session persistence without shared session storage, since a client always reaches the same server. Drawback: uneven distribution if client IPs cluster (e.g., behind NAT/proxies), and remapping when the server count $n$ changes (unless consistent hashing is used).

  16. Why does consistent hashing improve on plain modulo IP Hash when servers are added or removed?

    With plain $\text{hash} \bmod n$, changing $n$ remaps almost all keys. Consistent hashing places servers and keys on a hash ring so that adding/removing a server only remaps about $\frac{1}{n}$ (K/n) of the keys, minimizing cache/session disruption.

  17. Classify Round Robin, Least Connections, and IP Hash as static or dynamic algorithms.

    Round Robin and IP Hash are static (decisions based on fixed rules/hashing, not live server state). Least Connections is dynamic (decisions based on real-time active-connection counts).

  18. What is New Relic, and what category of tool is it?

    New Relic is a commercial SaaS observability and Application Performance Monitoring (APM) platform. It collects metrics, traces, logs, and events from applications and infrastructure to monitor performance, errors, and user experience.

  19. What is Apdex, the score New Relic uses, and give its formula.

    Apdex (Application Performance Index) measures user satisfaction with response times against a target threshold $T$. $$\text{Apdex}_T = \frac{\text{Satisfied} + \frac{\text{Tolerating}}{2}}{\text{Total Samples}}$$ where satisfied requests are $\leq T$, tolerating are $> T$ and $\leq 4T$, and frustrated are $> 4T$.

  20. What is the range of an Apdex score and what does 1 mean?

    Apdex ranges from $0$ to $1$. A score of $1$ means every request was 'satisfied' (all within the target threshold $T$); $0$ means every user was frustrated.

  21. Name three telemetry types (the 'pillars of observability') that platforms like New Relic collect.

    Metrics, Logs, and Traces (often summarized as MELT: Metrics, Events, Logs, Traces). Together they give a full view of system behavior and performance.

  22. What is Prometheus, and what monitoring model does it use?

    Prometheus is an open-source (CNCF) monitoring and alerting toolkit that stores time-series metrics. It uses a pull-based model: the Prometheus server scrapes metrics over HTTP from instrumented targets/exporters at defined intervals.

  23. What query language does Prometheus use, and what is it for?

    PromQL (Prometheus Query Language). It is a functional language for selecting, aggregating, and computing over time-series data to produce graphs, tables, and alerting rules.

  24. Name the four core Prometheus metric types.

    Counter (monotonically increasing), Gauge (can go up or down), Histogram (bucketed observations with counts), and Summary (client-side quantiles). Counters and gauges are scalar; histograms and summaries track distributions.

  25. In PromQL, what does the rate() function compute over a counter, e.g. $\text{rate}(http\_requests\_total[5m])$?

    It computes the per-second average rate of increase of the counter over the specified time window (here 5 minutes), automatically handling counter resets. It answers 'how many requests per second on average.'

  26. What is a Prometheus 'exporter'?

    An exporter is a component that exposes metrics from a third-party system (e.g., databases, hardware, OS) in Prometheus format on an HTTP endpoint so the Prometheus server can scrape them. Example: node_exporter for host metrics.

  27. What component handles alert routing/notification in the Prometheus ecosystem?

    Alertmanager. Prometheus evaluates alerting rules and fires alerts to Alertmanager, which deduplicates, groups, silences, and routes notifications to receivers like email, Slack, or PagerDuty.

  28. What is Grafana, and what is its primary role?

    Grafana is an open-source analytics and visualization platform. It connects to data sources (like Prometheus, Loki, InfluxDB, SQL databases) and renders interactive dashboards, graphs, and alerts. Its main role is visualization, not storage.

  29. How do Prometheus and Grafana typically work together?

    Prometheus collects and stores time-series metrics and is added as a data source in Grafana. Grafana queries Prometheus (via PromQL) to build dashboards and visualizations. Prometheus = collection/storage; Grafana = visualization/dashboards.

  30. Given a service with throughput 500 requests/second and average concurrency (requests in system) of 50, use Little's Law to find the average response time.

    Little's Law: $L = \lambda W$, so $W = \frac{L}{\lambda}$. $$W = \frac{50}{500} = 0.1\ \text{s} = 100\ \text{ms}$$

  31. State Amdahl's Law for speedup and explain what it bounds.

    $$S = \frac{1}{(1 - p) + \frac{p}{s}}$$ where $p$ is the parallelizable/optimizable fraction and $s$ its speedup. It bounds overall speedup: even as $s \to \infty$, $S \to \frac{1}{1-p}$, so the serial fraction limits total performance gains.

Back-end Web Developement Performance Optimization FAQ

What is in the Back-end Web Developement Performance Optimization syllabus?

Back-end Web Developement Performance Optimization is split into 3 chapters: Caching, Load Balancing and Profiling & Monitoring. Together they contain 9 topics.

How many chapters are in Back-end Web Developement Performance Optimization?

3 chapters, containing 9 topics. The largest chapter is Caching, with 3 topics.

Are there flashcards for Back-end Web Developement Performance Optimization?

Yes — a 51-card Performance Optimization deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.