0

I have 2 x AWS EC2 instances with a node.js app. Out of the box, they come with a local mongod instance that works fine. Given the criticality of the app, I decided to spin up 2 x EC2 front ends (node js) to talk to a mongo db in another availability zone using the AWS ELB.

Full IP communication/27017 connectivity exists between all 3 nodes.

When using only 1 server to the mongo server, it works just fine. When adding both front end servers into the ELB target group, I get random 504 gateway errors.

Removing a server from the group fixes the issue.

Any suggestions on what I should look for?

In terms of how the node.js server connects to mongo, there is a config.json file that simply points out the IP and DB name required.

Thanks!

Kris
  • 1
  • 1

2 Answers2

0

AWS Load Balancer use "round robin" mechanism to route user's requests. Does your application have way to control user sessions? If not then your first request come to server 1, then second request to server 2 which doesn't have any information to the first request may result in error. That explain why it works fine when you have 1 server only

Dominic Nguyen
  • 753
  • 6
  • 11
0

the server uses redis (the app server) and the following components:

Node.js - Server-side Javascript-framework
Express.js - Web application framework for Node.js
Nginx - Web server & reverse proxy
MongoDB - NoSQL database
redis - Session Manager & data structure server
Socket.IO - Bi-directional communication between web clients and servers
Kris
  • 1
  • 1