AWS EC2 on ECS vs Fargate | Whats the Difference and When To Use What?

Поділитися
Вставка
  • Опубліковано 21 лис 2021
  • In the world of containers, there are many options for running your virtual images on the cloud. In this video, I compare and contrast two popular options for hosting containers on AWS: EC2 on ECS vs Fargate. Both of these technologies take advantage of ECS control plane to orchestrate your containers. However, there are numerous pros and cons associated with using either technology. In this video, we'll describe the difference between these two options. We'll go over some key terms in the world of ECS that you need to know about. Finally, I'll provide some guidance on when to use one option over the other.
    Looking to get hands on experience building on AWS with a REAL project? Check out my course - The AWS Learning Accelerator! courses.beabetterdev.com/cour...
    Relevant Videos:
    ECS Overview - • An Overview of AWS Ela...
    Deploying Docker Image onto ECS - • How to Deploy a Docker...
    Fargate + Application Load Balancer Setup - • How to Setup AWS ECS F...
    🎉SUPPORT BE A BETTER DEV🎉
    Become a Patron: / beabetterdev
    📚 MY RECOMMENDED READING LIST FOR SOFTWARE DEVELOPERS📚
    Clean Code - amzn.to/37T7xdP
    Clean Architecture - amzn.to/3sCEGCe
    Head First Design Patterns - amzn.to/37WXAMy
    Domain Driven Design - amzn.to/3aWSW2W
    Code Complete - amzn.to/3ksQDrB
    The Pragmatic Programmer - amzn.to/3uH4kaQ
    Algorithms - amzn.to/3syvyP5
    Working Effectively with Legacy Code - amzn.to/3kvMza7
    Refactoring - amzn.to/3r6FQ8U
    🎙 MY RECORDING EQUIPMENT 🎙
    Shure SM58 Microphone - amzn.to/3r5Hrf9
    Behringer UM2 Audio Interface - amzn.to/2MuEllM
    XLR Cable - amzn.to/3uGyZFx
    Acoustic Sound Absorbing Foam Panels - amzn.to/3ktIrY6
    Desk Microphone Mount - amzn.to/3qXMVIO
    Logitech C920s Webcam - amzn.to/303zGu9
    Fujilm XS10 Camera - amzn.to/3uGa30E
    Fujifilm XF 35mm F2 Lens - amzn.to/3rentPe
    Neewer 2 Piece Studio Lights - amzn.to/3uyoa8p
    💻 MY DESKTOP EQUIPMENT 💻
    Dell 34 inch Ultrawide Monitor - amzn.to/2NJwph6
    Autonomous ErgoChair 2 - bit.ly/2YzomEm
    Autonomous SmartDesk 2 Standing Desk - bit.ly/2YzomEm
    MX Master 3 Productivity Mouse - amzn.to/3aYwKVZ
    Das Keyboard Prime 13 MX Brown Mechanical- amzn.to/3uH6VBF
    Veikk A15 Drawing Tablet - amzn.to/3uBRWsN
    🌎 Find me here:
    Twitter - / beabetterdevv
    Instagram - / beabetterdevv
    Patreon - Donations help fund additional content - / beabetterdev
    #AWS
    #ECS
    #Fargate
    #EC2
    #Beabetterdev

КОМЕНТАРІ • 74

  • @BeABetterDev
    @BeABetterDev  2 роки тому +14

    ECS Overview - ua-cam.com/video/I9VAMGEjW-Q/v-deo.html
    Deploying Docker Image onto ECS - ua-cam.com/video/zs3tyVgiBQQ/v-deo.html
    Fargate + Application Load Balancer Setup - ua-cam.com/video/o7s-eigrMAI/v-deo.html

  • @user-ft2ci6vm3q
    @user-ft2ci6vm3q 4 місяці тому +1

    I am watching X vs Y in AWS videos in preparation for an AWS certification exam. These videos are straight and to the point.

  • @JitoTantrum
    @JitoTantrum 8 місяців тому +1

    This is the best explanation I’ve heard yet.

  • @DC-xt1ry
    @DC-xt1ry 2 роки тому +2

    Excelent explanation and very well presented ! Thx for sharing!

  • @DuyNguyenH
    @DuyNguyenH 2 роки тому +3

    I've never met this guy (or have I) but here he is helping me out again! Thank you for the great video bud.

  • @larhard
    @larhard Рік тому

    Thank you. Great work and useful video for recap in this busy world ;)

  • @vimalneha
    @vimalneha 2 роки тому +1

    Always great videos and your site has become a reference one for topics i look for.
    Thanks for sharing...

  • @raphaelaneng2547
    @raphaelaneng2547 2 роки тому +2

    Thank you for this wonderful explanation 🙌🏾

  • @RicusNortje
    @RicusNortje 2 роки тому +4

    Nice video. As an fyi: we use Fargate and split our clusters based on the type of logging the underlying services and tasks produce. All services log to a single cloudwatch log group, you can then grok the logs in that log group based on the type of logs created by the services\tasks inside them.

    • @RicusNortje
      @RicusNortje 2 роки тому

      ECS on EC2 also makes it easier to impliment ECS Anywhere on your local data center.

  • @GabrielCrowe
    @GabrielCrowe 2 роки тому +24

    Some other reasons you might NOT use Fargate:
    - You cannot cache container images, even from AWS Elastic Container Registry, they need to transfer across the wire for every task
    - The startup time is longer, due to setting up the networking and things like allocation.
    Typically, fargate will add approximately 20-30 seconds from the invocation of startTask (for example).
    EC2 instances with ECS, startup is much quicker and it can cache the images.

  • @vladkodenko5008
    @vladkodenko5008 2 роки тому +1

    Thanks! Great content. Your channel is a gem

  • @severtone263
    @severtone263 3 місяці тому

    Excellent explanation. Thank you

  • @inversebrah
    @inversebrah 2 роки тому +1

    Great explanation as usual 👍

  • @JohnS-er7jh
    @JohnS-er7jh 9 місяців тому +2

    Best AWS videos. I have signed up for a variety of AWS training courses, but sometimes i will listen to others speak for 20 minutes, and at the end of the video, they succeed in just confusing me more. So many of these services sound very similar, by doing a comparison of the services it helps me understand this stuff better.

    • @user-ft2ci6vm3q
      @user-ft2ci6vm3q 4 місяці тому

      I think I have watched the same AWS training courses, and it feels like many of the instructors have mastered the subject, but forgot what it is like from little to no knowledge or experience.

  • @FinaISpartan
    @FinaISpartan 7 місяців тому +1

    One more thing to note, as you mentioned, running EC2 outside of ECS is completely viable. You can even have autoscaling by putting it in an ASG, and traffic routing to each instance via ELB. Since you manage everything manually, you can get maximum usage out of the hardware, and this is the lowest-cost way of doing it.

  • @naska8701
    @naska8701 Рік тому +1

    Great video as usual

  • @k.i.m.5506
    @k.i.m.5506 2 роки тому +1

    super clear explanation!

  • @AJ_real
    @AJ_real 2 роки тому +15

    We use Fargate in work and to be honest, when I heard about it first, I thought it sounded like some kind of alien transportation device ahahahaha

  • @SH-os1ck
    @SH-os1ck 2 роки тому +1

    This is really good! I'm subbing!

  • @huthayfaainqawi4348
    @huthayfaainqawi4348 Рік тому

    Excellent!

  • @shashankgupta4656
    @shashankgupta4656 17 днів тому

    great video if possible can you add one video for costing difference between also

  • @luiztauffer8513
    @luiztauffer8513 2 роки тому +1

    great content as always, thanks!
    Would be awesome to hear your opinion on using AWS Batch with Fargate!

  • @DandyDev
    @DandyDev 2 роки тому +33

    Great video! There is one subtle error though: you say that _container_ is a term used only when running an ECS cluster on EC2. This is not true. _Containers_ are the smallest primitive that is used to define what you want to run and as such are part of the Task Definition, both for tasks run on Fargate as well as EC2.
    Quote from the AWS Fargate docs:
    "The task definition is a text file (in JSON format) that describes one or more *containers* (up to a maximum of ten) that form your application."
    What you're confused with are Container _Instances_ . Container Instances are EC2 instances specifically reserved for running ECS containers (which are part of tasks). Container Instances are illustrated well on the diagram you show at 8:33. So when you're explaining how tasks run inside a container (9:30), what you really mean is that tasks are running inside container _instances_ . Interestinly, you could make the diagram even more complete by drawing containers _inside_ the tasks, because technically each task can contain 1 _or more_ containers. (although usually, you'd run 1 container per task)

    • @navneetthillaisthanam5095
      @navneetthillaisthanam5095 Рік тому +1

      Good clarification. I was getting befuddled on why are the definitions deviating from what the container world is already familiar with. Of course, I am guilty of not having RTFMed the AWS Container offering before coming to this video.

  • @iceya4155
    @iceya4155 Рік тому

    great video thanks

  • @ruslanmustaev8170
    @ruslanmustaev8170 Місяць тому

    The main feature you forgot to mention and from my point of view is the key feature in choosing is the having persistent storage available for docker containers when we use EC2+ECS.

  • @kishore7890
    @kishore7890 2 роки тому

    Good one.

  • @nishakaraperera385
    @nishakaraperera385 Рік тому +1

    simply great!!

  • @rickharold7884
    @rickharold7884 2 роки тому +1

    Great summary. Love serverless everything

  • @wanderer.1993
    @wanderer.1993 2 роки тому +5

    It should be "container instances" isntead of "container". Both fargate and ecs modes deal with containers, but only ec2 mode deals with container instances (the ec2 vm where your task actually are running on)

    • @BeABetterDev
      @BeABetterDev  2 роки тому

      Thanks for the clarification victor!

  • @AriKhuu
    @AriKhuu 6 місяців тому

    Thank you

  • @AndrewHelgeCox
    @AndrewHelgeCox 7 місяців тому

    Can your fargate tasks communicate with each other over a shared private network?

  • @manishmaharjann
    @manishmaharjann Рік тому

    Hi Can you cover in EKS?

  • @BullishBuddy
    @BullishBuddy 2 роки тому +1

    👍👍👍厉害

  • @JimBob1937
    @JimBob1937 9 місяців тому +1

    Another reason, EC2 supports GPU resources, Fargate doesn't (currently).

  • @joshcollins9125
    @joshcollins9125 2 роки тому +2

    What about Fargate v App Runner?

  • @natheeshkumar
    @natheeshkumar 2 роки тому +1

    Great video ❤️. Can you make aurora server vs serverless database with cost analysis 🤗

  • @vergmeister9479
    @vergmeister9479 2 роки тому +2

    Well explained, thank you. I got a question. I have 2 very very low traffic Web apps with fair amount of logic at the backend. I am currently hosting them on aws app runner but I'd like to migrate them as is not fit for purpose and feels immature (errors, downtime, lack of logs).
    I wonder if fargate would be a option? Apps are open to the public, wouldn't need more than 256Mb to run and 0.2 cpu would be more than enough. They would need to be constantly app and running ready to serve requests.

    • @ramtadam1469
      @ramtadam1469 2 роки тому +4

      Should work just fine - we built sth like this with Fargate as Backend and Cloudfront for Frontend + Load Balancer. Worked perfectly fine

    • @vergmeister9479
      @vergmeister9479 2 роки тому

      @@ramtadam1469 thanks, I built yesterday the two service. Got me some time to get to the correct configuration but in the end got there. Did some calculations as well, I expect costs to be about $10 a month per app (single tasks).
      Hosting the FE on cloudfront sounds very appealing but have no need for it now. Nice to hear about your architecture.

  • @kayoutube690
    @kayoutube690 Рік тому

    ECS Fargate is better choice specially if your organization have a strict security requirements.

    • @kavyav3838
      @kavyav3838 6 місяців тому

      What is the reasoning behind this?

  • @armanmirk
    @armanmirk 7 місяців тому

    He is incorrect about 3:01 telling fargate how many docker images you want to run. It’s better to think in terms of ECS tasks which have a limit of 10 containers per task. Anymore and you have to start a new task. In this regard a fargate task is like a server with a hard ten containers limit. It’s also worth mentioning that a service may run multiples of the same task not multiples of different tasks which isn’t immediately obvious.

  • @DF-ss5ep
    @DF-ss5ep 2 роки тому +4

    ECS seems like AWS's reinvention of the kubernetes wheel.

    • @BeABetterDev
      @BeABetterDev  2 роки тому

      Good observation DF! Very similar indeed.

  • @LarrysJournal
    @LarrysJournal 2 роки тому +2

    Hi I've read a lot on containerisation but I still am embarassed to ask what Dockers and containers are used for? Is it run multiple applications on multiple systems in tandem? Or something else.

    • @DodaGarcia
      @DodaGarcia 2 роки тому +2

      Don’t be embarrassed!! It’s a pretty abstract thing that takes some getting used to.
      You can think of a Docker container as a lightweight type of VM So when you run a Docker container from say, a Linux-based Docker image, that container will have its own little Linux system running, totally in isolation from the host computer.
      So the huge benefit here is that you can have a complex setup of applications installed in a Docker image that will work the same for everyone who runs a container from that image. That makes it a great way to package and distribute projects, since you can make a Docker image containing your project and all it needs to run, and other people can then use your image to run containers that use the functionality you packaged in. So your code essentially becomes executable in that sense, without requiring installation.
      This might have sounded convoluted so here’s an example I run into a lot: I use Blender to render my 3D projects, but installing and maintaining Blender on Linux is a bit of a pain in the ass. So what I do is pull the Blender Docker image from the NYTimes repo, which is always up to date, and run it as a container. Now not only do I have Blender running in that container without having had to install and troubleshoot dependencies, but also if I want to I can have several containers in the same computer running that image to render my 3D scene faster.
      I also really recommend @Fireship’s “Docker in 100 seconds” video, he’s truly stellar in making these concepts easier to understand.

  • @Josempita
    @Josempita 2 роки тому +2

    There's also EKS

  • @rajiv7
    @rajiv7 Рік тому

    Hi...Can anyone please let me know how I can leverage existing EC2 machines as part of ECS cluster? I am confused here.
    Is below the answer? I just googled it. Please confirm if that is the right approach.
    'You can run an ECS cluster within an existing VPC, making it accessible to existing AWS resources running in that VPC.'

  • @firegiver
    @firegiver Рік тому

    I feel like the details of scaling were left out here.

  • @yangsong8812
    @yangsong8812 2 роки тому +20

    It is ECS on EC2 to begin with

  • @ziadirida
    @ziadirida 28 днів тому

    Not correct when talking about containers in relationship to fargate. 6:00 and 7:25 (container only apply to EC2 is not correct)

  • @florianfanderl6674
    @florianfanderl6674 2 роки тому +1

    Kind of confusing that they called the EC2 instances containers, while docker also calls the instantiated images containers.

    • @BeABetterDev
      @BeABetterDev  2 роки тому +1

      I completely agree. I wish they picked a different name!

  • @G3TSH1TD0N3
    @G3TSH1TD0N3 Рік тому

    Good info but just an FYI, it's reSources not reZources.

  • @armunro
    @armunro 2 роки тому

    ECS and Fargate are awful. Just use kubernetes instead; its much better. Mind you EKS is also pretty awful and thus maybe you should look at GCP GKE which is miles better and probably the best cloud based kubernetes? Sidecar is a misleading term (this is a k8s term); it would just be best if you called it the ECS container agent, which is a docker container running in the EC2 instance that will spin up containers for you under ECS control?

    • @BeABetterDev
      @BeABetterDev  2 роки тому +3

      Hi Alasatir. I haven't worked much with EKS so can't really comment on how it compares. Also, sidecar is a general term that applies to side processes running alongside a host - see docs.microsoft.com/en-us/azure/architecture/patterns/sidecar .