Production 100mph. About Me Co-founder – Takipi (God mode in Production Code). Co-founder – VisualTao (acquired by Autodesk). Director, AutoCAD.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

CPSC 388 – Compiler Design and Construction
Exceptions Chapter Throwing and Catching Exceptions When a program runs into a problem that it cannot handle, it throws an exception. Exceptions.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Written by: Dr. JJ Shepherd
ITEC200 Week02 Program Correctness and Efficiency.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Principles of Object-Oriented Software Development The language Java.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Exceptions and side-effects in atomic blocks Tim Harris.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Leveraging User Interactions for In-Depth Testing of Web Applications Sean McAllister, Engin Kirda, and Christopher Kruegel RAID ’08 1 Seoyeon Kang November.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Interesting facts about node.js.  Asynchronous I/O  How do they do that?..threads (usually) What do Web Servers do?
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Parallel Programming in Java with Shared Memory Directives.
Advanced Java New York University School of Continuing and Professional Studies.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
Java Programming: Advanced Topics
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Standalone Java Application vs. Java Web Application
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
A Revolutionary Programming Pattern that Will Clean up your Code : Coroutines in C++ David Sackstein ACCU 2015.
Google Web Toolkit An Overview By Shauvik Roy Choudhary.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Object-Oriented Software How does it differ from procedural? How is it similar to procedural? Why has it become so popular? Does it replace or supplement.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Chapter 6 Server-side Programming: Java Servlets
Introduction to Exception Handling and Defensive Programming.
“This presentation is for informational purposes only and may not be incorporated into a contract or agreement.”
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
COP4020 Programming Languages Exception Handling Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
SE-2840 Dr. Mark L. Hornick1 Servlet Threads and Sessions.
Java 3: Odds & Ends Advanced Programming Techniques.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
How to write a MSGQ Transport (MQT) Overview Nov 29, 2005 Todd Mullanix.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Written by: Dr. JJ Shepherd
Join us on Twitter: #AU2013 Building Well-Performing Autodesk® AutoCAD® Applications Albert Szilvasy Software Architect.
Final Review James Atlas August 12, James Atlas - CISC3702 “Family Feud” style Each team gets a chance to pick an answer Each team gets a chance.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
© Andy Wellings, 2004 Thread Priorities I  Although priorities can be given to Java threads, they are only used as a guide to the underlying scheduler.
CSC Multiprocessor Programming, Spring, 2012 Chapter 12 – Testing Concurrent Programs Dr. Dale E. Parson, week 12.
J AVA T RAINING IN A HMEDABAD By TOPS Technologies 1 TOPS Technologies Java Course.
JAVA TRAINING IN NOIDA. JAVA Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented and specifically.
Preface IIntroduction Course Objectives I-2 Oracle Complete Solution I-3 Course Agenda I-4 Tables Used in This Course I-5 The Order Entry Schema I-6 The.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fibers – blocking is cheap in a Parallel Universe jPrime Stefan Minev
Java Programming Language
Production Debugging in a Serverless World
EE 422C Java Reflection re·flec·tion rəˈflekSH(ə)n/ noun
Java Programming Language
Google App Engine Ying Zou 01/24/2016.
Units with – James tedder
Java Programming Course
WebSphere & EJB’s Experiences, Deployment & Best Practices
Presentation transcript:

Production 100mph

About Me Co-founder – Takipi (God mode in Production Code). Co-founder – VisualTao (acquired by Autodesk). 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 takipiblog.comtakipiblog.com

Overview Dev-stage debugging is forward-tracing. Production debugging is focused on backtracing. Modern production debugging poses two challenges: state isolation and data distribution. Direct correlation between quality of data to MTTR.

Agenda 1.Distributed logging – best practices. 1.Preemptive jstacks 2.Extracting state with BTrace 3.Extracting state with custom Java agents.

Solid Logging Practices 1. Code context. 2. Time + duration. 3. Thread ID (preferably name). 4. Transaction ID (for async & distributed debugging). Make sure these are baked into your logging context –

Transaction ID Logging is usually a multi–threaded / process affair. 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 distributed / async debugging.

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) Transaction ID Servlet parameters Queue message ID Start time "pool-1-thread-1" #17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait() [0x ebcc000] ”MsgID: AB5CAD, type: Analyze, queue: ACTIVE_PROD, TID: , TS: 11/8/ :34 " #17 prio=5 os_prio=31 tid=0x00007f9d620c9800 nid=0x6d03 in Object.wait() [0x ebcc000]

Your last line of defense - critical to pick up on unhandled exceptions. Setting the callback: public static void Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) void UncaughtExceptionHandler.uncaughtException(Thread t, Throwable e) { logger.error(“Uncaught error in thread “ + t, e); } Again, this is where thread Name + TLS are critical as the only surviving state. Global Exception Handlers

External Calls When a call leaves the JVM via JNI chances of exception increase dramatically. This includes Http, SQL, IO, OS calls. Treat each as if it will explode (it most likely will). try { return s3client.generatePresignedUrl(request); } catch (Exception e) { String error = String.format(“Error generating request: %s bucket: %s key: %s. method: %s", request, bucket, path, method); throw new IllegalStateException(error, e); // OR: logger.error(error, e); }

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.

Preemptive jstack - Demo github.com/takipi/jstack

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.

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.

BTrace - Demo

Custom Java Agents An advanced technique for instrumenting code dynamically. The foundation for most profiling / debugging tools. Two types of agents: Java and Native.Java and Native Pros: extremely powerful technique to collect state from a live app. Cons: requires knowledge of creating verifiable bytecode.

Custom Agent - Demo github.com/takipi/debugAgent

@takipid takipiblog.com Thanks!