SlideShare une entreprise Scribd logo
1  sur  23
Performance tuning
Grails applications
Lari Hotari @lhotari
Pivotal Software, Inc.
Agenda
• What is performance and what are we optimising
for?
• How do you do performance tuning and
optimisation?
• common missteps, tips and tricks related to Grails
applications profiling and tuning
Performance aspects
• Latency of operations
• Throughput of operations
• Quality of operations - correctness, consistency,
resilience, security, usability, availability ...
Why?
• Optimising costs to run your system - operational
efficiency
• Tuning your system to meet it's performance
requirements with optimal cost
• Performance is a feature of your system: keeping
up the quality of the operations under high load
Amdahl's law
Little's law
• What does Little's law tell us when we are using
the thread-per-request model?
MeanNumberInSystem = MeanThroughput * MeanResponseTime
→
MeanThroughput = MeanNumberInSystem / MeanResponseTime
L = λW
How?
• Set up your own feedback cycle for tuning your own system
• Measure & profile
• start with the tools you have available. You can add more tools and methods in the next
iteration.
• Think & learn, analyse and plan the next change
• find tools and methods to measure something in the next iteration you want to know
about more
• Implement a single change
• Iterate: do a lot of iterations and optimally change one thing at a time - this will help you to
learn about your system's performance and operational aspects
• Set up a different feedback cycle for production environments. Don't forget that usually
it's irrelevant if the system performs well on your laptop. If you are not involved in
operations, use innovative means to set up a feedback cycle.
More
• In concurrent execution: Amdahl's law - you won't be able to speed up a single computation
task if you cannot parallellize it.
• In traditional synchronous Grails code this means, that each request thread shouldn't block
other threads. It doesn't necessarily mean that you have to switch to asynchronous handling
of requests. However that might be helpful for error handling reasons. Asynchronous doesn't
mean fast.
• Find the most limiting bottleneck and eliminate it, one by one
• re-measure after each change because the behaviour of concurrent execution can be
different after a small change in reducing blocking - usually the next problem is not the 2. one
on the list from the previous measurement.
• "Mature optimization" - keep the clarity and consistency of the solution. Don't do things just
"because this is faster". Don't introduce accidental complexity.
• Find out also how your systems gets saturated - the saturation point . How does latency
change when load is added? Can your system survive? What happens when it gets over
loaded?
JVM code profiler concepts
• Sampling
• statistical ways to get information about the execution using JVM profiling
interfaces with a given time interval, for example 100 milliseconds.
Statistical methods are used to calculate values based on the samples.
• Unreliable results, but certainly useful in some cases since the
overhead of sampling is minimal compared to instrumentation
• Usually helps to get better understanding of the problem if you learn to
look past the numeric values returned from measurements.
• Instrumentation
• exact measurements of method execution details
Load generation tools
• Simple command line tools
• ab - apache bench
• wrk - modern HTTP benchmarking tool
• has lua scripting support for doing things like
checking the reply
• Load testing toolkits
• Support testing use cases and state full flows
Common pitfalls in profiling
Groovy and Grails code
• Measuring wall clock time
• Measuring CPU time for certain method
• Instrumentation usually provides false results
because of JIT compilation and other reasons
like spin locks
• lack of proper JVM warmup
• Relying on gut feeling
Ground your feet
• Find a way to review production performance graphs regularly,
especially after making changes to the system
• system utilisation over time (CPU load, IO load & wait, Memory
usage), system input workload (requests) over time, etc.
• In the Cloud, use tools like New Relic to get a view in operations
• CloudFoundry based Pivotal Web Services and IBM Bluemix
have New Relic available
• In the development environment, use a profiler and debugger to
get understanding. You can use grails-melody plugin to get insight
on SQL that's executed.
Recommendations
• Concentrate on eliminating blocking because of Amdahl's law
• Look for low hanging fruit (next slide) if you are in a rush - it's
worth doing.
• Concentrate on constantly improving the performance tuning
feedback cycles you have in place for development and
production environments.
• Innovate to get iterations going: you don't necessary need
expensive tools or toolkits. Continuous improvement is more
important than fancy tools.
• Take small steps.
Environment related
problems
• Improper JVM configuration for Grails apps
• out-of-the-box Tomcat parameters
• a single JVM running with a huge heap on a big
box
• If you have a big powerful box, it's better to
run multiple small JVMs and put a load
balancer in front of them
Low hanging fruit
• SQL and database related bottlenecks: learn how to profile SQL queries and tune your database queries and your database
• grails-melody plugin can be used to spot costly SQL queries in development and testing environments. Nothing prevents use
in production however there is a risk that running it in production environment has negative side effects.
• New Relic in CloudFoundry (works for production environments)
• Eliminate stack traces thrown in normal program flow - use profiler or debugger to find if any are called in normal program flow
• High CPU usage: Check regexps that are used a lot (use profiler's CPU time measurement to spot those, search for the code
for candidate regexps). Also check the regexps with different input size. Make sure valid input doesn't trigger "catastrophic
backtracking". Understand what it is. Use a regexp analyser to find out the number of operations a certain input triggers in
handling the input.
• Check concurrency patterns like synchronised usage: using java.util.Hashtable/Properties is blocking
• these block: System.getProperty("some.config.value","some.default"), Boolean.getBoolean("some.feature.flag")
• .each -> for loop
• Cache implementation that serves stale information while entry is being updated (blocks only when there isn't information
available)
• Cache implementation that locks a certain key for updating to prevent cache storms
• should use "static transactional = false" in services that don't need transactions
• Don't call transactional services from GSP taglibs (or GSP views), that might cause a large number of short transactions during
view rendering
Tool for getting insight in sudden
production performance problems
• kill -3 <PID>
• Makes a thread dump of all threads and outputs it
to System.out which ends up in catalina.out in
default Tomcat config.
• the java process keeps running and it doesn't get
terminated
Java Mission Control
& Flight Recorder
• Oracle JDK 7 and 8 includes Java Mission Control
since 1.7.0_40 .
• JAVA_HOME/bin/jmc executable for launching the
client UI for jmc
• JMC includes Java Flight Recorder which has been
designed to be used in production.
• JFR can record data without the UI and store events
in a circular buffer for investigation of production
problems.
JFR isn't free
• JFR is a commercial non-free feature, available
only in Oracle JVMs (originally from JRockit).
• You must buy a license from Oracle for each JVM
using it.
• "... require Oracle Java SE Advanced or Oracle Java SE Suite licenses for the computer running the observed
JVM" , http://www.oracle.com/technetwork/java/javase/documentation/java-se-product-editions-397069.pdf ,
page 5
Controlling JFR
• enabling JFR with default continuous "black box"
recording:
• Runtime controlling using jcmd commands
• help for commands with jcmd <pid> help JFR.start
jcmd <pid> help JFR.stop
jcmd <pid> help JFR.dump
jcmd <pid> help JFR.check
export _JAVA_OPTIONS="-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder
-XX:FlightRecorderOptions=defaultrecording=true"
wrk http load testing tool
sample output
1 Running 10s test @ http://localhost:8080/empty-test-app/empty/index
2 10 threads and 10 connections
3 Thread Stats Avg Stdev Max +/- Stdev
4 Latency 1.46ms 4.24ms 17.41ms 93.28%
5 Req/Sec 2.93k 0.90k 5.11k 85.67%
6 Latency Distribution
7 50% 320.00us
8 75% 352.00us
9 90% 406.00us
10 99% 17.34ms
11 249573 requests in 10.00s, 41.22MB read
12 Socket errors: connect 1, read 0, write 0, timeout 5
13 Requests/sec: 24949.26
14 Transfer/sec: 4.12MB
check latency, the max and it's
distribution
Total throughput
https://github.com/lhotari/grails-perf-testapps/empty-test-app
Demo
Thanks!
Lari Hotari @lhotari
Pivotal Software, Inc.

Contenu connexe

Tendances

Machine Learning At Speed: Operationalizing ML For Real-Time Data Streams
Machine Learning At Speed: Operationalizing ML For Real-Time Data StreamsMachine Learning At Speed: Operationalizing ML For Real-Time Data Streams
Machine Learning At Speed: Operationalizing ML For Real-Time Data StreamsLightbend
 
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...confluent
 
Nine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take youNine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take youMarkus Eisele
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...Lightbend
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandC2B2 Consulting
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereLightbend
 
Cloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessCloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessLightbend
 
War Stories: DIY Kafka
War Stories: DIY KafkaWar Stories: DIY Kafka
War Stories: DIY Kafkaconfluent
 
Pivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
Pivoting Spring XD to Spring Cloud Data Flow with Sabby AnandanPivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
Pivoting Spring XD to Spring Cloud Data Flow with Sabby AnandanPivotalOpenSourceHub
 
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...confluent
 
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017Big Data Spain
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkBuilding Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkTodd Fritz
 
Running Apache Spark Jobs Using Kubernetes
Running Apache Spark Jobs Using KubernetesRunning Apache Spark Jobs Using Kubernetes
Running Apache Spark Jobs Using KubernetesDatabricks
 
The Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on KubernetesThe Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on KubernetesBilgin Ibryam
 
Time Series Analysis Using an Event Streaming Platform
 Time Series Analysis Using an Event Streaming Platform Time Series Analysis Using an Event Streaming Platform
Time Series Analysis Using an Event Streaming PlatformDr. Mirko Kämpf
 
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...confluent
 
Detecting Real-Time Financial Fraud with Cloudflow on Kubernetes
Detecting Real-Time Financial Fraud with Cloudflow on KubernetesDetecting Real-Time Financial Fraud with Cloudflow on Kubernetes
Detecting Real-Time Financial Fraud with Cloudflow on KubernetesLightbend
 

Tendances (19)

Machine Learning At Speed: Operationalizing ML For Real-Time Data Streams
Machine Learning At Speed: Operationalizing ML For Real-Time Data StreamsMachine Learning At Speed: Operationalizing ML For Real-Time Data Streams
Machine Learning At Speed: Operationalizing ML For Real-Time Data Streams
 
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...
Scaling Security on 100s of Millions of Mobile Devices Using Apache Kafka® an...
 
Real-Time Design Patterns
Real-Time Design PatternsReal-Time Design Patterns
Real-Time Design Patterns
 
Nine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take youNine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take you
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
 
Microservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got HereMicroservices, Monoliths, SOA and How We Got Here
Microservices, Monoliths, SOA and How We Got Here
 
Cloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful ServerlessCloudstate - Towards Stateful Serverless
Cloudstate - Towards Stateful Serverless
 
War Stories: DIY Kafka
War Stories: DIY KafkaWar Stories: DIY Kafka
War Stories: DIY Kafka
 
Pivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
Pivoting Spring XD to Spring Cloud Data Flow with Sabby AnandanPivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
Pivoting Spring XD to Spring Cloud Data Flow with Sabby Anandan
 
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
KafkaConsumer - Decoupling Consumption and Processing for Better Resource Uti...
 
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017
Tuning Java Driver for Apache Cassandra by Nenad Bozic at Big Data Spain 2017
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, SparkBuilding Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
 
Revitalizing Aging Architectures with Microservices
Revitalizing Aging Architectures with MicroservicesRevitalizing Aging Architectures with Microservices
Revitalizing Aging Architectures with Microservices
 
Running Apache Spark Jobs Using Kubernetes
Running Apache Spark Jobs Using KubernetesRunning Apache Spark Jobs Using Kubernetes
Running Apache Spark Jobs Using Kubernetes
 
The Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on KubernetesThe Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on Kubernetes
 
Time Series Analysis Using an Event Streaming Platform
 Time Series Analysis Using an Event Streaming Platform Time Series Analysis Using an Event Streaming Platform
Time Series Analysis Using an Event Streaming Platform
 
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
Organic Growth and A Good Night Sleep: Effective Kafka Operations at Pinteres...
 
Detecting Real-Time Financial Fraud with Cloudflow on Kubernetes
Detecting Real-Time Financial Fraud with Cloudflow on KubernetesDetecting Real-Time Financial Fraud with Cloudflow on Kubernetes
Detecting Real-Time Financial Fraud with Cloudflow on Kubernetes
 

En vedette

Report Of Follow Up Week With Stakeholders
Report Of Follow Up Week With StakeholdersReport Of Follow Up Week With Stakeholders
Report Of Follow Up Week With Stakeholdersguesta4ad22e3
 
Digital course
Digital courseDigital course
Digital courseimgaurav
 
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel Willems
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel WillemsMARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel Willems
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel WillemsRoel Willems
 
Cooperative Training 20 20 02 09 New
Cooperative Training 20 20 02 09  NewCooperative Training 20 20 02 09  New
Cooperative Training 20 20 02 09 Newguesta4ad22e3
 

En vedette (6)

Report Of Follow Up Week With Stakeholders
Report Of Follow Up Week With StakeholdersReport Of Follow Up Week With Stakeholders
Report Of Follow Up Week With Stakeholders
 
Secraterate
SecraterateSecraterate
Secraterate
 
Digital course
Digital courseDigital course
Digital course
 
Iec Ashok
Iec AshokIec Ashok
Iec Ashok
 
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel Willems
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel WillemsMARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel Willems
MARCOM 2013, Online strategie bepalen, hoe doe je dat? - Roel Willems
 
Cooperative Training 20 20 02 09 New
Cooperative Training 20 20 02 09  NewCooperative Training 20 20 02 09  New
Cooperative Training 20 20 02 09 New
 

Similaire à Performance tuning Grails Applications GR8Conf US 2014

Performance tuning Grails applications
Performance tuning Grails applicationsPerformance tuning Grails applications
Performance tuning Grails applicationsLari Hotari
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applicationsGR8Conf
 
Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Lari Hotari
 
Building an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureBuilding an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureSrihari Sriraman
 
The Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance TuningThe Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance TuningjClarity
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With GatlingKnoldus Inc.
 
Performance optimization (balancer optimization)
Performance optimization (balancer optimization)Performance optimization (balancer optimization)
Performance optimization (balancer optimization)Vitaly Peregudov
 
Flopsar tesacom-technical-introduction v1a-eng
Flopsar tesacom-technical-introduction v1a-engFlopsar tesacom-technical-introduction v1a-eng
Flopsar tesacom-technical-introduction v1a-engMarcelo Marinangeli
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningMichel Schildmeijer
 
Application Performance Tuning Techniques
Application Performance Tuning TechniquesApplication Performance Tuning Techniques
Application Performance Tuning TechniquesRam Nagesh
 
Architecting for the cloud storage build test
Architecting for the cloud storage build testArchitecting for the cloud storage build test
Architecting for the cloud storage build testLen Bass
 
Load Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSLoad Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSVladimir Ilic
 
EM12c Monitoring, Metric Extensions and Performance Pages
EM12c Monitoring, Metric Extensions and Performance PagesEM12c Monitoring, Metric Extensions and Performance Pages
EM12c Monitoring, Metric Extensions and Performance PagesEnkitec
 
Laravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsLaravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsMuhammad Shehata
 
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL PerformanceTommy Lee
 
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f..." Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...Lohika_Odessa_TechTalks
 

Similaire à Performance tuning Grails Applications GR8Conf US 2014 (20)

Performance tuning Grails applications
Performance tuning Grails applicationsPerformance tuning Grails applications
Performance tuning Grails applications
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applications
 
Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014
 
Real-World Load Testing of ADF Fusion Applications Demonstrated - Oracle Ope...
Real-World Load Testing of ADF Fusion Applications Demonstrated  - Oracle Ope...Real-World Load Testing of ADF Fusion Applications Demonstrated  - Oracle Ope...
Real-World Load Testing of ADF Fusion Applications Demonstrated - Oracle Ope...
 
Building an Experimentation Platform in Clojure
Building an Experimentation Platform in ClojureBuilding an Experimentation Platform in Clojure
Building an Experimentation Platform in Clojure
 
Ioug oow12 em12c
Ioug oow12 em12cIoug oow12 em12c
Ioug oow12 em12c
 
The Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance TuningThe Diabolical Developers Guide to Performance Tuning
The Diabolical Developers Guide to Performance Tuning
 
Gatling
Gatling Gatling
Gatling
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With Gatling
 
Performance optimization (balancer optimization)
Performance optimization (balancer optimization)Performance optimization (balancer optimization)
Performance optimization (balancer optimization)
 
Fastest Servlets in the West
Fastest Servlets in the WestFastest Servlets in the West
Fastest Servlets in the West
 
Flopsar tesacom-technical-introduction v1a-eng
Flopsar tesacom-technical-introduction v1a-engFlopsar tesacom-technical-introduction v1a-eng
Flopsar tesacom-technical-introduction v1a-eng
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuning
 
Application Performance Tuning Techniques
Application Performance Tuning TechniquesApplication Performance Tuning Techniques
Application Performance Tuning Techniques
 
Architecting for the cloud storage build test
Architecting for the cloud storage build testArchitecting for the cloud storage build test
Architecting for the cloud storage build test
 
Load Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSLoad Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWS
 
EM12c Monitoring, Metric Extensions and Performance Pages
EM12c Monitoring, Metric Extensions and Performance PagesEM12c Monitoring, Metric Extensions and Performance Pages
EM12c Monitoring, Metric Extensions and Performance Pages
 
Laravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and ToolsLaravel Load Testing: Strategies and Tools
Laravel Load Testing: Strategies and Tools
 
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
 
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f..." Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
 

Dernier

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 

Dernier (20)

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 

Performance tuning Grails Applications GR8Conf US 2014

  • 1. Performance tuning Grails applications Lari Hotari @lhotari Pivotal Software, Inc.
  • 2. Agenda • What is performance and what are we optimising for? • How do you do performance tuning and optimisation? • common missteps, tips and tricks related to Grails applications profiling and tuning
  • 3. Performance aspects • Latency of operations • Throughput of operations • Quality of operations - correctness, consistency, resilience, security, usability, availability ...
  • 4. Why? • Optimising costs to run your system - operational efficiency • Tuning your system to meet it's performance requirements with optimal cost • Performance is a feature of your system: keeping up the quality of the operations under high load
  • 6. Little's law • What does Little's law tell us when we are using the thread-per-request model? MeanNumberInSystem = MeanThroughput * MeanResponseTime → MeanThroughput = MeanNumberInSystem / MeanResponseTime L = λW
  • 7. How? • Set up your own feedback cycle for tuning your own system • Measure & profile • start with the tools you have available. You can add more tools and methods in the next iteration. • Think & learn, analyse and plan the next change • find tools and methods to measure something in the next iteration you want to know about more • Implement a single change • Iterate: do a lot of iterations and optimally change one thing at a time - this will help you to learn about your system's performance and operational aspects • Set up a different feedback cycle for production environments. Don't forget that usually it's irrelevant if the system performs well on your laptop. If you are not involved in operations, use innovative means to set up a feedback cycle.
  • 8.
  • 9. More • In concurrent execution: Amdahl's law - you won't be able to speed up a single computation task if you cannot parallellize it. • In traditional synchronous Grails code this means, that each request thread shouldn't block other threads. It doesn't necessarily mean that you have to switch to asynchronous handling of requests. However that might be helpful for error handling reasons. Asynchronous doesn't mean fast. • Find the most limiting bottleneck and eliminate it, one by one • re-measure after each change because the behaviour of concurrent execution can be different after a small change in reducing blocking - usually the next problem is not the 2. one on the list from the previous measurement. • "Mature optimization" - keep the clarity and consistency of the solution. Don't do things just "because this is faster". Don't introduce accidental complexity. • Find out also how your systems gets saturated - the saturation point . How does latency change when load is added? Can your system survive? What happens when it gets over loaded?
  • 10. JVM code profiler concepts • Sampling • statistical ways to get information about the execution using JVM profiling interfaces with a given time interval, for example 100 milliseconds. Statistical methods are used to calculate values based on the samples. • Unreliable results, but certainly useful in some cases since the overhead of sampling is minimal compared to instrumentation • Usually helps to get better understanding of the problem if you learn to look past the numeric values returned from measurements. • Instrumentation • exact measurements of method execution details
  • 11. Load generation tools • Simple command line tools • ab - apache bench • wrk - modern HTTP benchmarking tool • has lua scripting support for doing things like checking the reply • Load testing toolkits • Support testing use cases and state full flows
  • 12. Common pitfalls in profiling Groovy and Grails code • Measuring wall clock time • Measuring CPU time for certain method • Instrumentation usually provides false results because of JIT compilation and other reasons like spin locks • lack of proper JVM warmup • Relying on gut feeling
  • 13. Ground your feet • Find a way to review production performance graphs regularly, especially after making changes to the system • system utilisation over time (CPU load, IO load & wait, Memory usage), system input workload (requests) over time, etc. • In the Cloud, use tools like New Relic to get a view in operations • CloudFoundry based Pivotal Web Services and IBM Bluemix have New Relic available • In the development environment, use a profiler and debugger to get understanding. You can use grails-melody plugin to get insight on SQL that's executed.
  • 14. Recommendations • Concentrate on eliminating blocking because of Amdahl's law • Look for low hanging fruit (next slide) if you are in a rush - it's worth doing. • Concentrate on constantly improving the performance tuning feedback cycles you have in place for development and production environments. • Innovate to get iterations going: you don't necessary need expensive tools or toolkits. Continuous improvement is more important than fancy tools. • Take small steps.
  • 15. Environment related problems • Improper JVM configuration for Grails apps • out-of-the-box Tomcat parameters • a single JVM running with a huge heap on a big box • If you have a big powerful box, it's better to run multiple small JVMs and put a load balancer in front of them
  • 16. Low hanging fruit • SQL and database related bottlenecks: learn how to profile SQL queries and tune your database queries and your database • grails-melody plugin can be used to spot costly SQL queries in development and testing environments. Nothing prevents use in production however there is a risk that running it in production environment has negative side effects. • New Relic in CloudFoundry (works for production environments) • Eliminate stack traces thrown in normal program flow - use profiler or debugger to find if any are called in normal program flow • High CPU usage: Check regexps that are used a lot (use profiler's CPU time measurement to spot those, search for the code for candidate regexps). Also check the regexps with different input size. Make sure valid input doesn't trigger "catastrophic backtracking". Understand what it is. Use a regexp analyser to find out the number of operations a certain input triggers in handling the input. • Check concurrency patterns like synchronised usage: using java.util.Hashtable/Properties is blocking • these block: System.getProperty("some.config.value","some.default"), Boolean.getBoolean("some.feature.flag") • .each -> for loop • Cache implementation that serves stale information while entry is being updated (blocks only when there isn't information available) • Cache implementation that locks a certain key for updating to prevent cache storms • should use "static transactional = false" in services that don't need transactions • Don't call transactional services from GSP taglibs (or GSP views), that might cause a large number of short transactions during view rendering
  • 17. Tool for getting insight in sudden production performance problems • kill -3 <PID> • Makes a thread dump of all threads and outputs it to System.out which ends up in catalina.out in default Tomcat config. • the java process keeps running and it doesn't get terminated
  • 18. Java Mission Control & Flight Recorder • Oracle JDK 7 and 8 includes Java Mission Control since 1.7.0_40 . • JAVA_HOME/bin/jmc executable for launching the client UI for jmc • JMC includes Java Flight Recorder which has been designed to be used in production. • JFR can record data without the UI and store events in a circular buffer for investigation of production problems.
  • 19. JFR isn't free • JFR is a commercial non-free feature, available only in Oracle JVMs (originally from JRockit). • You must buy a license from Oracle for each JVM using it. • "... require Oracle Java SE Advanced or Oracle Java SE Suite licenses for the computer running the observed JVM" , http://www.oracle.com/technetwork/java/javase/documentation/java-se-product-editions-397069.pdf , page 5
  • 20. Controlling JFR • enabling JFR with default continuous "black box" recording: • Runtime controlling using jcmd commands • help for commands with jcmd <pid> help JFR.start jcmd <pid> help JFR.stop jcmd <pid> help JFR.dump jcmd <pid> help JFR.check export _JAVA_OPTIONS="-XX:+UnlockCommercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true"
  • 21. wrk http load testing tool sample output 1 Running 10s test @ http://localhost:8080/empty-test-app/empty/index 2 10 threads and 10 connections 3 Thread Stats Avg Stdev Max +/- Stdev 4 Latency 1.46ms 4.24ms 17.41ms 93.28% 5 Req/Sec 2.93k 0.90k 5.11k 85.67% 6 Latency Distribution 7 50% 320.00us 8 75% 352.00us 9 90% 406.00us 10 99% 17.34ms 11 249573 requests in 10.00s, 41.22MB read 12 Socket errors: connect 1, read 0, write 0, timeout 5 13 Requests/sec: 24949.26 14 Transfer/sec: 4.12MB check latency, the max and it's distribution Total throughput https://github.com/lhotari/grails-perf-testapps/empty-test-app
  • 22. Demo