Why does my Lambda function randomly fail when using a private netwok calls as well as public api calls inside a private VPC? [closed]

I am trying to write a caching function that returns cached elasticcache data or makes an api call to retrieve that data. However, the lambda function seems to be very unrealiable and timing out often.

It seems that the issue is having redis calls as well as public api calls causes the issue. I can confirm that I have setup aws correctly with a subnet with an internet gateway and a private subnet with a nat gateway. The function works, but lonly 10 % of the time.

Not sure what to do. Is it best practice to seperate these 2 tasks or am I doing something wrong?

    client.get(event.token, async (err, result) => {
      if (err) {
        console.error(err);
      } else {
        data = result;
        await client.quit();
      }
    });

    if (data && new Date().getTime() / 1000 - eval(data).timestamp < 30) {

      res.send(`({
        "address": "${token}",
        "price": "${eval(data).price}",
        "timestamp": "${eval(data).timestamp}"
      })`);
    } else {
      getPrice(event); //fetch api data
    }
    ```


Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept