504 Gateway Timeout - Two EC2 instances with load balancer

0 votes

The problem:

I have Amazon EC2 running an application. It functions without issue when there is only one instance and no load balancer.

But in my production environment, I have two identical instances running behind one load-balancer and when performing certain tasks, like a feature that generates a PDF and attaches it to an email, nothing happens at all, and when using Google Developer tools with the Network tab I get the error "504 Gateway Timeout" once the timeout hits (I have it set at 30 seconds).

My Database is external, on Amazon RDS.

I think... If I could force a client to stay connected to the initial server they logged in at, this problem would be solved, because it's my understanding that the 504 Gateway Timeout is happening when instance-1 tries to reach out to instance-2 to perform the task.

This happens ONLY WHEN using Load Balancing, but never when connecting straight to one of my two servers.

Load Balancer Settings:

  • The load balancer has a CRECORD on my Registrar, so app.myapplication.com points to myloadbalancerDNSname.elb.amazonaws.com.
  • The load balancer has 2 healthy instances, each in the same region but they are in different availability zones.
  • The load balancer is using the same Security Groups as the Instances (allow ALL IPs on ports 22, 80, and 443).
  • The load balancer has cross-zone load balancing turned on.
  • CORS (in Amazon S3) is enabled to GET, POST, PUT, DELETE from * to * (I have no idea how this is associated with my instances but anyway I did it as the instructions said).
  • The load balancer has listeners configured as such:
  • Load Balancer Protocol:HTTP Load Balancer Port:80 Instance Protocol:HTTP Instance Port:80
  • Load Balancer Protocol:HTTPS Load Balancer Port:443 Instance Protocol:HTTP Instance Port:80 (cipher chosen correctly per my Cert provider, and SSL fields 100% surely correct).

Any help would be very much appreciated.

Apr 4, 2022 in Others by Kichu
• 19,040 points
1,505 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

+1 vote
0 answers

How to split a number with coma betweeen two colunms

Jul 3, 2019 in Others by anonymous
832 views
0 votes
0 answers
0 votes
1 answer

It shows black screen when trying to load Map on device with ionic 2 Google Map Native plugin

In order to answer your question, start ...READ MORE

answered Feb 8, 2022 in Others by Rahul
• 9,680 points
1,748 views
0 votes
1 answer

I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome

These errors are usually generated from an ...READ MORE

answered Feb 16, 2022 in Others by Soham
• 9,710 points
5,397 views
0 votes
1 answer

How to install a GUI on Amazon AWS EC2 or EMR with the Amazon AMI

The top-level script for installing the GUI ...READ MORE

answered Mar 9, 2022 in Others by gaurav
• 23,260 points
1,013 views
0 votes
0 answers
0 votes
1 answer

Using Shapely on AWS Lambda with Python 3

For some reason, the pip install of ...READ MORE

answered Oct 8, 2018 in AWS by Priyaj
• 58,020 points
2,951 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP