SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Advanced Production Debugging
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/techniques-server-debug
Presented at QCon New York
www.qconnewyork.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
About Me
Co-founder – Takipi, JVM Production Debugging.
Director, AutoCAD Web & Mobile.
Software Architect at IAI Aerospace.
Coding for the past 16 years - C++, Delphi, .NET, Java.
Focus on real-time, scalable systems.
Blogs at blog.takipi.com
Overview
Dev-stage debugging is forward-tracing.
Production debugging is focused on backtracing.
Modern production debugging poses two challenges:
• State isolation.
• Data distribution.
Agenda
1. Logging at scale.
2. Preemptive jstacks
1. Extracting state with Btrace
1. Extracting state with custom Java agents.
Best Logging Practices
1. Code context.
2. Time + duration.
3. Transactional data (for async & distributed debugging).
A primary new consumer is a log analyzer. Context trumps content.
Transactional IDs
• Modern logging is done over a multi–threads / processes.
• Generate a UUID at every thread entry point into your app – the transaction ID.
• Append the ID into each log entry.
• Try to maintain it across machines – critical for debugging Reactive and microservice apps.
[20-07 07:32:51][BRT -1473 -S4247] ERROR - Unable to retrieve data for Job
J141531. {CodeAnalysisUtil TID: Uu7XoelHfCTUUlvol6d2a9pU}
[SQS-prod_taskforce1_BRT-Executor-1-thread-2]
1. Don’t catch exceptions within loops and log them (implicit and explicit).
For long running loops this will flood the log, impede performance and bring a server down.
void readData {
while (hasNext()) {
try {
readData();
}
catch {Exception e) {
logger.errror(“error reading “ X + “ from “ Y, e);
}
}
2. Do not log Object.toString(), especially collections.
Can create an implicit loop. If needed – make sure length is limited.
Logging Performance
Thread Names
• Thread name is a mutable property.
• Can be set to hold transaction specific state.
• Some frameworks (e.g. EJB) don’t like that.
• Can be super helpful when debugging in tandem with jstack.
Thread Names (2)
For example:
Thread.currentThread().setName(
Context + TID + Params + current Time, ...);
Before:
“pool-1-thread-1″ #17 prio=5 os_prio=31
tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait()
[0x000000013ebcc000
After:
”Queue Processing Thread, MessageID: AB5CAD, type:
AnalyzeGraph, queue: ACTIVE_PROD, Transaction_ID: 5678956,
Start Time: 10/8/2014 18:34″ #17 prio=5 os_prio=31
tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait()
[0x000000013ebcc000]
Modern Stacks - Java 8
Modern Stacks - Scala
Preemptive jstack
github.com/takipi/jstack
Preemptive jstack
• A production debugging foundation.
• Presents two issues –
– Activated only in retrospect.
– No state: does not provide any variable state.
• Let’s see how we can overcome these with preemptive jstacks.
”MsgID: AB5CAD, type: Analyze, queue: ACTIVE_PROD, TID:
5678956, TS: 11/8/20014 18:34 "
#17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in
Object.wait() [0x000000013ebcc000]
Jstack Triggers
• A queue exceeds capacity.
• Throughput exceeds or drops below a threshold.
• CPU usage passes a threshold.
• Locking failures / Deadlock.
Integrate as a first class citizen with your logging infrastructure.
BTrace
• An advanced open-source tool for extracting state from a live JVM.
• Uses a Java agent and a meta-scripting language to capture state.
• Pros: Lets you probe variable state without modifying / restarting the JVM.
• Cons: read-only querying using a custom syntax and libraries.
Usage
• No JVM restart needed. Works remotely.
• btrace [-I <include-path>] [-p <port>] [-cp <classpath>] <pid> <btrace-script> [<args>]
• Example: Btrace 9550 myScript.java
• Available at: kenai.com/projects/btrace
BTrace - Restrictions
• Can not create new objects.
• Can not create new arrays.
• Can not throw exceptions.
• Can not catch exceptions.
• Can not make arbitrary instance or static method calls - only the public static methods of
com.sun.btrace.BTraceUtils class may be called from a BTrace program.
• Can not assign to static or instance fields of target program's classes and objects. But,
BTrace class can assign to it's own static fields ("trace state" can be mutated).
• Can not have instance fields and methods. Only static public void returning methods are
allowed for a BTrace class. And all fields have to be static.
• Can not have outer, inner, nested or local classes.
• Can not have synchronized blocks or synchronized methods.
• can not have loops (for, while, do..while)
• Can not extend arbitrary class (super class has to be java.lang.Object)
• Can not implement interfaces.
• Can not contains assert statements.
• Can not use class literals.
Java Agents
• An advanced technique for instrumenting code dynamically.
• The foundation of modern profiling / debugging tools.
• Two types of agents: Java and Native.
• Pros: extremely powerful technique to collect state from a live app.
• Cons: requires knowledge of creating verifiable bytecode.
Agent Types
• Java agents are written in Java. Have access to the Instrumentation BCI API.
• Native agents – written in C++.
• Have access to JVMTI – the JVM’s low-level set of APIs and capabilities.
– JIT compilation, Garbage Collection, Monitor acquisition, Exception callbacks, ..
• More complex to write.
• Platform dependent.
Java Agents
github.com/takipi/debugAgent
com.sun.tools.attach.VirtualMachine
Attach at startup: java -Xmx2G -agentlib:myAgent -jar myapp.jar start
To a live JVM using: com.sun.tools.attach.VirtualMachine Attach API.
ASMifying
ASM Bytecode Outline plug-in
takipi.com
blog.takipi.com
Questions?
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations/
techniques-server-debug

Weitere ähnliche Inhalte

Andere mochten auch

Presentación1
Presentación1Presentación1
Presentación1ericg_98
 
tarea # 1
tarea # 1tarea # 1
tarea # 1saiidy
 
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013Dr. Pedro Espino Vargas
 
Θεωριες Μαθησης & ΤΠΕ
Θεωριες Μαθησης & ΤΠΕΘεωριες Μαθησης & ΤΠΕ
Θεωριες Μαθησης & ΤΠΕGeorgia Klostraki
 
Epistemoliga
EpistemoligaEpistemoliga
EpistemoligaMARY7374
 

Andere mochten auch (8)

Rock in rio 2015
Rock in rio 2015Rock in rio 2015
Rock in rio 2015
 
Presentación1
Presentación1Presentación1
Presentación1
 
tarea # 1
tarea # 1tarea # 1
tarea # 1
 
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013
Pedro Espino Vargas y Matriz acreditacion calidad ipeba 2013
 
Ali
AliAli
Ali
 
Θεωριες Μαθησης & ΤΠΕ
Θεωριες Μαθησης & ΤΠΕΘεωριες Μαθησης & ΤΠΕ
Θεωριες Μαθησης & ΤΠΕ
 
Ler e escrever 03 04
Ler e escrever 03   04Ler e escrever 03   04
Ler e escrever 03 04
 
Epistemoliga
EpistemoligaEpistemoliga
Epistemoliga
 

Mehr von C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 

Mehr von C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Five Techniques to Improve How You Debug Servers

  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /techniques-server-debug
  • 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. About Me Co-founder – Takipi, JVM Production Debugging. Director, AutoCAD Web & Mobile. Software Architect at IAI Aerospace. Coding for the past 16 years - C++, Delphi, .NET, Java. Focus on real-time, scalable systems. Blogs at blog.takipi.com
  • 5. Overview Dev-stage debugging is forward-tracing. Production debugging is focused on backtracing. Modern production debugging poses two challenges: • State isolation. • Data distribution.
  • 6. Agenda 1. Logging at scale. 2. Preemptive jstacks 1. Extracting state with Btrace 1. Extracting state with custom Java agents.
  • 7. Best Logging Practices 1. Code context. 2. Time + duration. 3. Transactional data (for async & distributed debugging). A primary new consumer is a log analyzer. Context trumps content.
  • 8. Transactional IDs • Modern logging is done over a multi–threads / processes. • Generate a UUID at every thread entry point into your app – the transaction ID. • Append the ID into each log entry. • Try to maintain it across machines – critical for debugging Reactive and microservice apps. [20-07 07:32:51][BRT -1473 -S4247] ERROR - Unable to retrieve data for Job J141531. {CodeAnalysisUtil TID: Uu7XoelHfCTUUlvol6d2a9pU} [SQS-prod_taskforce1_BRT-Executor-1-thread-2]
  • 9. 1. Don’t catch exceptions within loops and log them (implicit and explicit). For long running loops this will flood the log, impede performance and bring a server down. void readData { while (hasNext()) { try { readData(); } catch {Exception e) { logger.errror(“error reading “ X + “ from “ Y, e); } } 2. Do not log Object.toString(), especially collections. Can create an implicit loop. If needed – make sure length is limited. Logging Performance
  • 10. Thread Names • Thread name is a mutable property. • Can be set to hold transaction specific state. • Some frameworks (e.g. EJB) don’t like that. • Can be super helpful when debugging in tandem with jstack.
  • 11. Thread Names (2) For example: Thread.currentThread().setName( Context + TID + Params + current Time, ...); Before: “pool-1-thread-1″ #17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait() [0x000000013ebcc000 After: ”Queue Processing Thread, MessageID: AB5CAD, type: AnalyzeGraph, queue: ACTIVE_PROD, Transaction_ID: 5678956, Start Time: 10/8/2014 18:34″ #17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait() [0x000000013ebcc000]
  • 12.
  • 13. Modern Stacks - Java 8
  • 15.
  • 17. Preemptive jstack • A production debugging foundation. • Presents two issues – – Activated only in retrospect. – No state: does not provide any variable state. • Let’s see how we can overcome these with preemptive jstacks.
  • 18.
  • 19.
  • 20. ”MsgID: AB5CAD, type: Analyze, queue: ACTIVE_PROD, TID: 5678956, TS: 11/8/20014 18:34 " #17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait() [0x000000013ebcc000]
  • 21. Jstack Triggers • A queue exceeds capacity. • Throughput exceeds or drops below a threshold. • CPU usage passes a threshold. • Locking failures / Deadlock. Integrate as a first class citizen with your logging infrastructure.
  • 22.
  • 23. BTrace • An advanced open-source tool for extracting state from a live JVM. • Uses a Java agent and a meta-scripting language to capture state. • Pros: Lets you probe variable state without modifying / restarting the JVM. • Cons: read-only querying using a custom syntax and libraries.
  • 24. Usage • No JVM restart needed. Works remotely. • btrace [-I <include-path>] [-p <port>] [-cp <classpath>] <pid> <btrace-script> [<args>] • Example: Btrace 9550 myScript.java • Available at: kenai.com/projects/btrace
  • 25. BTrace - Restrictions • Can not create new objects. • Can not create new arrays. • Can not throw exceptions. • Can not catch exceptions. • Can not make arbitrary instance or static method calls - only the public static methods of com.sun.btrace.BTraceUtils class may be called from a BTrace program. • Can not assign to static or instance fields of target program's classes and objects. But, BTrace class can assign to it's own static fields ("trace state" can be mutated). • Can not have instance fields and methods. Only static public void returning methods are allowed for a BTrace class. And all fields have to be static. • Can not have outer, inner, nested or local classes. • Can not have synchronized blocks or synchronized methods. • can not have loops (for, while, do..while) • Can not extend arbitrary class (super class has to be java.lang.Object) • Can not implement interfaces. • Can not contains assert statements. • Can not use class literals.
  • 26.
  • 27.
  • 28.
  • 29. Java Agents • An advanced technique for instrumenting code dynamically. • The foundation of modern profiling / debugging tools. • Two types of agents: Java and Native. • Pros: extremely powerful technique to collect state from a live app. • Cons: requires knowledge of creating verifiable bytecode.
  • 30. Agent Types • Java agents are written in Java. Have access to the Instrumentation BCI API. • Native agents – written in C++. • Have access to JVMTI – the JVM’s low-level set of APIs and capabilities. – JIT compilation, Garbage Collection, Monitor acquisition, Exception callbacks, .. • More complex to write. • Platform dependent.
  • 32. com.sun.tools.attach.VirtualMachine Attach at startup: java -Xmx2G -agentlib:myAgent -jar myapp.jar start To a live JVM using: com.sun.tools.attach.VirtualMachine Attach API.
  • 33.
  • 34.
  • 35.
  • 38. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/ techniques-server-debug