Flask Load Balancing Using Nginx and Docker

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ธ.ค. 2024

ความคิดเห็น • 73

  • @192255100
    @192255100 9 หลายเดือนก่อน

    So far the best explanation I have ever seen, thank you!

  • @kingleo188
    @kingleo188 ปีที่แล้ว +5

    Yo man...This is like the best explanation I have seen in a while.....Great video...

  • @7franciscoramirez
    @7franciscoramirez ปีที่แล้ว +1

    it's a really easy understand why need the nginx on multiplies contents, thanks a lot.

  • @mizzlehd8742
    @mizzlehd8742 ปีที่แล้ว

    First video that explained it well enough to actually make it work, thanks for the video!

  • @nithinsamuel9995
    @nithinsamuel9995 10 หลายเดือนก่อน

    very nice video clear and informative thanks for sharing

  • @RomaniaPortamiVia
    @RomaniaPortamiVia ปีที่แล้ว

    Thank you , after two years since you made this tutorial it's stille correctly working .

  • @gray6275
    @gray6275 ปีที่แล้ว +1

    It's really easy to understand and it goes straight to the issue I'm researching
    Thanks for the tutorial!!!

  • @nathanlebgimstepf2907
    @nathanlebgimstepf2907 10 หลายเดือนก่อน

    that was an incredible load of knowleadge thank you!

  • @KevinKoech357
    @KevinKoech357 10 หลายเดือนก่อน

    Nice tutorial. Lots of content. Appreciate your work.

  • @amanand727
    @amanand727 2 ปีที่แล้ว +1

    Thanks for the tutorial, incredible content packed in such a short video.

  • @elad3958
    @elad3958 ปีที่แล้ว

    The best tutorial on this subject

  • @jaeeboom
    @jaeeboom 2 ปีที่แล้ว

    This is amazing! Loving all of your content!

  • @SuperShubhu123
    @SuperShubhu123 3 หลายเดือนก่อน

    best explanation
    thankyou so much

  • @kingleo188
    @kingleo188 ปีที่แล้ว

    please help @7:20, I get an error of unable to prepare context: path "context:app" not found.

  • @sergey5561
    @sergey5561 7 หลายเดือนก่อน

    Incredible! Thank you so much!

  • @selvakannan2548
    @selvakannan2548 ปีที่แล้ว

    Amazing content. Precise explanation. subbed

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว +1

      Thank you very much :D

  • @horacio_llegolamiel3758
    @horacio_llegolamiel3758 ปีที่แล้ว

    excellent video man, thanks!

  • @HONjramiroz98
    @HONjramiroz98 2 ปีที่แล้ว

    Amazing video! subscribed

  • @mbenturk97
    @mbenturk97 ปีที่แล้ว

    Great vid, good content, clear and easy to understand !!

  • @mayconalvesdealmeida3747
    @mayconalvesdealmeida3747 ปีที่แล้ว

    Nice tutorial, very clearly and direct the point.
    Thanks for share

  • @programacaocomramon
    @programacaocomramon 4 หลายเดือนก่อน

    Great video!

  • @krishnachaitanya4822
    @krishnachaitanya4822 11 หลายเดือนก่อน

    Nice one, didn't know "scale" existed.

  • @ericdwkim
    @ericdwkim 3 ปีที่แล้ว +1

    super helpful and learned a lot, thank you!

  • @Kennethlumor
    @Kennethlumor 8 หลายเดือนก่อน

    Thank you for sharing this knowledge with us. Please I want to ask the way you demonstrate this using this few example can you advance this tutorial by hosting this on pythonanywere where you can also set the load balancing over there.

  • @ganesanj7579
    @ganesanj7579 3 หลายเดือนก่อน

    Well cleared explain

  • @AishwariyaGupta
    @AishwariyaGupta 11 หลายเดือนก่อน +1

    Hi, I am in Windows 10, I re-created all the steps, although I get this error: Error response from daemon: CreateFile mypath
    ginx.conf: Access is denied. Can you help me with this?

  • @ultrakill5712
    @ultrakill5712 2 ปีที่แล้ว

    Ty mate. Sadly i cant give you more likes. Cool explanation with nice english so i got ya even with my worst eng skill :D

  • @sahilgarg94
    @sahilgarg94 7 หลายเดือนก่อน

    Can we add different database as well with the application server for read write Operations.?

  • @doronazulay903
    @doronazulay903 2 ปีที่แล้ว +1

    the nginx container dont show up on "docker ps" , you have any idea why?

  • @CASnumber
    @CASnumber ปีที่แล้ว

    Very very good video

  • @clearthinking5441
    @clearthinking5441 2 ปีที่แล้ว +1

    Great video! Quick question, in this example the compute is distributed across three containers. However, in practice these containers will all be calling to a single database. How would load balancing help in that case since the compute would now be forwarded to the single DB instance? Would you also have to increase the number of DB instances?

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว +3

      Most DB instances can take up a lot of load since they were designed that way. But when you seriously need to scale up DB instances, I recommend you take a look at horizontal DB scaling patterns. The most common ones are data replication (for read-heavy use cases) with a DB load balancer, or cluster-based sharding.

  • @fauzan.developer
    @fauzan.developer 2 ปีที่แล้ว

    So Helpfull, thanks a lot. Pls create more devops things. :D

  • @alimustafa2682
    @alimustafa2682 2 ปีที่แล้ว

    Very Under-rated Video

  • @ryanenoch4279
    @ryanenoch4279 ปีที่แล้ว +1

    Hi Ahnaf. I have a noob level question (Sorry in advance).
    You mentioned that Docker is LInux based. Is it basically some kind of an emulator to imitate a linux environment or is it something else???
    Thanks in advance

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว

      No question is noob level, and you are always welcome to ask!
      Docker itself is just a software that allows you to containerize and isolate applications. That itself isn't a Linux emulator, but it USES a Linux emulator/system to function.
      Docker is Linux based, that means that on any other OS that's not Linux (for example Windows), you need something to emulate a Linux system in order for Docker to run.
      So on Windows, you can try using WSL as it will emulate a Linux system.
      On Linux, you don't need to emulate anything as Docker will use the system's kernel and stuff to function.

  • @muchirajunior
    @muchirajunior 3 ปีที่แล้ว

    a very great skill learn on load balancing. thanks

  • @saketvempaty4312
    @saketvempaty4312 ปีที่แล้ว

    I've Done the exact same thing but I'm getting only a Welcome to Nginx page when i access localhost. Any ideas on resolving this?

  • @alaminbijoy1027
    @alaminbijoy1027 ปีที่แล้ว

    thank you man 😊

  • @elad3958
    @elad3958 ปีที่แล้ว

    what font are you using in this video

  • @Mar-kb8yq
    @Mar-kb8yq ปีที่แล้ว

    Hi awesome video congratulation. Just a question, in this case you have created three container instance oon the same docker computer.. what about creating instance in differents computers ( servers ) and load balancing through them?

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว

      In that case, I would use a service registry since the containers would have dynamic port allocation. Reverse proxy can look up the IPs and ports of the container instances through the service registry and forward the request to those

    • @Mar-kb8yq
      @Mar-kb8yq ปีที่แล้ว

      @@devguyahnaf thank you, I just thought to create a nginx load balancer on another server and upstream connection to the server instances domains. What about that?

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว

      @@Mar-kb8yq If you can hardcode the upstream connection with domains and they are connectable through VPC, then yeah go ahead. I was just talking about autoscaling and why I would use a service registry

    • @Mar-kb8yq
      @Mar-kb8yq ปีที่แล้ว

      @@devguyahnaf Ah ok, I like autoscaling, but for now I never did it, or course in future I want to learn it 😅. Thank you very much again. I will subscribe to your channel.

  • @walkdead94
    @walkdead94 ปีที่แล้ว

    Thanks!

  • @PHOENIX-he9fl
    @PHOENIX-he9fl 2 ปีที่แล้ว +1

    Bro can u help me:
    Either does not exit,is not accessible,or is not a valid URL
    This is my problem for running "docker-compose up"

    • @kingleo188
      @kingleo188 ปีที่แล้ว

      same here, "unable to prepare context: path "context:app" not found.

    • @kingleo188
      @kingleo188 ปีที่แล้ว

      Hi Phoenix, Seems I have figured out the issue, basically this means it cant find the Dockerfile....So I just replaced the word app with a period(.) . Essentially it just needs to be told where to find the Dockerfile, So with the (.) added, It looks in the CWD and then it runs successfully.
      So it should read context: .

    • @AishwariyaGupta
      @AishwariyaGupta 11 หลายเดือนก่อน

      what did you do? I did not get you :( @@kingleo188

  • @venkatasai8752
    @venkatasai8752 2 ปีที่แล้ว

    github link to this project?

  • @SHAILESHBABU
    @SHAILESHBABU 2 ปีที่แล้ว

    "(root) Additional property nginx is not allowed " can anyone help me resolve this error?

  • @anjanikant4804
    @anjanikant4804 3 ปีที่แล้ว

    Localhost showing the site can't be reached. Can you help with this issue ?

    • @devguyahnaf
      @devguyahnaf  3 ปีที่แล้ว

      I have corrected a mistake in the flask part. Use `app.run(host="0.0.0.0", debug=True)`. The host="0.0.0.0" is important

    • @PeterStankiewicz
      @PeterStankiewicz ปีที่แล้ว

      @@devguyahnaf Thanks a lot for that correction, Ahnaf! It finally works!

  • @Mostaqmahmud
    @Mostaqmahmud 2 ปีที่แล้ว

    Super..!!!!

  • @thelinkguys2925
    @thelinkguys2925 2 ปีที่แล้ว

    How would you do this without docker? Like multiple gunicorn running on diff ports. How would you configure that in nginx? Really good tutorial btw. First time i actually understand docker compose😂

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      Yes, run multiple unicorn instances on different ports, and then add each one's IP and port to upstream.
      For example,
      upstream gunicorn-servers {
      server 127.0.0.1:5000;
      server 127.0.0.1:5001;
      server 127.0.0.1:5002;
      }
      Now use that as your upstream for proxy-pass

  • @spiffjekey-green4034
    @spiffjekey-green4034 2 ปีที่แล้ว

    I don’t see how you created multiple instances of the flask app

    • @devguyahnaf
      @devguyahnaf  2 ปีที่แล้ว

      It's the docker compose up command
      docker-compose up -d --scale service_name=5

  • @calvinwong8569
    @calvinwong8569 3 ปีที่แล้ว

    what do you mean by typo cccccc ?

    • @devguyahnaf
      @devguyahnaf  3 ปีที่แล้ว

      Typo means typing mistake

    • @calvinwong8569
      @calvinwong8569 3 ปีที่แล้ว

      @@devguyahnaf i got an issue regarding my nginx container wont build but the 3 app is builded any idea ?

    • @calvinwong8569
      @calvinwong8569 3 ปีที่แล้ว

      i mean its created but keep exited

  • @TheCodeHunter
    @TheCodeHunter 3 ปีที่แล้ว

    nice

  • @KKOO8
    @KKOO8 3 ปีที่แล้ว

    I see

  • @rinket7779
    @rinket7779 ปีที่แล้ว +2

    Wait how does this load balancing even work? Why doesn’t it require an upstream group? How does nginx know to switch between each app ? What load balancing algorithm does it use? Round robin? Least connections? So many questions, I wish you had gone more into depth about wtf is actually going on here, is this some docker magic? Or it’s a feature of nginx itself? So confusing

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว +2

      This deployment method isn't good for high scale production, something like a cloud container service with a managed load balancer or some kind of cluster L7 ingress would be better. This is just a way to quickly set up load balancing with docker compose for those who need it done fast and dirty. Primarily, the load balancing is round robin as far as I know. The upstream group has IP addresses which are provided by Docker compose during container build, as the containers' internal IPs are dynamic.
      And yes, there's some Docker magic going on here. It's also why I didn't go too deep into it, as a lot of stuff is managed by Docker's internal hostname providers and such. This isn't the optimised or recommended way of deploying it to prod, it's just a simple way for small setups with multiple containers. I don't really remember the specifics of this video at the moment, but do follow up with replies if you have any questions and my answer doesn't satisfy you.

    • @rinket7779
      @rinket7779 ปีที่แล้ว

      @devguyahnaf maybe it's using dns based load balancing? I notice you just put "app" and it's able to load balance with just that, probably cos "app" returns a different ip each time?

    • @devguyahnaf
      @devguyahnaf  ปีที่แล้ว +1

      @@rinket7779 You're probably right, I've just taken a look and Docker does some of that networking which includes hostname resolving, which implies that it's DNS based load balancing.