12 Comments
User's avatar
Tung Le's avatar

E mới xem podcast của a với Yan. Thấy rất quen hoá ra là anh Hiếu ở Lê Lợi. Cảm ơn a về bài viết, mong có thể contact với a để trao đổi thêm :D

Expand full comment
Andrzej K's avatar

Thanks for the write up, but those are awful cold start times. You'd be better off with Middy as opposed to Express and using Powertools for Lambda instead of New Relic.

Expand full comment
Hieu Do's avatar

Thanks a lot, middy is cool. From what I read it could be 10ms cold start, correct? I’ll do some POC and we’ll see. Powertools seem like a lot of works compared to what we’ve already had OOTB and built along the way with New Relic, so it’s for another day.

[Update] I could not find reliable source on middy cold start benchmark, but it seems like ~400ms for Lambda wrapper is a pretty normal standard? If I could choose again, I would still have chosen ExpressJS because it just eases the local development for most NodeJS developers.

Expand full comment
Andrzej K's avatar

I get under 200ms cold starts with middy. Try my aws cdk middy starter - https://github.com/AndrzejKomarnicki/awscdk-nodejsfunction-middy

It's setup for function url, but types are interchangeable with api gw v2. It also already comes with Idempotency support through powertools.

Expand full comment
Hieu Do's avatar

Thanks, that's pretty optimized. My Lambda is using 512MB + NodeJS 18 setup, according to the benchmark at https://maxday.github.io/lambda-perf/, it should be around ~175ms, so middy is very optimized indeed.

I would probably start using middy for future Lambdas, but existing lamba should be fine with ~400ms using ExpressJS. So thanks a lot for your comments. (As I mentioned, my application is not sensitive to cold start, so it's not my biggest concern now, but yes, NewRelic makes cold start metrics look awful)

Expand full comment
Igor Dmitriev's avatar

Hi, how do you manage overbooking with DynamoDB?

Expand full comment
Hieu Do's avatar

Hi, sorry for late reply. We use a 3rd party PMS to manage bookings (which handles overbooking). However, with DynamoDB, you can use Conditional Write to avoid overbooking.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.ConditionalUpdate

Expand full comment
Tai's avatar

Hi, what will be the cost if we're not on Free Tier?

Expand full comment
Hieu Do's avatar

AWS Lambda and DynamoDB are currently always free.

Assuming AWS one day abandons always free tier for both Lambda and DynamoDB, then it’s probably $6/month

Expand full comment
John Brian's avatar

Great article! do you use other db for transactional data or just dynamodb?

Expand full comment
Hieu Do's avatar

Thanks. We design the application with DynamoDB in mind, so there’s no need for SQL DB. DynamoDB also supports transactions and strong consistency so I don’t expect to use SQL DB any time soon. But that’s a good questions.

Expand full comment
John Brian's avatar

Wow that is cool! I’ve always been doubting whether to fully use DynamoDB, now this make me more confident. Would love to see how you design the tables if you dont mind lol. Thanks anyway!

Expand full comment