SlideShare a Scribd company logo
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

More Related Content

What's hot (20)

PDF
Postgres on OpenStack
EDB
 
PDF
Evaluating NoSQL Performance: Time for Benchmarking
Sergey Bushik
 
PDF
Java troubleshooting thread dump
ejlp12
 
PDF
Distributed Caching Essential Lessons (Ts 1402)
Yury Kaliaha
 
PPTX
Dell emc back up solution in azure cloud
vipinvips
 
PDF
The Java Content Repository
nobby
 
PDF
MariaDB on Docker
MariaDB plc
 
PDF
A Tale of 2 Systems
David Newman
 
PPTX
IaaS for DBAs in Azure
Kellyn Pot'Vin-Gorman
 
PDF
SAP HANA System Replication (HSR) versus SAP Replication Server (SRS)
Gary Jackson MBCS
 
PDF
Built-in Replication in PostgreSQL
Masao Fujii
 
PDF
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts
 
PDF
004 architecture andadvanceduse
Scott Miao
 
PDF
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Jignesh Shah
 
PDF
Power BI with Essbase in the Oracle Cloud
Kellyn Pot'Vin-Gorman
 
PDF
Scalable Integration with JBoss Fuse
Christina Lin
 
PPTX
001 hbase introduction
Scott Miao
 
PDF
Scaling Out Tier Based Applications
Yury Kaliaha
 
PDF
Enterprise PostgreSQL - EDB's answer to conventional Databases
Ashnikbiz
 
PPTX
System design for video streaming service
Nirmik Kale
 
Postgres on OpenStack
EDB
 
Evaluating NoSQL Performance: Time for Benchmarking
Sergey Bushik
 
Java troubleshooting thread dump
ejlp12
 
Distributed Caching Essential Lessons (Ts 1402)
Yury Kaliaha
 
Dell emc back up solution in azure cloud
vipinvips
 
The Java Content Repository
nobby
 
MariaDB on Docker
MariaDB plc
 
A Tale of 2 Systems
David Newman
 
IaaS for DBAs in Azure
Kellyn Pot'Vin-Gorman
 
SAP HANA System Replication (HSR) versus SAP Replication Server (SRS)
Gary Jackson MBCS
 
Built-in Replication in PostgreSQL
Masao Fujii
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts
 
004 architecture andadvanceduse
Scott Miao
 
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
Jignesh Shah
 
Power BI with Essbase in the Oracle Cloud
Kellyn Pot'Vin-Gorman
 
Scalable Integration with JBoss Fuse
Christina Lin
 
001 hbase introduction
Scott Miao
 
Scaling Out Tier Based Applications
Yury Kaliaha
 
Enterprise PostgreSQL - EDB's answer to conventional Databases
Ashnikbiz
 
System design for video streaming service
Nirmik Kale
 

Similar to Application Profiling for Memory and Performance (20)

PPTX
Application Profiling for Memory and Performance
pradeepfn
 
PDF
Tools and Tips to Diagnose Performance Issues
Claudio Miranda
 
PPTX
Tuning Java Servers
Srinath Perera
 
PDF
Web Sphere Problem Determination Ext
Rohit Kelapure
 
PPT
Performance Analysis of Idle Programs
greenwop
 
PDF
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
srisatish ambati
 
PDF
Java Tools and Techniques for Solving Tricky Problem
Will Iverson
 
PDF
Challenges in Maintaining a High Performance Search Engine Written in Java
lucenerevolution
 
PDF
OOW09 Ebs Tuning Final
jucaab
 
PPTX
Enterprise application performance - Understanding & Learnings
Dhaval Shah
 
PPT
Best Practices for performance evaluation and diagnosis of Java Applications ...
IndicThreads
 
KEY
Everything I Ever Learned About JVM Performance Tuning @Twitter
Attila Szegedi
 
PDF
Sensible scaling
Rowan Merewood
 
PDF
Profiler Guided Java Performance Tuning
osa_ora
 
PPTX
Debugging java deployments_2
Rohit Kelapure
 
PDF
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
Red Hat Developers
 
PPTX
Top-5-java-perf-problems-jax_mainz_2024.pptx
Tier1 app
 
PDF
DiscoveredByte - Java Performance Monitoring, Tuning and Optimization - Key P...
DiscoveredByte
 
PPTX
Java performance tuning
Mohammed Fazuluddin
 
ODP
Jvm tuning in a rush! - Lviv JUG
Tomek Borek
 
Application Profiling for Memory and Performance
pradeepfn
 
Tools and Tips to Diagnose Performance Issues
Claudio Miranda
 
Tuning Java Servers
Srinath Perera
 
Web Sphere Problem Determination Ext
Rohit Kelapure
 
Performance Analysis of Idle Programs
greenwop
 
JavaOne 2010: Top 10 Causes for Java Issues in Production and What to Do When...
srisatish ambati
 
Java Tools and Techniques for Solving Tricky Problem
Will Iverson
 
Challenges in Maintaining a High Performance Search Engine Written in Java
lucenerevolution
 
OOW09 Ebs Tuning Final
jucaab
 
Enterprise application performance - Understanding & Learnings
Dhaval Shah
 
Best Practices for performance evaluation and diagnosis of Java Applications ...
IndicThreads
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Attila Szegedi
 
Sensible scaling
Rowan Merewood
 
Profiler Guided Java Performance Tuning
osa_ora
 
Debugging java deployments_2
Rohit Kelapure
 
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
Red Hat Developers
 
Top-5-java-perf-problems-jax_mainz_2024.pptx
Tier1 app
 
DiscoveredByte - Java Performance Monitoring, Tuning and Optimization - Key P...
DiscoveredByte
 
Java performance tuning
Mohammed Fazuluddin
 
Jvm tuning in a rush! - Lviv JUG
Tomek Borek
 
Ad

More from WSO2 (20)

PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
PDF
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
PDF
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
PDF
Platformless Modernization with Choreo.pdf
WSO2
 
PDF
Application Modernization with Choreo for the BFSI Sector
WSO2
 
PDF
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
WSO2
 
PDF
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
WSO2
 
PPTX
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
WSO2
 
PPTX
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
WSO2
 
PPTX
WSO2Con 2025 - Building Secure Customer Experience Apps
WSO2
 
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2
 
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2
 
PPTX
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
WSO2
 
PPTX
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
WSO2
 
PPTX
WSO2Con 2025 - Architecting Cloud-Native Applications
WSO2
 
PDF
Mastering Intelligent Digital Experiences with Platformless Modernization
WSO2
 
PDF
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
PDF
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
PDF
architecting-ai-in-the-enterprise-apis-and-applications.pdf
WSO2
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
Modern Platform Engineering with Choreo - The AI-Native Internal Developer Pl...
WSO2
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Build Smarter, Deliver Faster with Choreo - An AI Native Internal Developer P...
WSO2
 
Platformless Modernization with Choreo.pdf
WSO2
 
Application Modernization with Choreo for the BFSI Sector
WSO2
 
Choreo - The AI-Native Internal Developer Platform as a Service: Overview
WSO2
 
[Roundtable] Choreo - The AI-Native Internal Developer Platform as a Service
WSO2
 
WSO2Con 2025 - Building AI Applications in the Enterprise (Part 1)
WSO2
 
WSO2Con 2025 - Building Secure Business Customer and Partner Experience (B2B)...
WSO2
 
WSO2Con 2025 - Building Secure Customer Experience Apps
WSO2
 
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2
 
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
WSO2
 
WSO2Con 2025 - Unified Management of Ingress and Egress Across Multiple API G...
WSO2
 
WSO2Con 2025 - How an Internal Developer Platform Lets Developers Focus on Code
WSO2
 
WSO2Con 2025 - Architecting Cloud-Native Applications
WSO2
 
Mastering Intelligent Digital Experiences with Platformless Modernization
WSO2
 
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
WSO2
 
Ad

Application Profiling for Memory and Performance

  • 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