- Tausief Shaikh (Senior Server developer). Introduction Covers sense of responsibility towards Project development in IT Focusing on memory and CPU utilizations.

Slides:



Advertisements
Similar presentations
Unix Systems Performance Tuning Project of COSC 513 Name: Qinghui Mu Instructor: Prof. Anvari.
Advertisements

Performance Testing - Kanwalpreet Singh.
MCTS GUIDE TO MICROSOFT WINDOWS 7 Chapter 10 Performance Tuning.
1 Thread Pools Representation and Management of Data on the Internet.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
Chapter 14 Chapter 14: Server Monitoring and Optimization.
Chapter 1 Software Development. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 1-2 Chapter Objectives Discuss the goals of software development.
Memory Management 2010.
©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for Threads.
MCITP Guide to Microsoft Windows Server 2008 Server Administration (Exam #70-646) Chapter 14 Server and Network Monitoring.
1 Thread Pools. 2 What’s A Thread Pool? A programming technique which we will use. A collection of threads that are created once (e.g. when server starts).
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Scalability By Alex Huang. Current Status 10k resources managed per management server node Scales out horizontally (must disable stats collector) Real.
© 2004 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Automation Fundamental Concepts &
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
Apache JMeter By Mohamed Talaat
Multi-core Programming Thread Profiler. 2 Tuning Threaded Code: Intel® Thread Profiler for Explicit Threads Topics Look at Intel® Thread Profiler features.
MCTS Guide to Microsoft Windows 7
Distributed File Systems
Tim De Borger Principal Solution Consultant May 18 th, 2007 Tuning the ESB How to make the Bus drive faster.
Threads, Thread management & Resource Management.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Chapter 2 (PART 1) Light-Weight Process (Threads) Department of Computer Science Southern Illinois University Edwardsville Summer, 2004 Dr. Hiroshi Fujinoki.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
Suite zTPFGI Facilities. Suite Focus Three of zTPFGI’s facilities:  zAutomation  zTREX  Logger.
Java Threads 11 Threading and Concurrent Programming in Java Introduction and Definitions D.W. Denbo Introduction and Definitions D.W. Denbo.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 4 – Thread Concepts Outline 4.1 Introduction 4.2Definition of Thread 4.3Motivation for.
Oracle 10g Database Administrator: Implementation and Administration Chapter 2 Tools and Architecture.
1 Performance Optimization In QTP Execution Over Video Automation Testing Speaker : Krishnesh Sasiyuthaman Nair Date : 10/05/2012.
Suite zTPFGI Facilities. Suite Focus Three of zTPFGI’s facilities:  zAutomation  zTREX  Logger.
1 (Worker Queues) cs What is a Thread Pool? A collection of threads that are created once (e.g. when a server starts) That is, no need to create.
The Alternative Larry Moore. 5 Nodes and Variant Input File Sizes Hadoop Alternative.
Refactoring and Synchronization with the StarTeam Plug-in for Eclipse  Jim Wogulis  Principal Architect, Borland Software Corporation.
1-1 Software Development Objectives: Discuss the goals of software development Identify various aspects of software quality Examine two development life.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 11 – gdb and Debugging.
Department of Computer Science and Software Engineering
M. Accetta, R. Baron, W. Bolosky, D. Golub, R. Rashid, A. Tevanian, and M. Young MACH: A New Kernel Foundation for UNIX Development Presenter: Wei-Lwun.
Threads, Thread management & Resource Management.
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.
Threads. Readings r Silberschatz et al : Chapter 4.
From the customer’s perspective the SRS is: How smart people are going to solve the problem that was stated in the System Spec. A “contract”, more or less.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
TEAM FOUNDATION VERSION CONTROL AN OVERVIEW AND WALKTHROUGH By: Michael Mallar.
Operating System Concepts
Tuning Threaded Code with Intel® Parallel Amplifier.
Threads by Dr. Amin Danial Asham. References Operating System Concepts ABRAHAM SILBERSCHATZ, PETER BAER GALVIN, and GREG GAGNE.
Introduction to Operating Systems Concepts
Chapter 4 – Thread Concepts
Thread Pools (Worker Queues) cs
Multi Threading.
Hands-On Microsoft Windows Server 2008
Chapter 4 – Thread Concepts
Lecture 21 Concurrency Introduction
Lecture 5: GPU Compute Architecture
O.S Lecture 13 Virtual Memory.
Aaron Zeckoski Tomcat Debugging Aaron Zeckoski
Lecture 5: GPU Compute Architecture for the last time
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
Multithreaded Programming
Prof. Leonardo Mostarda University of Camerino
Chapter 4: Threads.
Operating System Concepts
Operating System Concepts
COMP755 Advanced Operating Systems
Light-Weight Process (Threads)
Presentation transcript:

- Tausief Shaikh (Senior Server developer)

Introduction Covers sense of responsibility towards Project development in IT Focusing on memory and CPU utilizations rather than just coding. Thread and Thread Pool Eclipse Debugging Use of thread dumps and analysis using JVisualVM

Developing a software is easy but developing best software is indeed very tough If you know how to code, have some basic logic thinking, and with proper assistance of NET you can develop applications easily. Eg: If you know Java core, like datatypes, OOPs concepts, defining classes, interfaces, variables, method, then you can code and go on to develop big applications. Knowing the write ways of coding (designing in specific) however needs some experience, but would definitely come after spending some time in IT.

Developing a software is easy but developing best software is indeed very tough… Even tough we develop an application, functionally all correct, that doesn't mean our work is done. As a developer its our responsibility to make sure that the application works superb under heavy load. When many users access the application concurrently, then this can add more load on the resources we use. That means, more load on the memory, more CPU time utilization, more disk space utilization, etc…. Our application would always be deployed and run in a limited environment, where we have some max memory size, max disk space, max capability of CPU core. So there is always a challenge of how many requests the application can process in parallel, because beyond this the application would eventually crash.

Developing a software is easy but developing best software is indeed very tough… If many objects are created on heap for processing a single, then when huge load hit the app in parallel, lot of heap size would be occupied, and app would crash, so objects has to be wisely allocated and cleaned-up from memory. Like wise, when we create a thread, a new stack location would be allocated. So if too many threads are created, then eventually a time would come when we might run out of memory crashing the application again. Like wise, we can risk the harddisk spaces as well. Thus we should be very particular while accessing these resources, and should be a very valuable concern of every Java developer.

Thread and Thread Pool We all know that for every thread new stack memory is allocated. Due to this, code runs in parallel. If you think like a server application developer(suppose tomcat developer), then for every incoming request, a thread should be allocated, in order to process the request. We can simply create a new thread for every request. Even tough this would functionally be fine, however would just be a nightmare when practically deployed on server. One of the disadvantages of the thread-per-request approach is that the overhead of creating a new thread for each request is significant; a server that created a new thread for each request would spend more time and consume more system resources creating and destroying threads than it would processing actual user requests.

Thread and Thread Pool In addition to the overhead of creating and destroying threads, active threads consume system resources. Creating too many threads in one JVM can cause the system to run out of memory or thrash due to excessive memory consumption. To prevent resource thrashing, server applications need some means of limiting how many requests are being processed at any given time. To avoid this, the best solution is to introduce and maintain a ThreadPool.

Advantages of Thread Pool By reusing threads for multiple tasks, the thread-creation overhead is spread over many tasks. Eg: when a request comes, server would create many threads and keep it ready for execution. As a bonus, because the thread already exists when a request arrives, the delay introduced by thread creation is eliminated. Thus, the request can be serviced immediately, rendering the application more responsive. By properly tuning the number of threads in the thread pool, you can prevent resource thrashing by forcing any requests in excess of a certain threshold to wait until a thread is available to process it.

Thread Pool – your usage If you get a opportunity to work on server applications, then you can speed up your response time and avoid memory crash issues. At times, you can tune the thread pool size of the server, for suiting your application requirement. You can create your own thread pools for performing any asynchronous task. For specific projects you can design a framework over core threads and mange it with pool in order to control sync and async processing of tasks.

Eclipse (with Thread) While a thread executes, it runs in Stack. Stack consists of 3 parts: local variables, operand stack, and frame data. The code instruction executes one by one based on the logic Eg: In this execution flow: Line 1 -> 2 -> 3 -> 6 ->… Eclipse contains a feature by which we can track the execution flow of a thread. And to add more to it, we can also see the runtime values of variables.

Importance of eclipse debugging This can be the ultimate tool which can help you in debugging any major issues during project dev. When you catch a thread, then you can see entire internal details about the thread as to what is actually happening at runtime of project. This can help you in exploring runtime flow of any use-case with 100% assurance.

Eclipse (with Thread) – Debug Standalone app For debugging a standalone Java application in eclipse, follow the below process: Add breakpoint in java code where you want to stop the thread execution. (double client on line numbers mentioned in left) Right click Java class(with main()), Debug As => Java App Executions stops at the line where breakpoint is added Using Eclipse debug perspective, walkthrough thread

Starting Tomcat in debug mode – Approach1 Directly configure tomcat in eclipse. Then “Debug On Server” would directly start tomcat in debug mode and help your breakpoints getting caught. Advantage: This method is very useful when tomcat is running in local machine, as it saves a lot of manually efforts and Ecilipse does lot of things for you. Disadvantage: While working with shared integrated environments, where tomcat is on another linux machine, this process might not be that handy

Starting Tomcat in debug mode – Approach2 This approach would also be handly while working with integrated environment Step 1: Start tomcat in debug mode Step 2: Eclipse Configuration to connect to remote tomcat process Continue…

Starting Tomcat in debug mode – Approach2 Start tomcat in debug mode Goto DOS prompt: and run below 2 commands set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket Run: /bin/catalina.bat jpda start Eclipse configuration Goto Debug configuration In left pane, start the remote Java application pointing to 8000 debug port started by tomcat for accepting remote debug conections.

Thread Dump and usage Lot of time during application testing, you might end up in a awkward situation where all your app threads might be stuck or waiting for something. And your application would not have any thing threads available to process your request. In such cases, it really becomes tough to analyze as to what’s going with the threads. And this problems grows with huge KLOC(kilo lines of code). In entire code base, any wrongly implemented use-case, might have consumed all your threads.

Thread Dump and usage Threads might be “getting stuck/consuming more processing time” due to any of the below reasons: Synchronized blocks/methods Taking more time for DB calls Dependencies on external resources, like HTTP calls or remote webservices or remote ejbs Nested iterations can also add delay. Or threads might be in sleeping state. We should write code in such a way so as to optimize or avoid all of the above issues. But still, while doing load testing, you might end up observing the above issues. Which risks thread utilizations.

Thread Dump and usage Thread Dumps are used to monitor the state of any of the application thread at a given point of time. Thread dump is a snapshot of all thread-state at any give point of time. At a given point of time you can say, which threads are doing what in your application. This can help you in identifying the bottleneck in your application. Then you can visit the code and work on the piece to make it perform better.

Thread States - JVisualVM Threads can be in any of the below states RUNNING: currently threads are performing some tasks. You can see currently the thread is running which line of which class. SLEEPING: Indicates currently thread is in sleeping state WAITING: This doesn’t specify problem situation, it simply means that thread is available in pool and can process any new task which is submitted to pool. MONITOR: Currently thread is blocked due to lock acquired by other thread on a resource which this thread is trying to active.

Java Visual VM JVisualVM is a tool which comes along with java installation under /bin folder This can be used to indicate internal memory details of an application. Like CPU utilizations, Heap occupancy, classes and thread details in the memory. You can effectively check the thread state of the system. It provides with a “Threads inspector” window, which helps you in identifying at which line number the threads are currently.

Thank You. Presenter details: Name: Tausief Shaikh Id: Fb: Contact: