How to choose between Elastic Container Service (ECS) or Elastic Container Registry (ECR), Elastic Beanstalk, and Lambda?
Solution 1:
Elastic Beanstalk is your traditional hosting - you can upload a PHP or Java or whatever application, say Wordpress, configure a database, etc, and go. There are some smarts for scaling, recovery, etc, but it’s still very much a traditional hosting platform.
ECS Containers can still run your traditional app but there are some more specifics - most notably the containers don’t have persistent storage and are ephemeral, they can come and go and be restarted at any time. Which means they have to be built and ready to run without manual configuration / intervention. There are ways to provide persistent storage for containers but if you can avoid it it’s better. Design your application in a way that it stores all its data in a database and all its files in S3 for example. BTW ECR (Elastic Container Registry) is only a storage for your containers. It's to be used with ECS.
Lambda is a cloud-native serverless concept where the app is split into small functions that serve the various API requests. The website frontend is typically built for example in React or Vue or similar and is served from S3 / CloudFront. Then it makes API calls to the Lambdas through API gateway.
Serverless apps and Containers can typically scale better than traditional apps if they are done right. On the other hand building your first serverless app will be quite a learning curve as some concepts are different from what you may be used to do.
It is a very brief overview. This topic can be discussed for hours :)
Try to google something like “serverless apps design best practice” or “containerised apps design best practices” if you want to go that way.
Hope that helps :)
Solution 2:
Adding to the previous answer - Elastic Beanstalk is more of a Pet platform while Docker (ECS) and Lambda are Cattles. That also means that Docker and Lambda are stateless which means they don't (must not) store any state locally, everything is in a database, in a memcache cluster, and in S3. Beanstalk on the other hand can store local state but it's discouraged with modern applications as it complicates scaling.
Have a look here if you're not familiar with the Pet and Cattle concept.