4

I am working on a an api which will get lot of hits so that, I cached it. Each call will have a set of ids which needs to be passed in the request itself and I cant use batch to get the items due to design issues. So I am calling get operation multiple times for all of the eventIds

async function getSummaryFromDax(id) {
        const perf = perfMeasure({enable: true});
        let params = {
            TableName: Table,
            Key: {
                id
            }
        };
        //todo dax not working as expected.
        perf("parallel");
        const result = await daxCacheClient.get(params).promise();
        perf("parallel");

        return {result: result.Item,perf: perf._summary};
    }

This function mocks the functionality. I just hard coded the id.

const {queryStringParameters= {}} = event;
    const {calls = 1, id = "CwjPJ4rcdIOOi3yFhpHhDiHzHKo-w8aRaVAYR"} = queryStringParameters;
    dummy.length = calls;
    dummy.fill(id);
    const proms = dummy.map(async id=>{
        return getSummaryFromDax(id)
    })


    const response = await Promise.all(proms);
    perf("handler");

If the calls =1 , means, 1 db get call will be done. The time taken to get the db response is 2ms. When I increase the calls count say, 100, I am getting average performance of 200 ms per each get operation. Why does that happening ?.

NIKHIL C M
  • 3,873
  • 2
  • 28
  • 35

0 Answers0