2

I'm very new to AWS. I've created a new RDS instance t2.small by following the previous one. I've selected all options as similar with the previous one. But the new instance is performing very slow, about 5 times slower than the previous one.

What I've found that, it's taking too much time to establish MySQL connection from the EC2. Sometimes it's more than 10s, and that time it shows connection timeout.

How can I reduce this time to establish mysql connection? I've got few answers about cache query, it didn't solve my problem.

Instance monitoring screenshot

JonathanDavidArndt
  • 1,424
  • 3
  • 20
  • 29
biplob
  • 121
  • 5
  • That load seems very low. Have you checked that the RDS instance is running in the same region and AZ as the EC2 instance? The latency could maybe explain it, but the AZs are generally sub ms away. Can you ping it - not sure you can in AWS. You can also stop and start it (not restart - stop and start) as this moves it to different hardware which may be less busy. Also check CloudWatch monitoring for the instance. – Tim Dec 13 '16 at 05:23
  • Thank you. It's on same region. Latency is high. And will try the suggested ways. – biplob Dec 13 '16 at 05:27
  • @Tim I've kept a simple php script on my ec2 to check mysql connection establish time. Most of the time it's more than 10s. Also tried by creating a new instance. But no luck. – biplob Dec 15 '16 at 02:16
  • Does a traceroute tell you anything interesting? Edit your post to show it - obfuscate if necessary but probably not since it's in a VPC. – Tim Dec 15 '16 at 04:17
  • @Tim , thank you so much. Finally, I could figure it out. It's because of security group. We had only mysql connection for db connection sg, we've added tcp and all traffic as well. Now, it's connecting less than 1s. – biplob Dec 15 '16 at 10:47
  • Please fill in an answer below so others who have this problem have a clear description of how to fix it. For example, it would be good to understand exactly what ports were open before, and exactly what ports you opened with what protocols to fix this. "Added TCP" is a bit vague - "We added a security group rule to allow TCP traffic on port 3307" - or it may have been your database security group. A screenshot would also be really helpful. – Tim Dec 15 '16 at 18:07

1 Answers1

0

We could solve the issue as following

  • Set all ports & traffics open from the security group before restart.
  • Restart the RDS instance
  • Remove again unnecessary security group items after restart.

Before restart

After restart

biplob
  • 121
  • 5
  • 2
    Based on what I know about AWS, which is a fair bit and includes three AWS certifications, the only part of your procedure that makes any difference is the restart part. Changing security groups, retstarting, then changing them again shouldn't make any difference. If it does you've found a bug. – Tim Dec 19 '16 at 05:14