AI Tools in Marketing - A comparative Study

How to monitor and manage a serverless web app?

Serverless is not a new concept for those who know cloud computing. The amateur perception of the term ‘serverless’ is the absence of a server. It sounds weird, 😲. Doesn’t it? How can an app run without a server?

Well, in the last few years, the serverless evolution has gained momentum for solid reasons.

According to AWS, “Serverless computing allows you to build and run applications and services without thinking about servers.” You don’t need to provision, scale, and manage any server in serverless web applications. Just think about the time and money you would be saving. Plus, you can focus on your core products and services.

The simplistic architecture of serverless web app looks like this:

Fig:AWS

In this architecture, the app is using AWS LAMBDA for serverless computing.

A Serverless web app has many advantages. It decreases your time to market and cuts down the cost. It gives you scalability and allocates more time to enhance the user experience. With such benefits, monitoring and managing serverless web apps is also crucial. Let’s discuss how to monitor and manage a serverless web app:

If you don’t add any third party, getting visibility of the incidents in a serverless app is difficult. Hence, monitoring is the key pillar from the operations perspective.

Monitoring serverless is critical

Monitoring your serverless app lets you know if your system is working properly based on the following parameters:
- Errors: Every request creating an error result
- Latency: How much time to process a request?
- Traffic: How many requests the resource can handle?

Such a monitoring strategy allows you to detect the services with the highest errors, performance degradation, and scaling issues. Prominent third-party service providers offer serverless deployment as a Function as a Service (FaaS). 

Some of the popular cloud-hosted managed FaaS services are:

- AWS Lambda
- GCP Functions
- Azure Functions

For serverless, running locally and line-wise debugging was a struggle. But AWS Toolkit has solved this problem. Multiple Lambda functions and multiple services are involved to create the solution.

Debugging and triaging isn’t possible without proper log consolidation. This brings up the challenge of ensuring proper logging format and transaction IDs that are used across various functions.

Though the server resource monitoring goes away in a server-less application, you need to monitor some key attributes including concurrent Lambda executions, number of DB connections or connections to other such services, average and max time taken by Lambda function, etc.

Following are some common monitoring strategies for a serverless web application: 

Monitor specific Lambda attributes

While in a server based application you need to worry about the resource usage like Compute, Memory, and Network. But in serverless web application, care for the following attributes like:
- Failures and retries of the Lambda functions
- Lambda function runs up to 15 minutes per execution
- Underline base services of your application e.g. if you are using S3 and Cloudfront to deploy your UI piece of the code then you would have to monitor the status of those services as your application availability depends on those services availability.

Use serverless web app monitoring tools

The serverless segment of the IT industry provides plenty of monitoring tools. You can integrate these tools with serverless runtime platforms. Such integration enables the tools to collect data for debugging and better visibility. Some of the most popular monitoring tools are SLS-dev-tools, SenseDeep, Lumigo, Serverless Framework Pro, etc.

Analyze all relevant logs

When all monitoring parameters detect problems, you need to troubleshoot them. The first step is to consult and analyze all relevant logs. You can generate the logs with custom loggings, prints, etc. These logs sometimes contain crucial information which helps in debugging the problems. You must use search filters across all logs to get what you are looking for. Once you find the correct log file, you can solve the problem faster. 

Apply distributed tracing

Distributed tracing helps you to relate the events with the captured logs. If you can execute distributed tracing successfully, you can find the root cause of the errors. You can collect every trace and gather them together as a whole part of the execution in serverless web applications. You need the followings to analyze the distributed traces:

- A distributed tracing instrumentation library
- A distributed tracing engine

Implementing OpenTracing is the most common approach while instrumenting the code.
It is a specification, which defines the structure of traces across various programming languages for distributed tracing. Spans - an individual implemented function in a distributed system defines the traces in OpenTracing. For example: 

span = tracer.start_span(operation_name='our operation')
scope = tracer.scope_manager.activate(span, True)
try:
# Do things that may trigger a KeyError.
except KeyError as e:
scope.set_tag('keyerror', f'{e}')
finally:
scope.finish()

It is advisable to use a universal standard across all your services and use a vendor-neutral API. You don’t need to make huge code changes while switching between various traces engines with such API. But developers need to maintain span and declaration related to traces across the entire code base. Post instrumentation, you can publish and capture the traces into a distributed traces engine.

An engine like Jaeger organizes the traces in a timeline: 

Image: cloudacademy

Get alerts to an incident management platform

Getting alerts on an incident management platform triggers notifications. Taking action becomes easy. Some of the known alerting platforms are PagerDuty, OpsGenie, Slack, etc. While choosing such a platform, you need to ensure that you can configure the alerts depending on the issue type, involved resources, and destinations.

Any dedicated monitoring tool has the following alert capabilities:

- Alert if the function gets timeout
- Alert on KPIs of specific business flow
- Alert on performance degradation of any resource

Build your first serverless web app with AAIC

We at Applied AI consulting help to build serverless apps from the scratch as a dedicated AWS Consulting Partner. Our engineering team is AWS certified and comprises experienced developers and architects. We create customized architecture and develop the app suiting all your needs. By collaborating with us, you get the fastest agile development cycle powered by DevOps experts and AWS Lambda certified professionals. Decrease time to market, grow, scale, and release your serverless web apps faster with us.

Talk to our experts or drop us an email to understand our engineering services

  • Sky Loft, Creaticity Mall, Off,
    Airport Rd, opposite Golf Course, Shastrinagar, Yerawada, Pune, Maharashtra - 411006
AAIC
Accelerators
Resources
Contact Us

© Copyright 2021 AppliedAIConsulting - All Rights Reserved