Search code examples
amazon-s3aws-cloud9

Hosting a Docker Container in S3 vs Elastic Beanstalk?


I have heard of the strategy of hosting/serving a static website in S3 in a container. What is the advantage over putting it in elastic beanstalk?


Solution

  • 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.

    enter image description here