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 Distributed Tracing System OverviewAWS 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.
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.
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.
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:
|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).
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
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.
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.”
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:
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:
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:
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
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
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!
Which Certifications Should I Get?
As we mentioned in an earlier post, the old AWS slogan, “Cloud is the new normal” is indeed a reality today. Really, cloud has been the new normal for a while now and getting credentials has become an increasingly effective way to quickly showcase your abilities to recruiters and compan...
New Content: AWS, Azure, Typescript, Java, Docker, 13 New Labs, and Much More
This month, our Content Team released a whopping 13 new labs in real cloud environments! If you haven't tried out our labs, you might not understand why we think that number is so impressive. Our labs are not “simulated” experiences — they are real cloud environments using accounts on A...
Kickstart Your Tech Training With a Free Week on Cloud Academy
Are you looking to make a jump in your technical career? Want to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Kubernetes, Python, or another in-demand skill?Then you'll want to mark your calendar. Starting Monday, June 22 at 12:00 a.m. PDT (3:00 a.m. EDT), ...
New Content: AZ-500 and AZ-400 Updates, 3 Google Professional Exam Preps, Practical ML Learning Path, C# Programming, and More
This month, our Content Team released tons of new content and labs in real cloud environments. Not only that, but we introduced our very first highly interactive "Office Hours" webinar. This webinar, Acing the AWS Solutions Architect Associate Certification, started with a quick overvie...
Azure vs. AWS: Which Certification Provides the Brighter Future?
More and more companies are using cloud services, prompting more and more people to switch their current IT position to something cloud-related. The problem is most people only have that much time after work to learn new technologies, and there are plenty of cloud services that you can ...
Blog Digest: 5 Reasons to Get AWS Certified, OWASP Top 10, Getting Started with VPCs, Top 10 Soft Skills, and More
Thank you for being a valued member of our community! We recently sent out a short survey to understand what type of content you would like us to add to Cloud Academy, and we want to thank everyone who gave us their input. If you would like to complete the survey, it's not too late. It ...
New Content: Alibaba, Azure Cert Prep: AI-100, AZ-104, AZ-204 & AZ-400, Amazon Athena Playground, Google Cloud Developer Challenge, and much more
This month, our Content Team released 8 new learning paths, 4 courses, 7 labs in real cloud environments, and 4 new knowledge check assessments. Not only that, but we introduced our very first course on Alibaba Cloud, and our expert instructors are working 'round the clock to create 6 n...
Top 5 Reasons to Get AWS Certified Right Now
Cloud computing trends are on the rise and have been for some time already. Fortunately, it’s never too late to start learning cloud computing. Skills like AWS and others associated with cloud computing are in high demand because cloud technologies have become crucial for many businesse...
Introducing Our Newest Lab Environments: Lab Playgrounds
Want to train in a real cloud environment, but feel slowed down by spinning up your own deployments? When you consider security or pricing costs, it can be costly and challenging to get up to speed quickly for self-training. To solve this problem, Cloud Academy created a new suite of la...
Blog Digest: AWS Breaking News, Azure DevOps, AWS Study Guide, 8 Ways to Prevent a Ransomware Attack, and More
New articles by topicAWS Azure Data Science Google Cloud Cloud Adoption Platform Updates & New Content Security Women in TechAWSBreaking News: All AWS Certification Exams Now Available Online As an Advanced AWS Technology Partner, C...
AWS Certified Solutions Architect Associate: A Study Guide
Want to take a really impactful step in your technical career? Explore the AWS Solutions Architect Associate certificate. Its new version (SAA-C02) was released on March 23, 2020, though you can still take SAA-C01 through July 1, 2020. This post will focus on version SAA-C02.The AWS...
New on Cloud Academy: AWS Solutions Architect Exam Prep, Azure Courses, GCP Engineer Exam Prep, Programming, and More
Free content on Cloud Academy More and more customers are relying on our technology and content to keep upskilling their people in these months, and we are doing our best to keep supporting them. While the world fights the COVID-19 pandemic, we wanted to make a small contribution to he...