Mark As Completed Discussion

What are metrics and why do they matter?

Generally speaking, metrics are simply quantitative measures used for comparing, tracking, and understanding the performance of a specific process. They are highly beneficial because they help us evaluate our progress and overall efficiency, or simply put – tell us where our problems are so that we can focus on fixing them.

Okay, but do we need them for our web pages and applications?

The short answer is – yes.

Actually, measuring our website performance has never been more important since nowadays the users are very demanding – they want high-resolution graphics, interactive design, and extremely fast loading speeds. And as a matter of fact, how are we going to know if our website is functioning properly or if we need improvements if we don’t look at the numbers? Let's take a look at some of the statistics regarding user experience and satisfaction.

Introduction

There exist many web performance-related metrics that can measure our webpage or application performance, but the most crucial and commonly utilized ones are:

1. Latency

Latency, or lag, is the total time needed for a data package to get from one point on a network to another and is mostly measured as the delay between a user's action and the response of the application to that action. This measurement can tell us how in how many milliseconds (ms) our application or website loads or responds to users’ requests. The structure of one such request-response HTTP transaction is shown in the diagram below.

Latency

An in-depth explanation of the protocol is beyond the scope of this tutorial, but roughly speaking, this is what happens during one HTTP transaction:

1 ) The client contacts the server at a designated port number and then it sends a document request

2 ) The client sends header information to inform the server of the configuration and document preference

3 ) The server replies with a message that it got the request

4 ) The server gives header information to tell the client about itself and the document that the client requested

5 ) The response data is sent

Having no latency is practically impossible due to the way networks work and communicate. However, having high latency leads to poor customer experience and ultimately - negative income implications and reviews. That’s why it’s of the utmost importance to minimize this lag as much as possible, and in order to do this, we need to focus on the main factors that may cause this lag:

  • Distance – the latency is directly proportional to the distance between the start and end node.
  • Transmission medium –the medium, i.e. the actual physical path between the communicating nodes can also influence latency. For example, using optic fibers is always a better idea than using the old cable-based networks.
  • Storage – latency may be increased when we access previously stored data since time is needed in order to process and return the requested information.

When trying to decrease latency, we should always try to optimize the aforementioned components or at least those we can control. Moreover, we should optimize pictures, compress files and avoid using render-blocking resources when possible. Another way we can improve our application performance is by using a Content Delivery Network (CDN). The main idea here is to store content closer to end-users by having many CDN servers distributed in multiple locations and thus reduce its travel time and latency respectively.

Try this exercise. Click the correct answer from the options.

Is there a way to optimize the factor of distance in order to improve latency?

Click the option that best answers the question.

  • Yes
  • No

2. Error Rates

Errors in web applications refer to the fallacies that happen while processing users’ requests. Respectively, the error rate is defined as the percentage of these error requests compared to the total number of requests and is a key indicator of the application's overall performance failure.

They can be caused by many different things and are rather unavoidable, but making sure they happen as rarely as possible is a very important part of keeping our users happy. As a matter of fact, statistics show that 75% of users leave applications and websites after only one software error, but only 1% of them actually report the problem to the company.

So, finding the problems before our users do is pretty much what we’re trying to do here, and the best way to do this is by using Real User Monitoring (RUM) tools which continuously check our system's availability, functioning, and responsiveness. RUM allows us to observe exactly how our users engage with our website or app and it provides us with a deep, top-down view of a wide range of front-end browser, backend database, and server-level issues that they might experience. Some of the most popular RUM tools are:

  • Sematext Experience
  • Dynatrace RUM
  • AppDynamics Browser RUM
  • New Relic Browser
  • Pingdom

One thing that we should always keep an eye on is the behavior of the site under different loads; having a larger number of users than its capacity is the main cause of the increased error rate.

Build your intuition. Click the correct answer from the options.

What should we use in order to get the same experience as our users are getting while using our website/application?

Click the option that best answers the question.

  • Application Power Management tools
  • Real User Monitoring tools
  • Power BI
  • Javascript

3. CPU Usage

CPU (Central Processing Unit) usage, or utilization, is a well-known performance indicator that may be used to predict how responsive a program is. CPU utilization refers to the amount of work that is being handled by the CPU, or how much of the computer’s processing resources are being used.

Monitoring this metric is crucial because having very high CPU usage causes serious performance problems and slows down the whole server. This issue is frequently caused by abruptly increased site traffic.

Almost all server and application monitoring solutions can monitor the CPU usage and provide alerts. It's crucial to keep track of them not only per server but also in aggregate across all of your application's different instances.

Some of the things we can do in order to reduce our CPU utilization are:

  • Remove high CPU plugins
  • Clean the database
  • Optimize images
  • Delete everything that’s not being used
  • Check for errors

Let's test your knowledge. Is this statement true or false?

Having too many users on the webpage/application is rarely a reason for maximized CPU usage?

Press true if you believe the statement is correct, or false otherwise.

4. Memory

Memory usage stands for the amount of memory that a webpage or an application uses while running. This metric, similarly to CPU usage, is a very good estimator of the utilization of our resources and should be closely observed and measured. By analyzing the memory usage we can decide if, for example, we’ll assign additional services to a virtual machine (VM) with low memory usage or upgrade the memory of a VM that has high memory usage.

One of the most common problems that may happen with memory utilization is a so-called memory leak. A memory leak means that your application allocates memory and uses it even when it’s no longer needed. Some of the most common reasons for a memory leak are:

  • unbound timers – timers that are running forever
  • unbound collections – references to arrays, sets, and maps that are kept forever
  • accidental global variables – undeclared variables that become global and thus never get released
  • closures – inner functions that are having a reference to outer functions’ variables.
So, as we can see on the diagram above, the leak happens when we have referenced objects that are not being used. This is a problem because the garbage collector, which is responsible for reclaiming memory that is no longer needed, cannot collect the objects that are still being referenced.

The easiest way to detect such errors is by using application-performance monitoring, alerting, and anomaly detection tools.

Build your intuition. Click the correct answer from the options.

What cannot be cause a a memory leak?

Click the option that best answers the question.

  • never-ending timers
  • variables that became global by accident and never get released
  • inner functions with references to outer functions' variables
  • high latency

These are just a couple of Application Performance Monitoring metrics and there exist many more - just take a look at the picture below! However, the aforementioned ones are a necessity for every developer who'd like to have a successful webpage or application.

Summary

One Pager Cheat Sheet

  • Using metrics to measure our website performance is essential for providing excellent user experience and satisfaction.
  • Reducing latency for improved user experience and optimizing distance, transmission media, storage resources, pictures, files and render-blocking sources, as well as using a Content Delivery Network (CDN), helps to minimize the total time needed for a data package to get from one point on a network to another.
  • By utilizing a Content Delivery Network (CDN), you can improve latency by optimizing the distance factor and gain other benefits such as improved scalability and faster redundancy.
  • Monitoring the error rate of our applications, and understanding how users engage with them, is key in ensuring their successful functioning and minimizing the chances of encountering software errors which could ultimately lead to unhappy customers.
  • We should use Real User Monitoring (RUM) tools continuously in order to observe exactly how our users engage with our website or app, identify and address potential issues, and ensure an optimal experience.
  • Monitoring CPU utilization is a crucial performance metric that must be tracked across different applications to ensure server responsiveness and avoid performance issues caused by increased traffic, which can be reduced by optimizing images, deleting unnecessary files, checking for errors, and more.
  • Too many concurrent users can lead to system overload and maximized CPU utilization, which can cause serious performance problems, so it is important to monitor the CPU utilization of the server.
  • Monitoring and detecting memory leaks is essential to efficiently utilizing resources, and can be done by using application-performance monitoring, alerting and anomaly detection tools.
  • High latency does not directly cause a memory leak, which is usually due to issues such as unbound timers, unbound collections, accidental global variables, or closures preventing the garbage collector from reclaiming objects.
  • Monitoring keyApplication Performance Metricsis essential for success in web or app development.