How an app is built from parts, how the web carries a request, and what makes a site fast.
Lectures this week
- What is an App?
- Components of an App
- Client-Server and Peer-to-Peer Architecture
- Software Architectures
- Introduction to the Web
- How does the Web work?
- Simple Web Server
- What is a Protocol?
- Performance of a Website
Key points, notes and past questions
Web Architecture, Protocols & Rendering
The HTTP request cycle, statelessness, rendering location and scaling vocabulary.
- The request cycle and HTTP methods
- DNS first: the name becomes an IP address.
- Then request, response (or error code), and display.
- GET returns headers and body; HEAD returns headers only.
- MVC is a software architecture pattern; IP addresses and routes data.
- Statelessness and cookies
- Stateless: the server keeps no client state between requests.
- A cookie is stored by the browser and sent back with each request.
- Cookies let sites recognise users and remember login, language, location.
- Flask reads cookies with
request.cookiesand sets them withset_cookie.
- Server-side and client-side rendering
- SSR: the server sends complete HTML (Flask + Jinja2).
- CSR: the server sends a skeleton and JS; the browser builds the DOM.
- SSR: faster first load, better SEO.
- CSR: less server rendering work, smoother partial updates.
- Cloud models and scaling
- IaaS: machines; PaaS: platform (bring code); SaaS: finished app.
- Scale up = bigger machine (RAM); scale out = more machines.
- ACID for financial transactions; BASE for social media scale.
- Redundancy = spares for failure; replication = copies of data/service.
Notes11 past questions in this topic
System Performance, Hardware & Encoding
The numbers behind encoding, time, disks, memory and server capacity.
- Start here: units from zero
- 8 bits = 1 byte; small b is bits, capital B is bytes.
- k, M, G go up by 1000 (1024 only when stated).
- rate × time = amount; amount ÷ rate = time.
- Convert to one unit before you divide.
- Bits for a character set
- Bits per symbol = ⌈log₂ k⌉.
- The space is a symbol.
- Size = length × bits per symbol.
- Adding symbols changes only the bits per symbol.
- Running time: plug in and scale
- Given n: compute both.
- Scale: × f(n₂)/f(n₁).
- n²: square the ratio; n log n: ratio × log ratio.
- Constants decide below the break-even n.
- Memory hierarchy and disks
- Register → SRAM → DRAM → SSD → HDD: slower and bigger.
- HDD: highest latency, lowest throughput.
- rev/s = RPM ÷ 60.
- Worst delay = one turn; average = half.
- DRAM bandwidth
- 64 bits = 8 bytes.
- DDR × 2, dual channel × 2.
- Use only the factors the question states.
- Recompute when one number changes.
- Propagation and processing delay
- Time = distance ÷ speed.
- Cable 2 × 10^8 m/s, air 3 × 10^8 m/s.
- Add each leg and the server delay.
- Closer servers cut latency.
- Server capacity
- Bits = bytes × 8.
- Network limit = link ÷ bits per request.
- Answer = the smallest limit.
- Memory: peak users × memory per user.