DevConda — blog-workspace

Is EC2 Serverless? S3 and CloudFront vs EC2

Two services do two jobs. Mix them up and “serverless” sounds like marketing. Keep them straight and the rest of this post is obvious.

S3 is object storage. You put files in a bucket: index.html, JavaScript, images. The bucket lives in one AWS region. There is no Linux box for you to patch. There is a disk API. The Vue dist folder from npm run build goes here. In Part 1 this is the origin for the front end.

S3 bucket as origin: index.html and hashed JS in one region
Origin / object storage: the Vue dist lives in one region.

You can host a static site from S3 alone. The objects still sit in that region. S3 does not, by itself, keep copies next to every user. Custom HTTPS and “keep the bucket private, open only the front door” usually belong to the next layer.

CloudFront is a CDN. It has edge locations (POPs) around the world. The browser does not connect to the bucket’s region first. It connects to a nearby edge. CloudFront does not replace S3. It stands in front of S3 and serves the same objects from cache.

CloudFront edge POPs in front of a single S3 origin; browser hits a nearby edge first
CDN in front: the browser talks to CloudFront, not to S3 first.

Every request follows this order:

  1. Browser → CloudFront
  2. Hit: the edge already has the file. S3 is not called.
  3. Miss: CloudFront GETs the object from S3, stores it at the edge, then returns it.
Left to right: Browser always to CloudFront; CloudFront to S3 on cache miss only
Request order is Browser → CloudFront → S3. There is no Browser → S3 arrow.

You upload to S3. People open the CloudFront URL, or a domain on that distribution. The browser does not talk to S3 first. Part 2 splits cache for index.html versus hashed /assets/* on CloudFront. The origin is still S3.

Serverless is not one product. The operations test is: do you run an operating system? You do not, on S3 or on CloudFront. That is why this Vue front is called serverless in production. Lambda is the usual serverless compute: run code per event, no AMI. You accept cold starts, a timeout, and no local disk as a database.

Also commonly grouped as serverless: API Gateway, DynamoDB, SQS/SNS/EventBridge, Fargate. Fargate can still run tasks all day. “No server for you” is not “zero cost at idle.”

Map Part 1:

Piece What it is Serverless?
Vue static files S3 origin, CloudFront in front Yes
Spring Boot A process you keep on EC2 No
This blog Lightsail WordPress No — a VPS

A hybrid is normal. Static files: browser → CloudFront. API: browser → EC2. A load balancer does not make EC2 serverless. The OS is still yours. If you move the API later, Lambda + API Gateway is the usual path. Long-running work still fits EC2.

Two paths: Vue static Browser to CloudFront to S3 (serverless) and API Browser to EC2 (not serverless)
Hybrid: static Vue is Browser → CloudFront → S3. The API is Browser → EC2.
S3 plus CloudFront yes; EC2 no; Lightsail WordPress no
Operations test: do you run an OS? S3 + CloudFront yes (serverless). EC2 and this blog (Lightsail) no.

Related on DevConda

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *