[Absolute beginner] - [Lambda Functions] - How large should a Function be?

0

My app uses lots of libraries (I am writing python 3.9, sklearn, numpy, plotly).

When I import them locally - I end up with 800Mb worth of content!

Documentation recommends far less and I was thinking if I should I break my app up into literally functions. The 'lean-ness' of function are really very appealing to me.

Do Lamba Functions get it their names literally as they shouldn't really be more than a function? How 'big' should a function be or should I be using a container instead? Can anyone give me some guidance?

asked a year ago321 views
2 Answers
1
Accepted Answer

In the Lambda documentation it talks to the limits on function size (50 MB zipped; 250 MB unzipped) so if your function needs to be larger than that then you'll need to go to a container.

That said: The smaller your function (usually through less dependencies) the better. It will load faster and (most probably) initialise quicker as well.

Otherwise, the only other advice is that functions should be (more or less) "single purpose" - that's the whole concept behind building microservices. But you can go too far down that path too. So it's a "how long is a piece of string" question - the best thing is to do what is manageable for you.

profile pictureAWS
EXPERT
answered a year ago
0

You're right I think I should break it down.

I wanted to respond and say it's so refreshing to hear someone respond with a real "there isn't really a right or wrong answer"... how far do you go with the division? 100% understand what you are saying here

I will re-evaluate my use case and rearchitect it - TBH I may even use a combination of function and container. Much appreciated.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions