Mass Order Processing Lambda Best Practices

Hi,

I am running a cron job every 12 hours on aws lambda to do some processing on orders that have come through. It gets the orders for the past 12 hours, and then sends out a questionnaire. I’ll be processing up to 1000 orders on each invocation, and it may become larger. Right now, it’s all processed through one lambda function. Each order has a couple of api calls that it has to make too, in order to obtain more information about the order, and then to send the questionnaire.

My question is, what is the best practice for scaling, or how would other people handle it? Here are some options I have thought of.

  1. I know lambdas have a 15 minute max execution. I haven’t hit that, and probably won’t for a while. It could just keep scaling until that is hit.
  2. Have 1 lambda to obtain all of the orders, and then have that one invoke another lambda for execution of each order.
  3. Set the cron to run more often, for example once an hour as opposed to very 12 hours.

It’s working currently, but I’m trying to learn more about best practices and what other options might be.

Thanks!

if it works why change it?

also depends whether you want to send a questionnaire on every order, or is it on first order only?

i would make it part of the order process, i.e. user makes order, payment received, trigger questionnaire function etc…

if you have many different api calls, maybe you can split these within individual functions and wire them together in one order-workflow step function - this way you are able to track at what stage each order is at.