This content is part of the Essential Guide: AWS Lambda architecture brings serverless to enterprise cloud
Manage Learn to apply best practices and optimize your operations.

Visualize your AWS Lambda deployment for serverless harmony

As with any AWS resource, a Lambda function interacts with a variety of services and capabilities. Graph databases help enterprises get around AWS' lack of support for Lambda visualization.

Lambda is Amazon's entry in the serverless computing marketplace. Instead of provisioning a set of servers or even running one of AWS' many as a service products, a developer creates a set of Lambda functions that run in response to events. There is nothing to provision -- AWS provides the entire infrastructure to detect and generate events and to fire up functions in an AWS Lambda deployment.

AWS Lambda functions can be written in Python, Node.js or any of the Java Virtual Machine languages. AWS Lambda functions can even create Alexa skills for Amazon Echo.

As powerful as they are, tooling support lacks when writing Lambda functions at large scale. In this context, scale does not refer to the number of times a given function is invoked. Instead, it refers to creating a system with a large number of AWS Lambda functions that work together in concert. If a developer has one or several dozen functions working together, there is little to no support for visualizing the overall system. But developers can work around the lack of support to visualize their AWS Lambda deployment.

The first part of the system involves annotating each function to indicate the event to which it responds -- each function responds to a single event -- and the set of events it might, in turn, generate. IT shops can use their current code style tooling to enforce annotations.

Next, the system scrapes the source directory of the AWS Lambda deployment to create a CSV list of the events and functions.

If a developer has one or several dozen functions working together, there is little to no support for visualizing the overall system. But developers can work around the lack of support to visualize their AWS Lambda deployment.

Lastly, this CSV list feeds into a graph database, such as Neo4j, to create a graph of the Lambda function interactions. This graph represents the system architecture. Graph databases represent both nodes and edges as first-class entities, allowing for a natural representation of relationships, such as :event > invokes :lambda. Most graph databases also offer a visual representation of the data as part of their GUI.

There are many ways to run Neo4j, including loading it on a Linux machine, running it within Docker or using a hosting service, such as Graphene, which offers a free tier of Neo4j as a service. For this example, we'll download the Community Edition of Neo4j for Mac. Once the database is running, paste the contents of the previously generated CSV file into Neo4j's cipher tool to load the events, functions and their relationships.

create (S3:AWS {name:'AWS-S3'})

create (NewFileEvent:Event {name:'new S3 event'})

create (NewS3FileLambda:Lambda {name:'new S3 file lambda'})

CREATE (S3)-[:EMITTED]->(NewFileEvent)

create (NewFileEvent:Event)-[:INVOKED]->(newS3FileLambda:Lambda)

create ('new S3 event')-[:INVOKED]->('new S3 file lambda')


create index on :AWS (name)

create index on :Event (name)

create index on :Lambda (name)

match(aws:AWS {name:'AWS-S3'}), (emitted: Event {name:'new S3 event'}) create (aws)-[:EMITED]->(emitted)

match(event:Event {name:'new S3 event'}), (invoked: Lambda {name:'new S3 file lambda'}) create (event)-[:INVOKED]->(invoked)

match(lambda: Lambda {name:'new S3 file lambda'}), (aws: AWS{name:'AWS-SNS'}) create (lambda)-[:CALLED]->(aws)

Example of the build process.
Neo4j visualizes a CSV file including events and functions.

Neo4j represents the data as an object graph, which allows us to visually see the interconnections between various events and functions. This gives us the system-level view and allows a user to see isolated nodes and potential cycles.

A Neo4j Lambda graph.
An event and function are represented on a graph database.

Being able to visualize dozens of events and functions in an AWS Lambda deployment provides powerful insights into the overall system. Annotating the edges with information about the relative invocation counts that can be obtained from Amazon CloudWatch logs can further improve the system. Logs can identify hot spots in the running system.

Next Steps

Set up and configure a Lambda function

Avoid these common AWS Lambda mistakes

Generate an HTTP response header in Lambda

Dig Deeper on AWS Lambda

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Which Lambda code style guidelines does your IT shop follow?