I have drawn a quick architecture diagram to hopefully clear up the misconceptions.
S3 does not execute any Code. There is no Docker Container in here.
The pattern you're talking about looks roughly like this:
- A CloudFront distribution (Content Delivery Network) is the entrypoint to the infrastructure
- Any static content gets served from S3, which is optimized to deliver static content
- Any dynamic content (i.e. non-static-paths) that requires server side code can get routed to for example a load balancer like an Application Load Balancer
- The load balancer an then decide which backend serves the request
- The backend can for example consist of EC2 instances managed by Elastic Beanstalk or Containers managed by something like ECS or EKS.
- The compute infrastructure also consists of long-running processes (usually, I'm excluding the integration between the ALB and Lambda here).
The benefit is that your comparatively expensive compute resources don't have to be wasted on service static content, which can be done by specialized and more inexpensive solutions such as S3.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…