More Related Content Similar to Debugging Modern Applications: Introduction to AWS X-Ray (20) More from Amazon Web Services (20) Debugging Modern Applications: Introduction to AWS X-Ray1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Debugging Modern Applications: Introduction to AWS X-Ray
Abhishek Singh,
Sr. Manager, Product Management
2. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
What to expect from the session
Overview
Use Cases
Concepts
Getting Started
Demo
Q&A
3. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Debugging Applications
4. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Traditional Debugging
Developer Local Test
Developer
Add
Breakpoints
Add Log
Statements
5. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
The traditional process of debugging doesn’t scale well for production applications or
those built using a service-oriented, microservice, or serverless architecture
It’s tedious, repetitive, and time consuming.
6. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Monolithic
Monolithic vs. Service Oriented Architecture
Service Oriented Architecture
7. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Drawbacks of Monolithic Architecture
Hard to Iterate Fast CI/CD Time ConsumingHard to scale Efficiently
Reliability Challenges
8. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Benefits of Service Oriented Architecture
Increased Agility Easy to Scale Improved Innovation
Reduced Human Errors
9. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Monolithic vs. Service Oriented Applications
Move to service oriented (microservices) and serverless
architectures to overcome the drawbacks of a monolithic
application architecture
But microservices come with their own set of challenges
10. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Challenges
• Services such as AWS Lambda, Amazon EC2 Container Service, AWS
Elastic Beanstalk, AWS CloudFormation, etc. make it easier to deploy and
manage applications consisting of hundreds of services
Deploying and managing service oriented applications can be
more work compared to monolithic applications
Still hard to debug application issues in production applications due to:
Cross-service interactions
Varying log formats across services
Collecting, aggregating, and collating logs from services
11. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Log Centric Approach
service 1 logs
service 2 logs
service 3 logs
user
12. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
User Centric Approach
user
Amazon API
Gateway
AWS Lambda
Amazon
DynamoDB
Amazon
SQS queue
13. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify Performance
Bottlenecks
How does AWS X-Ray help?
Pinpoint Specific
Service Issues
Identify Errors Identify Impact to Users
14. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Use Cases
15. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Visualize service call graph
16. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify impact
17. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify performance bottlenecks
18. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify performance bottlenecks
19. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify performance bottlenecks
20. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Identify performance bottlenecks
21. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Pinpoint issues
22. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Pinpoint issues
23. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Pinpoint issues
24. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
AWS Lambda
25. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
AWS Lambda
26. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Advanced Use Cases
Use off-cloud Custom Payload Deep Linking Custom Apps via
API
Filter Expressions
27. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
How does AWS X-Ray work?
28. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray Service
29. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray SDK
Enables you to get started quickly without having to manually instrument your
application code to log metadata about requests
Available for Java, .NET, and Node.js
Adds filters to automatically captures metadata for calls to:
AWS services using the AWS SDK
Non-AWS services over HTTP and HTTPS
Databases (MySQL, PostgreSQL, and Amazon DynamoDB)
Queues (Amazon SQS)
30. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray Daemon
Receives data from the SDK over UDP and acts as a local buffer. Data
is flushed to the backend every second or when the local buffer fills.
Available for Amazon Linux AMI, RHEL, Ubuntu, OS X, and Windows.
Can be run anywhere as long as AWS credentials are provided (e.g.: EC2,
ECS, on premise, developer machine, etc.)
31. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
App & X-Ray
SDK
EC2 Instance
X-Ray
Daemon
Localhost
UDP
X-Ray API
HTTPS
HTTPS
X-Ray Console
App & X-Ray
SDK
Server
X-Ray
Daemon
Localhost
UDP
EC2 Role
AWS
Credentials
DevOps Team
HTTPS
X-Ray Workflow
32. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Concepts
33. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray Concepts
Trace End-to-end data related a single request across services
Segments Portions of the trace that correspond to a single service
Sub-segments Remote call or local compute sections within a service
Annotations Business data that can be used to filter traces
Metadata Business data that can be added to the trace but not used for filtering traces
Errors Normalized error message and stack trace
Sampling Percentage of requests to your application to capture as traces
34. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray Concepts
user
Amazon API
Gateway
AWS Lambda
Amazon
DynamoDB
Amazon
SQS queue
35. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Sampling Configuration
{
"rules": {
“payment": {
"id": 1,
"service_name": "*",
"http_method": "*",
"url_path": "/api/payment/*",
"fixed_target": 0,
"rate": 1.00
},
"base": {
"id": 2,
"service_name": "*",
"http_method": "*",
"url_path": "*",
"fixed_target": 1,
"rate": 0.1
}
}
}
This example defines two rules.
The first rule applies a 100 percent sampling rate
with no minimum number of requests to trace to
requests with paths under /api/payment
The second overrides the default sampling rule
with a rule that traces the first request each
second and 10 percent of additional requests.
36. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
APIs
37. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray API
X-Ray provides a set of APIs to enable you to send, filter, and retrieve
trace data
You can send trace data directly to the service without having to use
our SDKs (i.e.: you can write your own SDKs for languages not
currently supported)
Raw trace data is available using batch get APIs
You can build your own data analysis applications on top of the data
collected by X-Ray
38. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray API
PutTraceSegments Uploads segment documents to AWS X-Ray
BatchGetTraces Retrieves a list of traces specified by ID
GetServiceGraph Retrieves a document that describes services in your application and their
connections
GetTraceSummaries Retrieves IDs and metadata for traces available for a specified time frame
using an optional filter
39. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Segment Document
Minimal example
{
"name" : "example.com",
"id" : "70de5b6f19ff9a0a",
"start_time" : 1.478293361271E9,
"trace_id" : "1-581cf771-a006649127e371903a2de979",
"end_time" : 1.478293361449E9
}
Example showing an in-progress segment
{
"name" : "example.com",
"id" : "70de5b6f19ff9a0b",
"start_time" : 1.478293361271E9,
"trace_id" : "1-581cf771-a006649127e371903a2de979",
“in_progress”: true
}
40. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Getting Started
41. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Agent installation (Amazon EC2 Linux)
#!/bin/bash
curl https://s3.dualstack.us-east-1.amazonaws.com/aws-xray-assets.us-east-1/xray-daemon/aws-xray-
daemon-1.x.rpm -o /home/ec2-user/xray.rpm
yum install -y /home/ec2-user/xray.rpm
42. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Agent Installation (Amazon EC2 Windows)
43. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Agent installation (Amazon ECS)
44. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
App Instrumentation (Node.js)
//Add aws-xray-sdk package to package.json
var XRay = require('aws-xray-sdk');
var AWS = captureAWS(require('aws-sdk'));
…
XRay.config([XRay.plugins.EC2]);
XRay.captureHTTPs(http);
XRay.setDefaultName('myfrontend-dev');
…
app.use(XRay.express.openSegment());
app.get('/', function(req, res)
…
app.get('/blog', function(req, res)
…
app.use(XRay.express.closeSegment());
45. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Demo
46. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
X-Ray Pricing
Free tier
The first 100,000 traces recorded are free
The first 1,000,000 traces retrieved or scanned are free
Additional charges
Beyond the free tier, traces recorded cost $5.00 per million traces.
Beyond the free tier, traces retrieved or scanned cost $0.50 per million traces.
47. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Availability
Go to https://aws.amazon.com/xray to learn more
Documentation: http://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html
.NET Sample: https://github.com/awslabs/aws-xray-dotnet-webapp
Java Sample: https://github.com/awslabs/eb-java-scorekeep/tree/xray
Node.js Sample: https://github.com/awslabs/eb-node-express-sample/tree/xray
The AWS X-Ray service is available in 14 regions today.
48. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved
aws.amazon.com/activate
Everything and Anything Startups
Need to Get Started on AWS