What is the reason for the delay of the first consultation with Amazon RDS?

1

Always after a short period without queries, when requesting from Amazon RDS (MySQL), there is a delay of almost 20 seconds, while the following requisitions happen normally, as you can see in the image, highlighted in the green rectangle! I need to resolve this.

    
asked by anonymous 19.11.2014 / 21:30

1 answer

2

One possible cause for this is that you have a pool of expired connections ( timeout ) after the long period.

So when a request arrives, your application, framework, or server takes the 20 seconds to detect the problem and reconnect to the database.

Possible solutions:

  • Configure your connection manager to ping the database and prevent connections from "dying". This idea was extracted from this article .
  • Increase the timeout defined in the variable wait_timeout .
  • If your application is Java you can use the autoReconnect parameter, as mentioned in driver documentation .
  • The first option seems to be the most recommended.

        
    19.11.2014 / 21:59