Performance hit with sequalize on lambda?
See original GitHub issueI am you performance issues with (i believe) sequalize on lambda and am wondering if this is just the norm. For example, I have a call where my app thinks the timing is 97 mc but lambda actually takes 1102 ms. The timings of my test lambda without sequalize seem to make more sense. Anyways, any thoughts are appreciated.
// my pool
pool: {
max: 1,
min: 0,
idle: 100
},
// snippet
module.exports.handler = function (event, context, cb) {
console.time("reqstart")
var model = require('../models');
var group;
model.Group.create({})
.then(function (localGroup) {
console.timeEnd("reqstart")
return cb(null, {
message: 'Go Serverless! Your Lambda function executed successfully! '+JSON.stringify(event, null, 2)
});
})
.catch(function (err) {
console.log(err);
});
};
// cloudwatch logs
START RequestId: 7384364a-2b93-11e6-9d8f-83d013cc53d6 Version: 60
2016-06-06T03:04:59.120Z undefined Executed (default): INSERT INTO "Groups" ("id","createdAt","updatedAt") VALUES ('54d96b10-7e24-4c0b-ac26-6f2444f65978','2016-06-06 03:04:59.030 +00:00','2016-06-06 03:04:59.030 +00:00') RETURNING *; 10
2016-06-06T03:04:59.123Z 7384364a-2b93-11e6-9d8f-83d013cc53d6 reqstart: 97ms
END RequestId: 7384364a-2b93-11e6-9d8f-83d013cc53d6
REPORT RequestId: 7384364a-2b93-11e6-9d8f-83d013cc53d6 Duration: 1102.49 ms Billed Duration: 1200 ms Memory Size: 1024 MB Max Memory Used: 41 MB
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Using sequelize in AWS Lambda
AWS Lambda is a serverless computing service that allows customers. ... re-use the sequelize instance across invocations to improve performance
Read more >AWS Lambda vs Sequelize | What are the differences?
AWS Lambda - Automatically run code in response to modifications to objects in Amazon S3 buckets, messages in Kinesis streams, or updates in...
Read more >Hijacking Sequelize with Fyresite's MySQL Data API Wrapper
When the Lambda's already warm, Sequelize mitigates some of these performance issues by reusing connections with pools.
Read more >A crash course on Serverless with AWS - Building APIs ...
I have a serverless project integrated with express and sequelize, such that a single lambda has multiple routes. The F.E calls 6 api...
Read more >Sequelize Code Not Executing Inside AWS Lambda
Yesterday found that if you're using callback(null, successData), the performance was really poor (>11 secs on a Select top 1). Had to change ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Found the issue after RTFM.
http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html#nodejs-prog-model-context-properties
You have to set
context.callbackWaitsForEmptyEventLoop = false
. Otherwise, the process isn’t terminated until the event loop is empty.Hope this helps someone.
Unfortunately, Sequelize is not good for lambda because the higher cost is the startup…
With sequelize it takes almost 1s to return the request and with mysql2 in most cases lower than 100ms.