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.
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?
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?
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.
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
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.
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?
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
@@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?
@@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
@@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.
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: .
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😂
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
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
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.
@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?
@@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.
So far the best explanation I have ever seen, thank you!
Yo man...This is like the best explanation I have seen in a while.....Great video...
it's a really easy understand why need the nginx on multiplies contents, thanks a lot.
First video that explained it well enough to actually make it work, thanks for the video!
very nice video clear and informative thanks for sharing
Thank you , after two years since you made this tutorial it's stille correctly working .
It's really easy to understand and it goes straight to the issue I'm researching
Thanks for the tutorial!!!
that was an incredible load of knowleadge thank you!
Nice tutorial. Lots of content. Appreciate your work.
Thanks for the tutorial, incredible content packed in such a short video.
The best tutorial on this subject
This is amazing! Loving all of your content!
best explanation
thankyou so much
please help @7:20, I get an error of unable to prepare context: path "context:app" not found.
Incredible! Thank you so much!
Amazing content. Precise explanation. subbed
Thank you very much :D
excellent video man, thanks!
Amazing video! subscribed
Thank you :)
Great vid, good content, clear and easy to understand !!
Nice tutorial, very clearly and direct the point.
Thanks for share
Great video!
Nice one, didn't know "scale" existed.
super helpful and learned a lot, thank you!
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.
Well cleared explain
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?
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
Thanks a lot :D
Can we add different database as well with the application server for read write Operations.?
the nginx container dont show up on "docker ps" , you have any idea why?
Very very good video
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?
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.
So Helpfull, thanks a lot. Pls create more devops things. :D
Very Under-rated Video
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
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.
a very great skill learn on load balancing. thanks
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?
thank you man 😊
what font are you using in this video
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?
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
@@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?
@@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
@@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.
Thanks!
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"
same here, "unable to prepare context: path "context:app" not found.
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: .
what did you do? I did not get you :( @@kingleo188
github link to this project?
"(root) Additional property nginx is not allowed " can anyone help me resolve this error?
Localhost showing the site can't be reached. Can you help with this issue ?
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
@@devguyahnaf Thanks a lot for that correction, Ahnaf! It finally works!
Super..!!!!
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😂
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
I don’t see how you created multiple instances of the flask app
It's the docker compose up command
docker-compose up -d --scale service_name=5
what do you mean by typo cccccc ?
Typo means typing mistake
@@devguyahnaf i got an issue regarding my nginx container wont build but the 3 app is builded any idea ?
i mean its created but keep exited
nice
I see
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
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.
@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?
@@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.