I'm using the AWS Parameter Store in order to save parameters to be used by my Lambda functions(env variables), 4 parameters actually. But I am observing some performance issues when loading them, It is taking between 0.2 and 0.6 secs to load one parameter only, which is a lot of time for my web app.
I measured the time by running this command
time aws ssm get-parameter --name "sample_parameter"
I would expect less time in order to load the parameter value, since I need to get 4 parameters. So here is my question...Is it a good pracite to load parameters as json text? so I could put all these 4 parameters within a json object. Is there something to do in order to improve performance when calling the get parameter function?
Thanks
You can get all the parameters at once using the get-parameters. In my tests it's averages the same time to get all 4 parameters in a single call as it does to get 1.
$ time aws ssm get-parameter --name w1
{
"Parameter": {
"Name": "w1",
"Type": "String",
"Value": "say anything",
"Version": 1,
"LastModifiedDate": 1566914540.044,
"ARN": "arn:aws:ssm:us-east-1:1234567890123:parameter/w1"
}
}
real 0m0.811s
user 0m0.509s
sys 0m0.095s
$ time aws ssm get-parameters --names w1 w2 w3 w4
{
"Parameters": [
{
"Name": "w1",
"Type": "String",
"Value": "say anything",
"Version": 1,
"LastModifiedDate": 1566914540.044,
"ARN": "arn:aws:ssm:us-east-1:1234567890123:parameter/w1"
},
{
"Name": "w2",
"Type": "String",
"Value": "say nothing",
"Version": 1,
"LastModifiedDate": 1566914550.377,
"ARN": "arn:aws:ssm:us-east-1:1234567890123:parameter/w2"
},
{
"Name": "w3",
"Type": "String",
"Value": "say what",
"Version": 1,
"LastModifiedDate": 1566914561.301,
"ARN": "arn:aws:ssm:us-east-1:1234567890123:parameter/w3"
},
{
"Name": "w4",
"Type": "String",
"Value": "say hello",
"Version": 1,
"LastModifiedDate": 1566914574.716,
"ARN": "arn:aws:ssm:us-east-1:1234567890123:parameter/w4"
}
],
"InvalidParameters": []
}
real 0m0.887s
user 0m0.561s
sys 0m0.097s