Introducing the AWS X-Ray Distributed Tracing System

If you are running distributed microservices on AWS and find it challenging to troubleshoot issues as they come up, you’ll definitely want to learn more about the AWS X-Ray service. Announced in preview at the AWS re:Invent conference in November 2016, AWS X-Ray  is a new distributed tracing service. Updated at the AWS Global Summit San Francisco in April 2017, it graduated to GA (general availability) in all 14 public AWS regions.

In this post, we will give you an overview of AWS X-Ray Distributed Tracing System, Composition and Pricing.
AWS X-Ray

AWS X-Ray Distributed Tracing System Overview

AWS X-Ray helps you analyze and debug distributed applications. AWS X-Ray aids in the understanding of complex system behavior by helping you identify and troubleshoot performance issues and errors.
AWS X-Ray

Modern Engineering Challenges

Stepping back, let’s take a look at what motivates a requirement for a distributed tracing service such as AWS X-Ray.

In recent years, there has been a strong progression away from monolithic architectures toward microservices. Software applications built using microservices have multiplied rapidly, and the trend shows no signs of slowing down.

A microservices architecture is a software design pattern in which a large application is decomposed into many smaller units, each with its own simple and discrete objective. The individual microservices are designed to collaborate and coordinate over a network, typically using a lightweight mechanism such as HTTP/REST with JSON. This communication may either be synchronous or asynchronous.
Machine 1,2,3,4
Coupled with the initial emergence and now wide use of cloud platforms such as AWS, we are seeing applications becoming more and more distributed and dynamic at the infrastructure layer. A single application today could well be composed of many servers deployed across multiple regions, multiple physical facilities, multiple VPCs, and/or multiple Availability Zones. These cloud architectures are additionally highly elastic and dynamic, so they adjust to application demand in real time.
Amazon Route S3
Jeff Barr from AWS succinctly articulates the challenge that X-Ray is built to address:
“The combination of cloud computing, microservices, and asynchronous, notification-based architectures has brought forth systems that have hundreds or thousands of moving parts. The challenge of identifying and addressing performance issues in these complex systems has only grown, as has the difficulty of aggregating individual, service-level observations into meaningful top-level results. There has been no easy way for developers to “follow-the-thread” as execution traverses EC2 instances, ECS containers, microservices, AWS database and messaging services”.

AWS X-Ray Service

AWS X-Ray provides distributed tracing and monitoring support by extracting and deriving operational insights from within and across distributed systems running at scale. AWS X-Ray provides visibility into the pathways and performance of your deployed applications by providing traces of requests as they are routed through the different service touchpoints.
Highlights of the AWS X-Ray service include:

  • Visualization of complex and detailed service relationships within highly distributed applications
  • Message tracing, timelines, and pathways of call stacks at scale
  • Trace aggregation and filtering features that enable you to find performance bottlenecks and hotspots
  • Drill down and pinpoint service exceptions and errors

AWS X-Ray creates a map of services used by your application with trace data that you can use to drill down into specific services or issues. This provides a view of connections between services in your application and aggregated data for each service, including average latency and failure rates.
Within the  service map, the health of each node is represented by coloring on the ratio of successful calls to errors and faults:

  • Green = successful calls
  • Red = server faults (500 series errors)
  • Yellow = client errors (400 series errors)
  • Purple = throttling errors (429 Too Many Requests)

AWS X-Ray Service Composition

The AWS X-Ray service is made up of the following key components:
Amazon X-Ray

X-Ray SDK The AWS X-Ray SDK is used to instrument your application code.
X-Ray Daemon The AWS X-Ray daemon collects all the local trace data, batches the information up, and periodically sends it over the internet to the AWS X-Ray service. The daemon by default listens on port 2000 for UDP connections.
X-Ray API The AWS X-Ray service has an API endpoint that is used to receive the collected telemetry as delivered from the AWS X-Ray daemon.
Other Clients The AWS X-Ray service can be integrated using either the AWS SDK, the AWS CLI, or other third party provided clients.
X-Ray Console The AWS X-Ray service console is where all of the visualization magic comes together. You can log in to the AWS X-Ray service console and navigate all your collected traces.

AWS X-Ray Distributed Tracing System Pricing

Pricing for the AWS X-Ray service is very simple. First, there is a perpetual free tier that allows for the following:

  • Free for the first 100,000 traces recorded each month.
  • Free for the first 1,000,000 traces retrieved or scanned each month.

Next, actual costs are accrued after the free tier thresholds have been reached, at the following rates:

  • $5 per 1 million traces recorded ($0.000005 per trace).
  • $0.50 per 1 million traces retrieved or scanned ($0.0000005 per trace).

Instrumentation

To leverage the AWS X-Ray service you will need to instrument your application utilizing the appropriate X-Ray SDK. The X-Ray SDKs (Java, .Net, and Node.js) have been designed to be very low touch. At times, it takes no more than four lines of extra code to X-Ray enable your application.
For example, the following Node.js code would instruct X-Ray to capture and collect any downstream HTTPS requests, which would then be correlated back to the originating call:

var xray = require('aws-xray-sdk');
var http = xray.captureHTTPs(require('http'));
app.use(xray.express.openSegment('SERVICE1'));

The next Node.js example shows how to instruct X-Ray to capture and collect any downstream SQS activity:

var xray = require('aws-xray-sdk');
var aws  = require('aws-sdk');
app.use(xray.express.openSegment('SERVICE2'));
var sqs = xray.captureAWSClient(new aws.SQS());

AWS X-Ray Console

The AWS X-Ray console has two main features:

  • Service Map
  • Traces

Service Map

The Service Map is a visualization computed by AWS over collected tracing data. It quickly allows you to understand the relationships and interplay between individual services that make up your application.
AWS X-Ray
As you can see, the Service Map allows us to see the connectivity that exists between services and also highlights performance characteristics such as average response latency, etc.
The computed Service Map graph is an aggregated view of the tracing data collected based on the user selected time range. In the screenshot above, the time range has been set to the predefined value “Last 15 Minutes.”

Traces

The Traces view displays a list of individual traces. Traces can be filtered by entering a custom filter expression within the filter expression input field (top), and/or by time range. For example, we could enter the following filtered expression:

service("CALCULATOR") AND annotation.calcid = "1234"

This will find all traces that have hit the CALCULATOR service and carry a custom supplied annotation named calcid with a value set to 1234:
AWS X-Ray
From here, we can now drill down into the details of any of the individually listed traces. Clicking on the first trace record brings up the following view:
AWS X-Ray
Here we can see that the ADD trace segment has a red status indicator and that the response code is 503 (service unavailable).
By clicking on the red status indicator icon we can drill down into even more detail:
AWS X-Ray
Here we can see additional details specific to the ADD segment such as start and end times, calculated duration, etc. We can also view message Annotations, Metadata, and/or Exceptions.

AWS X-Ray Distributed Tracing System: Getting Started

For a more comprehensive lesson on AWS X-Ray, check out the latest Cloud Academy course on AWS X-Ray:
Using AWS X-Ray to monitor a Node.js App deployed with Docker containers
AWS X-Ray
The course covers the following agenda:

  • Detailed review of the AWS X-Ray service and the functionality that it offers
  • Detailed review of the underlying mechanics of the service and how it all works together
  • Demonstration of the AWS X-Ray Console, highlighting key areas such as the Service Map and Tracing windows
  • End-to-end demonstration implementing a locally hosted Microservices based Node.js application using Docker Containers instrumented with AWS X-Ray
AWS X-Ray

Conclusion

The new AWS X-Ray service has launched to much fanfare, and it’s easy to see why. In essence, the service is well thought out and extremely easy to work with.
The AWS X-Ray Service Map console computes valuable operational insights into how your application is actually working at runtime. This allows you to compare this back to the architectural intent of your application, and deviations and latency hotspots will be quickly apparent.
Application instrumentation required to X-Ray-enable an application is generally very low touch; this coupled with the very efficient price point of the service will make it extremely appealing.

Go ahead and try it out today. It rocks!

 

Avatar

Written by

Jeremy Cook

Jeremy is currently employed as a Cloud Researcher and Trainer - and operates within CloudAcademy's content provider team authoring technical training documentation for both AWS and GCP cloud platforms. Jeremy has achieved AWS Certified Solutions Architect - Professional Level, and GCP Qualified Systems Operations Professional certifications.

Related Posts

Avatar
Michael Sheehy
— August 19, 2019

What Exactly Is a Cloud Architect and How Do You Become One?

One of the buzzwords surrounding the cloud that I'm sure you've heard is "Cloud Architect." In this article, I will outline my understanding of what a cloud architect does and I'll analyze the skills and certifications necessary to become one. I will also list some of the types of jobs ...

Read more
  • AWS
  • Cloud Computing
Avatar
Andrew Larkin
— August 13, 2019

Content Roadmap: AZ-500, ITIL 4, MS-100, Google Cloud Associate Engineer, and More

Last month, Cloud Academy joined forces with QA, the UK’s largest B2B skills provider, and it put us in an excellent position to solve a massive skills gap problem. As a result of this collaboration, you will see our training library grow with additions from QA’s massive catalog of 500+...

Read more
  • AWS
  • Azure
  • content roadmap
  • Google Cloud Platform
Avatar
Adam Hawkins
— August 9, 2019

DevSecOps: How to Secure DevOps Environments

Security has been a friction point when discussing DevOps. This stems from the assumption that DevOps teams move too fast to handle security concerns. This makes sense if Information Security (InfoSec) is separate from the DevOps value stream, or if development velocity exceeds the band...

Read more
  • AWS
  • cloud security
  • DevOps
  • DevSecOps
  • Security
Avatar
Stefano Giacone
— August 8, 2019

Test Your Cloud Knowledge on AWS, Azure, or Google Cloud Platform

Cloud skills are in demand | In today's digital era, employers are constantly seeking skilled professionals with working knowledge of AWS, Azure, and Google Cloud Platform. According to the 2019 Trends in Cloud Transformation report by 451 Research: Business and IT transformations re...

Read more
  • AWS
  • Cloud skills
  • Google Cloud
  • Microsoft Azure
Avatar
Andrew Larkin
— August 7, 2019

Disadvantages of Cloud Computing

If you want to deliver digital services of any kind, you’ll need to estimate all types of resources, not the least of which are CPU, memory, storage, and network connectivity. Which resources you choose for your delivery —  cloud-based or local — is up to you. But you’ll definitely want...

Read more
  • AWS
  • Azure
  • Cloud Computing
  • Google Cloud Platform
Joe Nemer
Joe Nemer
— August 6, 2019

Google Cloud vs AWS: A Comparison (or can they be compared?)

The "Google Cloud vs AWS" argument used to be a common discussion among our members, but is this still really a thing? You may already know that there are three major players in the public cloud platforms arena: Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP)...

Read more
  • AWS
  • Google Cloud Platform
  • Kubernetes
Avatar
Stuart Scott
— July 29, 2019

Deployment Orchestration with AWS Elastic Beanstalk

If you're responsible for the development and deployment of web applications within your AWS environment for your organization, then it's likely you've heard of AWS Elastic Beanstalk. If you are new to this service, or simply need to know a bit more about the service and the benefits th...

Read more
  • AWS
  • elastic beanstalk
Avatar
Stuart Scott
— July 26, 2019

How to Use & Install the AWS CLI

What is the AWS CLI? | The AWS Command Line Interface (CLI) is for managing your AWS services from a terminal session on your own client, allowing you to control and configure multiple AWS services and implement a level of automation. If you’ve been using AWS for some time and feel...

Read more
  • AWS
  • AWS CLI
  • Command line interface
Alisha Reyes
Alisha Reyes
— July 22, 2019

Cloud Academy’s Blog Digest: July 2019

July has been a very exciting month for us at Cloud Academy. On July 10, we officially joined forces with QA, the UK’s largest B2B skills provider (read the announcement). Over the coming weeks, you will see additions from QA’s massive catalog of 500+ certification courses and 1500+ ins...

Read more
  • AWS
  • Azure
  • Cloud Academy
  • Cybersecurity
  • DevOps
  • Kubernetes
Avatar
Stuart Scott
— July 18, 2019

AWS Fundamentals: Understanding Compute, Storage, Database, Networking & Security

If you are just starting out on your journey toward mastering AWS cloud computing, then your first stop should be to understand the AWS fundamentals. This will enable you to get a solid foundation to then expand your knowledge across the entire AWS service catalog.   It can be both d...

Read more
  • AWS
  • Compute
  • Database
  • fundamentals
  • networking
  • Security
  • Storage
Avatar
Adam Hawkins
— July 17, 2019

How to Become a DevOps Engineer

The DevOps Handbook introduces DevOps as a framework for improving the process for converting a business hypothesis into a technology-enabled service that delivers value to the customer. This process is called the value stream. Accelerate finds that applying DevOps principles of flow, f...

Read more
  • AWS
  • AWS Certifications
  • DevOps
  • DevOps Foundation Certification
  • Engineer
  • Kubernetes
Avatar
Vineet Badola
— July 15, 2019

AWS AMI Virtualization Types: HVM vs PV (Paravirtual VS Hardware VM)

Amazon Machine Images (AWS AMI) offers two types of virtualization: Paravirtual (PV) and Hardware Virtual Machine (HVM). Each solution offers its own advantages. When we’re using AWS, it’s easy for someone — almost without thinking —  to choose which AMI flavor seems best when spinning...

Read more
  • AWS
  • Hardware Virtual Machine
  • Paravirtual
  • Virtualization