[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?

已提問 2 年前檢視次數 355 次
2 個答案
1
已接受的答案

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
專家
已回答 2 年前
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.

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南