Increase the waiting time to one minute. This may be due to the cold start of the lambda function.
Only your first call takes time, consecutive calls should be very fast since you are reusing the same connection.
In addition, having a higher timeout does not mean that you will pay for this timeout, you will only pay for the time that the lambda works.
, , webpack ,
http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/webpack.html
,
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'amazon-string.rds.amazonaws.com',
user : 'myusername',
password : 'mypassword'
});
connection.connect();
exports.handler = (event, context) => {
connection.query("SELECT * FROM table", function(err, rows, fields) {
console.log("rows: " + rows);
context.succeed('Success');
});
};
, .