Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One Lambda Function OR Multiple Lambda Functions

Can I write one Lambda Function to Handle Multiple REST API Requests. I have my data in Dynamo DB

Flow: API Gateway-->Lambda Function-->Dynamo DB Example:

Request1:GET Method-Need to pull data from Table1
/device/{device_id}/start/{start_date}/end/{end_date}/events


Request2:GET Method-Need to pull data from Table2
/device/{device_id}/start/{start_date}/end/{end_date}/event_count

Request3:POST Method-Need to put data from Table3
/device/{device_id}/start/{start_date}/end/{end_date}/fault_events

What is the best solution should I write 3 different lambda functions to handle 3 different requests or can I handle all the 3 requests in one BIG Lambda Function.

like image 962
Rajashekar Reddy Avatar asked Feb 03 '20 09:02

Rajashekar Reddy


People also ask

Can One Lambda have multiple functions?

> You can definitely achieve multiple lambda functions from one code base using the Lambda Bootstrapper and the custom runtime feature.

Can one Lambda trigger another Lambda?

In order to allow the ParentFunction to call the ChildFunction, we need to provide the ParentFunction with specific rights to call another lambda function. This can be done by adding specific policies to a role and then assign that role to the lambda function.

How many Lambda functions can you have?

The default concurrency limit per AWS Region is 1,000 invocations at any given time. The default burst concurrency quota per Region is between 500 and 3,000, which varies per Region. There is no maximum concurrency limit for Lambda functions.


1 Answers

Yes, you can have one Lambda function that handle more than one API. The question is why?

Doing this is considered (almost) an anti-pattern as you won't be able to scale independently the various scenario.

These are two slides from the link pasted above from Chris Munns talk at last re:invent and I strongly agree.

enter image description here enter image description here

like image 188
BAD_SEED Avatar answered Sep 21 '22 06:09

BAD_SEED