skip to Main Content

would love to hear some opinions regarding hosting of an Angular Universal app.

Question – EC2 vs AWS Lambda

After finishing my application I initially created t2.micro linux instance to host my app, was happy to see that the site scores 97 in Googles page speed insight test.

Afterwards I came across AWS lambda, a serverless way to run my server rendering app!, as its cost depends on the amount of requests (which Is extremely low on my website) thought that could be a nice way to avoid paying $10 a month.

The only issue is – Google speed test (using AWS Lambda) scored a sad 80… with a huge red flag on server response time.
After doing a few more tests seems like the function became warmer and got up to 92. that’s not 98 but I can live with that.

The thing is, as Im planning to get about 20-50 requests spread through out the entire day it will stay cold, so SEO wise I’ll stay on 80 score website instead of 98.

Is there something I’m missing? As convenient as it is should I just stick with EC2 for my needs?

Thanks for reading <3

2

Answers


  1. 20-50 requests a day is definitely not much, so indeed your Lambda functions will run cold at some point (usually they go cold after 5 mins).

    One option here is to create a CloudWatch event that runs every 4 mins and triggers your Lambda function.

    Keep in mind that this would only spin up one single container. If you expect peaks, let’s say that 10 out of the 50 requests are concurrent, then you’d need to have your Lambda spin up another instance of the same function 10 times, so you wouldn’t have to worry about cold starts too much. However, since this can get messy quickly, I suggest your CloudWatch Event invokes a Lambda whose only responsibility is to warm up the real Lambda (i.e, calling the real Lambda 10 times concurrently) you’re going to use.

    I suggest you read this article by AWS Community Hero Yan Cui, where he covers, in details, how Lambda cold starts work and how to avoid them.

    Login or Signup to reply.
    • If its just Google speed test that pulling you back from using aws lambda (I would suggest to use synthetic transaction also known as active monitoring or proactive monitoring or using CloudWatch Events “ping”) which would help you keep the lambdas worm.
    • As long as you are in the monthly 1 million free invocations it wont cost you a pennies.
    • It also depends up the traffic you are seeing/expecting on your site, because it will be the guiding force to select the method, how you want to implement the keep warm bit(synthatic transaction or cloudwatch event ping).
    • hope this link helps its just talking about cloud watch ping method but its covering single concurrency and multiple concurrency methods https://www.jeremydaly.com/lambda-warmer-optimize-aws-lambda-function-cold-starts/
    • And synthetic transaction is nothing but doing a whole user journey on your site like once every 10 minutes but its more of monitoring then keep the lambda warm.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search