Cloud
Cloudflare
A global network with CDN, DNS, DDoS protection, plus Workers, R2 and D1 for running apps at the edge.
What it is
Cloudflare started as a CDN and DNS proxy with DDoS protection and is now a full platform. Your domain's traffic passes through its network spread across hundreds of cities, where it is cached, filtered and accelerated.
Beyond the network there is a developer platform: Workers (code at the edge), R2 (S3-compatible storage with no egress fees), D1 (a SQLite database), KV, Queues, Pages.
The free tier is generous, so Cloudflare often sits in front of sites of any size as DNS, CDN and WAF.
Use it when
- You need CDN, DNS and protection against DDoS and bots for a site.
- You want to run code close to users with minimal latency (Workers).
- You serve many files and egress fees in other clouds are costly (R2).
- You need Zero Trust access to internal apps without a VPN.
Avoid it when
- You need long-running computation or heavy databases: these are not general-purpose virtual machines.
- Compliance forbids routing traffic through a third-party proxy.
- The app relies heavily on Node.js APIs that are not available in the Workers runtime.
Key concepts
- Anycast CDN
- A request lands on the nearest network node, where a cached copy is served or code runs.
- Proxy (orange cloud)
- A mode where a DNS record is proxied through Cloudflare: it hides the server IP and enables cache and WAF.
- WAF
- Web Application Firewall: rules against SQL injection, bots and suspicious requests.
- R2
- Object storage with an S3-compatible API and zero egress fees.
- Tunnel
- Cloudflare Tunnel exposes an internal service through an outbound connection, with no open ports.
Example
Interview questions
1. What does a CDN do and why is it needed?
A CDN keeps copies of static files on nodes closer to users, so responses arrive faster and the origin has less load. It also absorbs part of DDoS traffic.
2. How do Workers differ from AWS Lambda?
Workers run on V8 isolates at the network edge and start with almost no cold start. Lambda runs a containerized environment in one region but supports more languages and longer executions.
3. Why is R2 interesting compared with S3?
It is compatible with the S3 API but charges no egress fees. For projects that serve many files this can cut the bill a lot.
Interview questions from the bank
- What does a CDN provide, and what should you cache on it?JuniorFrontend performance
- How do you improve LCP?MiddleFrontend performance
- How do you configure HTTP caching for static assets and HTML?MiddleFrontend performance
- How do preload, prefetch, preconnect, and dns-prefetch differ?MiddleFrontend performance
- What did HTTP/2 and HTTP/3 change for loading optimization?MiddleFrontend performance
- How does a Service Worker help with performance, and what caching strategies exist?SeniorFrontend performance
- Estimate on a napkin: 10 million DAU, each makes 50 requests per day, 10% of requests are writes of 1 KB, the average response is 5 KB. Compute average and peak QPS, data volume per year and outgoing traffic. How many Node processes and servers do you need?MiddleSystem design
- After upload a file must be checked with an antivirus, images need three thumbnails, and videos need a preview. ClamAV scans tens of MB/s per core, while ffmpeg on video works for minutes. Design this pipeline and the serving: where the queues are, how to keep video from blocking images, when a file becomes available and how to serve 20 Gbit/s of downloads.SeniorSystem design
Related technologies
- Cloudflare WorkersA serverless platform on Cloudflare's edge: V8 isolate code starts almost instantly worldwide.
- AWSThe largest cloud platform, with hundreds of services from virtual machines and storage to databases, queues and ML.
- HetznerA German provider with very good-value VPS, dedicated servers and a simple cloud API.
- CaddyCaddy is a web server and reverse proxy written in Go with automatic HTTPS and very simple configuration.
- nginxnginx is a fast web server and reverse proxy that also works as a load balancer and HTTP cache.
- TerraformTerraform is an infrastructure as code tool: you describe cloud resources in configuration and it creates and changes them.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).