JSTAcademy
0 XP
Dashboard
Technology
Cloud Infrastructure
18 min
Next-Gen AI+190 XP
Technology · Next-Gen AI

Cloud Infrastructure

Servers, CDNs, edge computing, and what "serverless" actually means
18 min read+190 XP on completionCert: Technology
Tap any word in the text below to start reading from there.

Cloud Infrastructure

Modern software does not run on hardware you own it runs on compute, storage, and networking resources rented from cloud providers on demand. Understanding cloud infrastructure means understanding what you are paying for, how to architect for reliability and cost efficiency, and what trade-offs the new abstractions (containers, serverless, edge) make.

The Cloud Provider Landscape

Three hyperscalers dominate: AWS (~33% market share), Azure (~23%), and Google Cloud (~11%). The remainder is split among Cloudflare Workers, Vercel, Railway, Render, and regional providers.

For most product companies, the practical choice is:

  • AWS: maximum service breadth, best for teams with dedicated DevOps. Higher complexity.
  • Vercel: best developer experience for Next.js/React applications. Higher per-unit cost at scale.
  • Railway/Render: best for simple container deployments without DevOps overhead.
  • Cloudflare Workers: edge-first serverless with the world's largest CDN backbone. Sub-millisecond cold starts globally.

The compute hierarchy (from most control to least):

  1. Bare metal: you rent physical servers no virtualization overhead, maximum performance, minimum flexibility
  2. Virtual machines: isolated OS instances on shared hardware flexible, slow to provision, billed per hour
  3. Containers: packaged app processes on shared OS kernels fast to start, portable, billed per use
  4. Serverless functions: event-triggered code with no infrastructure management automatic scaling, billed per invocation
  5. Edge functions: serverless run at CDN nodes globally lowest latency possible, most constrained runtime (limited CPU time, no persistent connections)

How CDNs Work

Without a CDN: a user in Japan requests your app's logo. The request travels to your origin server in Virginia (150ms round-trip), the server reads the file from disk, and returns it over the same slow path.

With a CDN: the first request for that logo is a cache miss same 150ms. But the CDN node in Tokyo now has the file. Every subsequent user in Asia gets it from Tokyo in 5ms. Cache hit rates of 90%+ mean your origin server handles only a small fraction of total traffic.

CDN caching rules:

  • Cache static assets aggressively (images, fonts, JS bundles): set Cache-Control: max-age=31536000, immutable
  • Cache dynamic pages conservatively or not at all: use Cache-Control: no-store or short TTLs
  • Use content-addressed filenames (/app.a3b4c5d.js) so cache busting happens automatically when content changes

Serverless Trade-offs

Advantages:

  • No server provisioning or management
  • Automatic scaling from zero to millions of requests
  • Pay per invocation (often near-zero cost for low-traffic apps)
  • Built-in high availability (multiple AZ deployment by default)

Disadvantages:

  • Cold starts: the first invocation after an idle period spins up a new container (50–400ms for Node.js, up to 2s for JVM). Users on cold start paths experience latency spikes.
  • Execution time limits: AWS Lambda max 15 minutes, Vercel Edge Functions max 30 seconds
  • Statelessness: every invocation starts fresh no in-memory cache persistence between calls
  • Vendor lock-in: serverless APIs (AWS Lambda event format, Vercel Edge Functions) are not portable

The pattern for reducing cold starts: keep functions warm by pinging them every 5 minutes, use provisioned concurrency (paying to keep N instances always warm), or use edge functions which have near-zero cold start times.

Object Storage vs. Block Storage vs. File Storage

Object storage (AWS S3, Cloudflare R2, Supabase Storage): store and retrieve files by key over HTTP. No file system interface. Horizontally limitless. Best for: user uploads, backups, static assets, media files. S3 Standard costs ~$0.023/GB/month.

Block storage (AWS EBS, Hetzner volumes): a virtual disk attached to a VM. Has a file system, supports random read/write. Best for: databases, application code on VMs. Must be in the same region as the VM.

File storage (AWS EFS, NFS): a file system shared across multiple servers. Best for: shared configuration, content that multiple app servers must read simultaneously.

Infrastructure as Code

Clicking through a cloud console to configure your production infrastructure is like deploying code by copying files via FTP it works until you need to reproduce it. IaC (Terraform, Pulumi, AWS CDK) defines infrastructure in code that is:

  • Version-controlled: every change to infrastructure is tracked in git with author and timestamp
  • Reproducible: create an identical staging environment from the same code
  • Auditable: security and compliance teams can review infrastructure changes via pull requests
  • Recoverable: if a region fails, spin up in a new region from the same IaC in minutes

Pulumi uses general-purpose languages (TypeScript, Python, Go), making it accessible to engineers who do not want to learn Terraform's HCL syntax.

Cost Optimization Patterns

Cloud bills grow exponentially without active management. The top cost drivers and their mitigations:

  • Idle VMs: right-size instances; use spot/preemptible instances for batch workloads (60–80% cheaper)
  • Egress fees: AWS charges $0.09/GB for data leaving AWS. CDN-cached content pays the CDN's lower egress rate. Cloudflare R2 charges $0 egress, making it materially cheaper than S3 at high egress volume.
  • Unused resources: orphaned load balancers, snapshots, and public IPs accumulate unnoticed. Run cost-anomaly detection (AWS Cost Explorer) with alerts on weekly spend increases >20%.
0%