We're using API gateway + Lambda function + DynamoDB to fetch data and using the DynamoDB query method. For 260.4KB data ( Total item count:675 | Scanned Count: 3327 ) it's taking 3.49s.
Requirement:
We've 4+ clients, we are calculating client sales user's data on daily basis and storing it in the DB.
Table Structure:
- Primary Key: ClientId
- Sort Key: Date+UserId
- Other Attributes: Date
In Query - We are using Primary Key ClientId & Date to get the data.
Currently, we're using on-demand mode for the DynamoDB yet we feel the response time > 1s is too much.
Is there any way we can improve this using any AWS configurations?
Update[24/03/2021] In Lambda - We are using NodeJs.
module.exports.executeQuery = async(dynamoDbClient, queryInput) => {
return await new Promise((resolve, reject) => {
dynamoDbClient.query(queryInput, (err, users) => {
if (err) {
reject(handleQueryError(err));
}
else {
resolve({
statusCode: 200,
users,
});
}
});
});
};
Memory Provisioned to Lambda = 128 MB