✕ סגור 
צור קשר
תודה על ההתעניינות .

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form

The curse of dead Lambda functions

Nitzan Shapira
|
בינונית
|
Mar 3, 2018
alt="facebook"alt="linkedin"להרשמה לניוזלטר
‍Photo by David Clode on Unsplash

Most developers agree that AWS Lambda is a great service. It’s cheap and easy to start with. It’s scalable. And most importantly — it just works.

But there are challenges as well. One the common challenges is to keep track of all your functions, which often leads to “dead” functions.

A dead Lambda function is a function that has been cold for a long time (makes sense, doesn’t it?). Usually this function is useless, and should probably be removed.

But it’s not just about keeping your resources nice and clean — there are real issues with dead functions:

1. Management: code and error management are common issues in every complex serverless architecture — but when you add dozens of unused functions, things become much more complicated.

2. Security: more functions means more opportunities for an attacker to try and take advantage of your code. A function that hasn’t been used in a long time is most likely outdated and may have wrong permissions or contain old external libraries.

3. Performance analysis: when trying to obtain a deep understanding of the entire architecture, such as the end-to-end performance, or the costs of specific transactions, having unused resources makes everything a lot harder.

So we can agree that dead Lambdas are bad. What can we do about it?

‍Photo by G. Crescoli on Unsplash

Solution

In order to solve this problem, we at Epsagon have created an open-source project: list-lambdas. It’s a Python script which enumerates your Lambda functions across all AWS regions and provides useful information, such as the function’s memory settings, its last invocation time and more. It can help identifying dead Lambda functions easily.

You can access it via GitHub:

Setup

git clone [email protected]:epsagon/list-lambdas.git

cd list-lambdas/

pip install -r requirements.txt

python list_lambdas.py

Example Outputs

‍CLI output

‍CSV output

Example Usage

The usage is straightforward using the CLI.

Filter only Lambda functions that have not been active in the last 10 days:

python list_lambdas.py --inactive-days-filter 10

Output table (with extra data) to a CSV file:

python list_lambdas.py --csv lambdas.csv

Print extended information to the screen (same as in the CSV file):

python list_lambdas.py --all

Sort by a chosen column (e.g. by last invocation time):

python list_lambdas.py --sort-by last-invocation

Conclusion

Dead serverless functions are a real issue — but it can be handled rather easily. Best practices such as giving your functions meaningful names are relevant in serverless as well. Tools like list-lambdas and others can help keep your architecture clean and steady, which ultimately leads to better software. We will keep adding features to the project, and plan to release additional projects in the near future.

We are curious for your feedback! Do you have additional features in mind? Please tell us about them, and feel free to contribute to the project!

Interested in learning more about dynamic monitoring for serverless architectures? Sign up for our beta at https://epsagon.com.

•  AWS

•  Serverless

•  AWS Lambda

•  Monitoring

•  Programming

Nitzan Shapira

Co-founder and CEO 

@Epsagon. Engineer, entrepreneur, curious.

‍Photo by David Clode on Unsplash

Most developers agree that AWS Lambda is a great service. It’s cheap and easy to start with. It’s scalable. And most importantly — it just works.

But there are challenges as well. One the common challenges is to keep track of all your functions, which often leads to “dead” functions.

A dead Lambda function is a function that has been cold for a long time (makes sense, doesn’t it?). Usually this function is useless, and should probably be removed.

But it’s not just about keeping your resources nice and clean — there are real issues with dead functions:

1. Management: code and error management are common issues in every complex serverless architecture — but when you add dozens of unused functions, things become much more complicated.

2. Security: more functions means more opportunities for an attacker to try and take advantage of your code. A function that hasn’t been used in a long time is most likely outdated and may have wrong permissions or contain old external libraries.

3. Performance analysis: when trying to obtain a deep understanding of the entire architecture, such as the end-to-end performance, or the costs of specific transactions, having unused resources makes everything a lot harder.

So we can agree that dead Lambdas are bad. What can we do about it?

‍Photo by G. Crescoli on Unsplash

Solution

In order to solve this problem, we at Epsagon have created an open-source project: list-lambdas. It’s a Python script which enumerates your Lambda functions across all AWS regions and provides useful information, such as the function’s memory settings, its last invocation time and more. It can help identifying dead Lambda functions easily.

You can access it via GitHub:

Setup

git clone [email protected]:epsagon/list-lambdas.git

cd list-lambdas/

pip install -r requirements.txt

python list_lambdas.py

Example Outputs

‍CLI output

‍CSV output

Example Usage

The usage is straightforward using the CLI.

Filter only Lambda functions that have not been active in the last 10 days:

python list_lambdas.py --inactive-days-filter 10

Output table (with extra data) to a CSV file:

python list_lambdas.py --csv lambdas.csv

Print extended information to the screen (same as in the CSV file):

python list_lambdas.py --all

Sort by a chosen column (e.g. by last invocation time):

python list_lambdas.py --sort-by last-invocation

Conclusion

Dead serverless functions are a real issue — but it can be handled rather easily. Best practices such as giving your functions meaningful names are relevant in serverless as well. Tools like list-lambdas and others can help keep your architecture clean and steady, which ultimately leads to better software. We will keep adding features to the project, and plan to release additional projects in the near future.

We are curious for your feedback! Do you have additional features in mind? Please tell us about them, and feel free to contribute to the project!

Interested in learning more about dynamic monitoring for serverless architectures? Sign up for our beta at https://epsagon.com.

•  AWS

•  Serverless

•  AWS Lambda

•  Monitoring

•  Programming

Nitzan Shapira

Co-founder and CEO 

@Epsagon. Engineer, entrepreneur, curious.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
בואו נעבוד ביחד
צרו קשר