SlideShare una empresa de Scribd logo
1 de 30
Application Profiling
          for
Memory & Performance
Srinath Perera   Pradeep Fernando   Dinuka Malalanayke
  WSO2 Inc           WSO2 Inc           WSO2 Inc
Understanding Server Performance
When Concurrency Increases?


•   Throughput increases, but where will it stop?
•   When there are contention for the server
•   Contention for what?
    o   CPU
    o   Memory
    o   Disk - I/O
    o   Network -I/O
•   If your server running on full capacity, there should be at
    least one resource under contention.
How to measure Contention?


•   CPU - CPU or load average
•   Memory - GC logs, monitor memory, sometime swapping
•   Disk I/O - IOPS per seconds, load average
•   Network I/O - network utilization, load average
•   What is load average? length of processor queue of the OS
•   How much load average is too much?
    o   Load average = number of cores (machine is fully used)
    o   Load average = 2* number of cores (machine is loaded)
If you cannot find contention

•   Either load is too small
•   You have too much locks. Look for lock profile
•   Server might be processing with too less threads (IO and
    CPU thread switches)
Performance Tuning


•   Increase throughput/ latency or both
•   Know that latency vs. throughput is often a tradeoff
•   Run the system and see how it does, make sure you are
    putting in enough load
•   Verify where is the bottleneck? is it CPU, memory, network,
    or disk
•   Start tuning
Tuning



•   When you tune, bottlenecks will shift, you will have to shift
    your focus
•   Can you tune settings (Application, JVM, OS) to improve and
    shift the bottleneck? play with parameters .. we call this
    parameter sweep
•   Then focus on the code, look for right profile
    o   CPU profile
    o   Memory/ Allocation profile
    o   Network profile
    o   IO profile
    o   Database profile
Programmer Nightmares
Programmer Nightmares



                  ClassCastException
                        Permgen Errors
            DeadLocks
                           NullPointer
     Unacceptable Latency
     CPU spin       OutofMemoryException
            ArrayIndexOutOfBoundsException

[image] http://www1.free-clipart.net/gallery2/clipart/Holidays/Halloween/Ghost_-_Boo.jpg
Introducing: Profiling...



•   Best thing would be to write bug free, high performant code
•   Normally development happens in iterative manner - get
    something to work and improve on that.
•   Basic profiling can help you to eliminate most of the memory
    and performance issues.
Right Tools...


•       There are many commercial and open source tools
•       We are going to use,
         o       Jprofiler by ejTechnologies
                     CPU, Memory, Allocation, Network, DB
         o       Eclipse Memory Analyzer tool
                     Find memory leaks
         o       Standard JDK tooling - Jconsole
                     Basic stats




    [image] http://writingsongs.com/pictures/toolbox.jpg
Environment Setup
    With WSO2 Carbon
Setting up JProfiler

•   Profiling modes local/remote
•   Applying common filters for WSO2 products
•   Different views..
JProfiler Contd.


CPU view
 - Call trees, Hot spots
Memory view
 - Allocation Hot spots, Recorded objects, Heap walker
VM telemetry view
 - Memory, Threads status graphs
Probes
  - JDBC , Sockets
JConsole


•   Connect to the running instance local/remote
•   Different memory banks
•   Getting most out of Mbeans.
•   Getting a memory dump and analyzing with Eclipse MAT.
•   Remote JMX URL gets printed in the console during server
    startup:

       JMX Service URL : service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi
       username : admin password : admin
JConsole
Memory Analyzer Tool


•   Analyze heap dumps.
•   Identifying OOM issues are trivial with basic leak report.
Usual Suspects

 Some of the common issues...
Permgen Errors


•   Permgen space relates to the 'Programme code' part, a.k.a -
    Loaded classes.
•   ClassLoader leaks
•   Typically happens in Container environments
•   Can uncover by doing deploy/redeploy cycles.
•   If one of the application objects get referenced by an object,
    outside the application, permgen error waiting to happen.
Permgen Errors



Container

                  URLClassLoader             Application




                                      Application Objects
    Container provided
         Objects
Memory Leaks - OOM


•   Languages like C, gave the control of memory to the
    programmer.
•   Java is a managed memory, language.
•   Still the JVM can't free up the memory, if the application is
    holding on to the objects.
•   Unnecessary accumulation of objects,
    o   Object creation for each and every connection
    o   Slow output rate in the input/output system
    o   Collecting clusterwide messages without an upper bound.
DeadLocks



                          Resource A




                          Resource B




•   Re-designing the lock acquiring sequence
•   Using LockManagers that keeps track of lock acquisition
Liveness issues...




•   Starvation - A thread can starve for CPU cycles, if it is
    blocked by a lock-wait.
•   Poor Responsiveness
•   LiveLock scenarios
Programming Best Practices



•   Think about memory aspects/ data retrieval process while
    writing code.
•   Optimize the critical Path (look at CPU profile).
•   Make use of Standard libs as much as possible.
•   Profile your apps before releasing them to production.
WSO2 make use of profiling ?
Identity Server - Losing weight




• Carbon server optimized to run in constrained memory
  environment.
• No front end components - 'createWorker' ant task.
• Selective Admin service loading. -Doptimized=true
• Removed unwanted functionality based on the use-case,
  (p2 - provisioning, etc)
Raspberry-Pi Clusters



   •   Application server
       cluster running on R-
       Pis.
   •   Powering the
       WSO2Con 2013
       mobile app
   •   512MB of RAM and
       ARM processor.
Demo

CPU spin and Memory leak scenario
Questions
Thank You

Más contenido relacionado

La actualidad más candente

How Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceHow Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceBrendan Gregg
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introductionsilenceIT Inc.
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeterBhojan Rajan
 
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud GatewaySpring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud GatewayIván López Martín
 
Writing and testing high frequency trading engines in java
Writing and testing high frequency trading engines in javaWriting and testing high frequency trading engines in java
Writing and testing high frequency trading engines in javaPeter Lawrey
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & ActuatorsVMware Tanzu
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connectconfluent
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5Peter Lawrey
 
Integrating Apache Kafka and Elastic Using the Connect Framework
Integrating Apache Kafka and Elastic Using the Connect FrameworkIntegrating Apache Kafka and Elastic Using the Connect Framework
Integrating Apache Kafka and Elastic Using the Connect Frameworkconfluent
 
Deploying Confluent Platform for Production
Deploying Confluent Platform for ProductionDeploying Confluent Platform for Production
Deploying Confluent Platform for Productionconfluent
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Julien Le Dem
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache KafkaJeff Holoman
 
Paris Kafka Meetup - Concepts & Architecture
Paris Kafka Meetup - Concepts & ArchitectureParis Kafka Meetup - Concepts & Architecture
Paris Kafka Meetup - Concepts & ArchitectureFlorian Hussonnois
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaJiangjie Qin
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 

La actualidad más candente (20)

How Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for PerformanceHow Netflix Tunes EC2 Instances for Performance
How Netflix Tunes EC2 Instances for Performance
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introduction
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeter
 
Load Runner
Load RunnerLoad Runner
Load Runner
 
Spark on YARN
Spark on YARNSpark on YARN
Spark on YARN
 
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud GatewaySpring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
Spring IO 2023 - Dynamic OpenAPIs with Spring Cloud Gateway
 
Apache Flink Hands On
Apache Flink Hands OnApache Flink Hands On
Apache Flink Hands On
 
Writing and testing high frequency trading engines in java
Writing and testing high frequency trading engines in javaWriting and testing high frequency trading engines in java
Writing and testing high frequency trading engines in java
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Diving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka ConnectDiving into the Deep End - Kafka Connect
Diving into the Deep End - Kafka Connect
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5
 
Java logging
Java loggingJava logging
Java logging
 
Integrating Apache Kafka and Elastic Using the Connect Framework
Integrating Apache Kafka and Elastic Using the Connect FrameworkIntegrating Apache Kafka and Elastic Using the Connect Framework
Integrating Apache Kafka and Elastic Using the Connect Framework
 
Deploying Confluent Platform for Production
Deploying Confluent Platform for ProductionDeploying Confluent Platform for Production
Deploying Confluent Platform for Production
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Paris Kafka Meetup - Concepts & Architecture
Paris Kafka Meetup - Concepts & ArchitectureParis Kafka Meetup - Concepts & Architecture
Paris Kafka Meetup - Concepts & Architecture
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 

Similar a Application Profiling for Memory & Performance Optimization

Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and PerformanceWSO2
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment StrategyMongoDB
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment StrategiesMongoDB
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)MongoDB
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data RacesAzul Systems Inc.
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Nikolay Savvinov
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
Computer system organization
Computer system organizationComputer system organization
Computer system organizationSyed Zaid Irshad
 
Machine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkMLMachine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkMLArnab Biswas
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpretersRAJU KATHI
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dumpejlp12
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012Ashish Bhasin
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningMichel Schildmeijer
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination ExtRohit Kelapure
 
Azug - successfully breeding rabits
Azug - successfully breeding rabitsAzug - successfully breeding rabits
Azug - successfully breeding rabitsYves Goeleven
 

Similar a Application Profiling for Memory & Performance Optimization (20)

Application Profiling for Memory and Performance
Application Profiling for Memory and PerformanceApplication Profiling for Memory and Performance
Application Profiling for Memory and Performance
 
Attack on the Core
Attack on the CoreAttack on the Core
Attack on the Core
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
 
Deployment
DeploymentDeployment
Deployment
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data Races
 
Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...Using the big guns: Advanced OS performance tools for troubleshooting databas...
Using the big guns: Advanced OS performance tools for troubleshooting databas...
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Computer system organization
Computer system organizationComputer system organization
Computer system organization
 
Machine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkMLMachine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkML
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Spark Tips & Tricks
Spark Tips & TricksSpark Tips & Tricks
Spark Tips & Tricks
 
Compilers and interpreters
Compilers and interpretersCompilers and interpreters
Compilers and interpreters
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dump
 
TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012TechGIG_Memory leaks in_java_webnair_26th_july_2012
TechGIG_Memory leaks in_java_webnair_26th_july_2012
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuning
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination Ext
 
Azug - successfully breeding rabits
Azug - successfully breeding rabitsAzug - successfully breeding rabits
Azug - successfully breeding rabits
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Application Profiling for Memory & Performance Optimization

  • 1. Application Profiling for Memory & Performance Srinath Perera Pradeep Fernando Dinuka Malalanayke WSO2 Inc WSO2 Inc WSO2 Inc
  • 3. When Concurrency Increases? • Throughput increases, but where will it stop? • When there are contention for the server • Contention for what? o CPU o Memory o Disk - I/O o Network -I/O • If your server running on full capacity, there should be at least one resource under contention.
  • 4. How to measure Contention? • CPU - CPU or load average • Memory - GC logs, monitor memory, sometime swapping • Disk I/O - IOPS per seconds, load average • Network I/O - network utilization, load average • What is load average? length of processor queue of the OS • How much load average is too much? o Load average = number of cores (machine is fully used) o Load average = 2* number of cores (machine is loaded)
  • 5. If you cannot find contention • Either load is too small • You have too much locks. Look for lock profile • Server might be processing with too less threads (IO and CPU thread switches)
  • 6. Performance Tuning • Increase throughput/ latency or both • Know that latency vs. throughput is often a tradeoff • Run the system and see how it does, make sure you are putting in enough load • Verify where is the bottleneck? is it CPU, memory, network, or disk • Start tuning
  • 7. Tuning • When you tune, bottlenecks will shift, you will have to shift your focus • Can you tune settings (Application, JVM, OS) to improve and shift the bottleneck? play with parameters .. we call this parameter sweep • Then focus on the code, look for right profile o CPU profile o Memory/ Allocation profile o Network profile o IO profile o Database profile
  • 9. Programmer Nightmares ClassCastException Permgen Errors DeadLocks NullPointer Unacceptable Latency CPU spin OutofMemoryException ArrayIndexOutOfBoundsException [image] http://www1.free-clipart.net/gallery2/clipart/Holidays/Halloween/Ghost_-_Boo.jpg
  • 10. Introducing: Profiling... • Best thing would be to write bug free, high performant code • Normally development happens in iterative manner - get something to work and improve on that. • Basic profiling can help you to eliminate most of the memory and performance issues.
  • 11. Right Tools... • There are many commercial and open source tools • We are going to use, o Jprofiler by ejTechnologies  CPU, Memory, Allocation, Network, DB o Eclipse Memory Analyzer tool  Find memory leaks o Standard JDK tooling - Jconsole  Basic stats [image] http://writingsongs.com/pictures/toolbox.jpg
  • 12. Environment Setup With WSO2 Carbon
  • 13. Setting up JProfiler • Profiling modes local/remote • Applying common filters for WSO2 products • Different views..
  • 14. JProfiler Contd. CPU view - Call trees, Hot spots Memory view - Allocation Hot spots, Recorded objects, Heap walker VM telemetry view - Memory, Threads status graphs Probes - JDBC , Sockets
  • 15. JConsole • Connect to the running instance local/remote • Different memory banks • Getting most out of Mbeans. • Getting a memory dump and analyzing with Eclipse MAT. • Remote JMX URL gets printed in the console during server startup: JMX Service URL : service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi username : admin password : admin
  • 17. Memory Analyzer Tool • Analyze heap dumps. • Identifying OOM issues are trivial with basic leak report.
  • 18. Usual Suspects Some of the common issues...
  • 19. Permgen Errors • Permgen space relates to the 'Programme code' part, a.k.a - Loaded classes. • ClassLoader leaks • Typically happens in Container environments • Can uncover by doing deploy/redeploy cycles. • If one of the application objects get referenced by an object, outside the application, permgen error waiting to happen.
  • 20. Permgen Errors Container URLClassLoader Application Application Objects Container provided Objects
  • 21. Memory Leaks - OOM • Languages like C, gave the control of memory to the programmer. • Java is a managed memory, language. • Still the JVM can't free up the memory, if the application is holding on to the objects. • Unnecessary accumulation of objects, o Object creation for each and every connection o Slow output rate in the input/output system o Collecting clusterwide messages without an upper bound.
  • 22. DeadLocks Resource A Resource B • Re-designing the lock acquiring sequence • Using LockManagers that keeps track of lock acquisition
  • 23. Liveness issues... • Starvation - A thread can starve for CPU cycles, if it is blocked by a lock-wait. • Poor Responsiveness • LiveLock scenarios
  • 24. Programming Best Practices • Think about memory aspects/ data retrieval process while writing code. • Optimize the critical Path (look at CPU profile). • Make use of Standard libs as much as possible. • Profile your apps before releasing them to production.
  • 25. WSO2 make use of profiling ?
  • 26. Identity Server - Losing weight • Carbon server optimized to run in constrained memory environment. • No front end components - 'createWorker' ant task. • Selective Admin service loading. -Doptimized=true • Removed unwanted functionality based on the use-case, (p2 - provisioning, etc)
  • 27. Raspberry-Pi Clusters • Application server cluster running on R- Pis. • Powering the WSO2Con 2013 mobile app • 512MB of RAM and ARM processor.
  • 28. Demo CPU spin and Memory leak scenario