DEV Community

Discussion on: Build a highly available Node.js application using Docker, NGINX and AWS ELB

Collapse
 
rubberduck profile image
Christopher McClellan

You've over complicated your architecture.
AWS ELB already uses NGINX to load balance/reverse proxy.
(At least it did last time I checked.)
I can't see a reason you need your own NGINX container here.

Collapse
 
sowmenappd profile image
Sowmen Rahman • Edited

AWS ELB still does use NGINX behind the scenes however, it doesn't provide an intuitive way of load balancing between applications running in the same instance. The additional NGINX container running on each server solves this problem, a bit complicated I admit but, it works.

The only other way I (that I can think of) could have avoided using NGINX (in my case) would be to use a target group that listen to different ports for each server. I guess that is easier, but I really wanted to demonstrate how NGINX would handle a two-tiered proxy pass and also personally it just came down to my preference of directly using NGINX. And I used containers instead of using a direct NGINX server, because I am planning to streamline the deployment process using a pipeline.
If this doesn't answer your query, please do brief down here a little more! Maybe I am missing something.. who knows? Thanks!

Collapse
 
gayanhewa profile image
Gayan Hewa

Won't using PM2 type process manager solve the problem. ELB is able to deal with load balancing if you plan to spin up multiple boxes. But within the box request can be served via PM2 or node cluster these serve the requests over each process in a round-robin fashion.

Thread Thread
 
sowmenappd profile image
Sowmen Rahman

Thank you @gayanhew. To answer your question, yes it would! However, my intention for this video wasn’t to get into pm2, like I said above in my note before starting the tutorial. At the base level, both nginx and pm2 would handle distributing load to multiple app instances, and I chose nginx. If I had chosen pm2, that too would have worked but I’d have needed to explain clusters, processes and forking.

Thread Thread
 
gayanhewa profile image
Gayan Hewa

True, valid point.