SlideShare a Scribd company logo
Audit your reactive 
applications 
+PhilippePrados @pprados 
+François-Xavier Bonnet @fxbonnet
What is reactive? 
● Responsive 
● Resilient 
● Elastic 
● Message driven 
“Non-blocking communication allows recipients 
to only consume resources while active, 
leading to less system overhead.” 
http://www.reactivemanifesto.org/
The problem: blocking APIs 
● Blocking APIs consume the thread pool 
because of too much waiting time 
 
● We should have no more threads than cores 
on the machine
How do I track blocking API calls? 
● Modifying the JVM? 
● Generating warnings during compilation? 
● Instrumenting the code at runtime using a 
JVM agent? 
Code Compiler JRE
Modifying the JDK 
● This strategy has been used by Google in 
Android SDK in order to avoid the use of 
blocking API in a UI thread 
● Not too hard for pure java methods but what 
about native methods (OS specific)?
Generating warnings during 
compilation? 
● Annotate JDK methods inside an IDE? Used 
by IntelliJ for @Nullable and @NotNull 
annotations but not standard 
● JSR 269 allows to do things at compile time 
https://jcp.org/en/jsr/detail?id=269 
● Compilation occurs in several phases, we 
can access the syntax tree only after the first 
phase 
o The pure syntax, not the called method name
Generating warnings during 
compilation? 
● JSR308 allows to do things after the second 
phase http://types.cs.washington.edu/jsr308/ 
o The augmented syntax tree 
● But not included in JDK 8
Generating warnings during 
compilation? 
● Many things can be seen only at runtime 
● Ex: java.io.Reader.read() is blocking for a file 
or network connection but not for memory
Instrumenting the code at runtime 
using a JVM agent? 
● Patch the code at application startup 
● Solution:
Auditing using Aspect programing 
● Load time weaving 
● Java agent at JVM startup 
● List all blocking methods 
● But, can not be weaving the SDK itself 
Some tweaks: 
● Some methods might be blocking depending 
on the arguments or internal use!
Aspect programming: example
Checking an application - Play
Log output with Play 
DEMO
Log output with Play 
HIGH : Call method void java.io.PrintWriter.print(String) with /tmp/sbt1269029892078438540.log 
com.octo.reactive.audit.lib.FileReactiveAuditException: 
Call method void java.io.PrintWriter.print(String) with /tmp/sbt1269029892078438540.log 
at thread "play-internal-execution-context-1" 
at sbt.ConsoleOut$$anon$3.print(ConsoleOut.scala:52) 
at sbt.ConsoleLogger.setColor(ConsoleLogger.scala:158) 
at sbt.ConsoleLogger.reset(ConsoleLogger.scala:153) 
at sbt.ConsoleLogger.sbt$ConsoleLogger$$printLabeledLine(ConsoleLogger.scala:168) 
at sbt.ConsoleLogger$$anonfun$log$1.apply(ConsoleLogger.scala:164) 
at sbt.ConsoleLogger$$anonfun$log$1.apply(ConsoleLogger.scala:163) 
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) 
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108) 
at sbt.ConsoleLogger.log(ConsoleLogger.scala:163) 
at sbt.ConsoleLogger.log(ConsoleLogger.scala:151) 
at sbt.AbstractLogger.log(Logger.scala:31) 
...
Use it with in testing scope 
● Because the analysis is performed on 
effective method calls at runtime 
● The audit should be used while running 
o Integration tests 
o Functional tests 
● Not relevant in unit tests
Configuration 
● Alert for all calls to blocking methods? 
● We need some filters 
o Startup shift 
o Thread name (pattern matching) 
o Kind and level of blocking call (CPU, File, Network) 
o Annotations
Configuration at runtime
Log output with Play 
DEMO
Checked SDK APIs +500 
java.io 
java.lang 
java.net 
java.nio.channel 
java.nio.file 
java.rmi.registry 
java.rmi.server 
java.sql 
java.util 
java.util.concurrent 
java.util.concurrent.locks 
java.util.logger 
java.util.zip 
javax.activation 
javax.imageio 
javax.net 
javax.net.ssl 
javax.rmi 
javax.rmi.ssl 
javax.sql.rowset.spi 
javax.sql.rowset 
javax.sql 
javax.tools 
javax.transaction.xa 
javax.xml.bind 
javax.xml.parsers 
javax.xml.soap 
javax.xml.ws.spi 
javax.xml.ws 
org.xml.sax
Supported 
frameworks/languages/servers 
Framework Windows Mac/linux 
unknown 
> reactive-audit 
> java %AUDIT_OPTS% ... 
$ source reactive-audit 
$ java %AUDIT_OPTS% ... 
jetty 
> reactive-audit jetty 
> java %AUDIT_OPTS% -jar start.jar 
$ source reactive-audit jetty 
$ java %AUDIT_OPTS% -jar start.jar 
catalina > reactive-audit catalina -run catalina run $ reactive-audit catalina -run catalina run 
play > reactive-audit play -run activator run $ reactive-audit play -run activator run 
vert.x > reactive-audit vertx -run vertx run ... $ reactive-audit vertx -run vertx run ... 
maven > reactive-audit maven -run mvn ... $ reactive-audit maven -run mvn ... 
gradle > reactive-audit gradle -run gradle ... $ reactive-audit gradle -run gradle ... 
sbt > reactive-audit sbt -run sbt ... $ reactive-audit sbt -run sbt ...
Build integration and continuous 
testing 
● Sample script for 
o Maven 
o Gradle 
o Sbt 
● You’re welcome to propose others
Use it with your reactive project 
● Play 
● Akka 
● VertX 
● AsyncHttpClient 
● RxJava 
● …
We need you ! 
● Check it with your project 
● Improve the rules 
● Submit some extensions 
● Submit plugins for others tools 
● Submit XSTL to format XML log file 
https://github.com/octo-online/reactive-audit
Questions? 
https://github.com/octo-online/reactive-audit
Questions? 
LES CONTACTS 
Philippe PRADOS 
Manager Tribu Reactive 
+33 (0)6 20 66 71 00 
pprados@octo.com 
François-Xavier Bonnet 
Consultant 
+33 (0)6 13 26 82 99 
efortin@octo.com

More Related Content

PDF
Testing with Codeception (Webelement #30)
PDF
Efficient JavaScript Unit Testing, May 2012
PDF
Continuous Quality Assurance using Selenium WebDriver
 
PPTX
Automation testing with Drupal 8
PDF
Introducing Playwright's New Test Runner
PDF
Unit Testing your React / Redux app (@BucharestJS)
PPT
JavaScript Unit Testing
PPT
Robotframework Presentation - Pinoy Python Meetup 2011January12
Testing with Codeception (Webelement #30)
Efficient JavaScript Unit Testing, May 2012
Continuous Quality Assurance using Selenium WebDriver
 
Automation testing with Drupal 8
Introducing Playwright's New Test Runner
Unit Testing your React / Redux app (@BucharestJS)
JavaScript Unit Testing
Robotframework Presentation - Pinoy Python Meetup 2011January12

What's hot (20)

PPTX
CI / CD w/ Codeception
PPT
JavaScript Unit Testing
ZIP
Automated Frontend Testing
PDF
Night Watch with QA
DOCX
Spring boot competitive tests
PDF
Testing PHP with Codeception
PDF
JavaFX JumpStart @JavaOne 2016
PPTX
Test-Driven JavaScript Development (JavaZone 2010)
PPTX
Jasmine with JS-Test-Driver
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
DOCX
Spring competitive tests
PPTX
Cypress first impressions
PDF
Java fx smart code econ
DOCX
Spring boot competitive tests
PDF
Plugins 2.0: The Overview
PDF
Preparing your code for Java 9
PDF
Test all the things! Automated testing with Drupal 8
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
PPTX
Cache is King
CI / CD w/ Codeception
JavaScript Unit Testing
Automated Frontend Testing
Night Watch with QA
Spring boot competitive tests
Testing PHP with Codeception
JavaFX JumpStart @JavaOne 2016
Test-Driven JavaScript Development (JavaZone 2010)
Jasmine with JS-Test-Driver
FITC - Here Be Dragons: Advanced JavaScript Debugging
Spring competitive tests
Cypress first impressions
Java fx smart code econ
Spring boot competitive tests
Plugins 2.0: The Overview
Preparing your code for Java 9
Test all the things! Automated testing with Drupal 8
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Cache is King
Ad

Similar to Audit your reactive applications (20)

PPT
Reactive java programming for the impatient
PDF
Diagnose Your Microservices
PPTX
Debugging java deployments_2
PPTX
Designing, Implementing, and Using Reactive APIs
PPTX
Reactive for the Impatient - Mary Grygleski
PDF
Web Sphere Problem Determination Ext
PPTX
Going Reactive in Java with Typesafe Reactive Platform
PDF
DBI-Assisted Android Application Reverse Engineering
PDF
Reactive All the Way Down the Stack
PDF
Not Only Streams for Akademia JLabs
PPTX
Introduction to Bitreactive
PDF
What are the benefits of reactive programming in java
PDF
An introduction to Reactive applications, Reactive Streams, and options for t...
PDF
The Final Frontier
ODP
How to bake reactive behavior into your Java EE applications
PPTX
Software Composition Analysis Deep Dive
PPT
Api tools overview
PPTX
Open Source Power Tools - Opensouthcode 2018-06-02
PPTX
Reactive applications tools of the trade huff po
PDF
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
Reactive java programming for the impatient
Diagnose Your Microservices
Debugging java deployments_2
Designing, Implementing, and Using Reactive APIs
Reactive for the Impatient - Mary Grygleski
Web Sphere Problem Determination Ext
Going Reactive in Java with Typesafe Reactive Platform
DBI-Assisted Android Application Reverse Engineering
Reactive All the Way Down the Stack
Not Only Streams for Akademia JLabs
Introduction to Bitreactive
What are the benefits of reactive programming in java
An introduction to Reactive applications, Reactive Streams, and options for t...
The Final Frontier
How to bake reactive behavior into your Java EE applications
Software Composition Analysis Deep Dive
Api tools overview
Open Source Power Tools - Opensouthcode 2018-06-02
Reactive applications tools of the trade huff po
apidays New York 2023 - Android Applications and APIs Hacking, Gabrielle Botb...
Ad

Recently uploaded (20)

DOCX
Unit-3 cyber security network security of internet system
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
ppt for upby gurvinder singh padamload.pptx
PPTX
Internet___Basics___Styled_ presentation
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
nagasai stick diagrams in very large scale integratiom.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
Testing WebRTC applications at scale.pdf
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
ENCOR_Chapter_11 - ‌BGP implementation.pptx
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
ENCOR_Chapter_10 - OSPFv3 Attribution.pptx
PDF
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
PPT
256065457-Anaesthesia-in-Liver-Disease-Patient.ppt
PPTX
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
PDF
WebRTC in SignalWire - troubleshooting media negotiation
Unit-3 cyber security network security of internet system
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
ppt for upby gurvinder singh padamload.pptx
Internet___Basics___Styled_ presentation
An introduction to the IFRS (ISSB) Stndards.pdf
nagasai stick diagrams in very large scale integratiom.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Testing WebRTC applications at scale.pdf
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Unit-1 introduction to cyber security discuss about how to secure a system
Decoding a Decade: 10 Years of Applied CTI Discipline
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENCOR_Chapter_11 - ‌BGP implementation.pptx
Job_Card_System_Styled_lorem_ipsum_.pptx
ENCOR_Chapter_10 - OSPFv3 Attribution.pptx
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
256065457-Anaesthesia-in-Liver-Disease-Patient.ppt
PPT_M4.3_WORKING WITH SLIDES APPLIED.pptx
WebRTC in SignalWire - troubleshooting media negotiation

Audit your reactive applications

  • 1. Audit your reactive applications +PhilippePrados @pprados +François-Xavier Bonnet @fxbonnet
  • 2. What is reactive? ● Responsive ● Resilient ● Elastic ● Message driven “Non-blocking communication allows recipients to only consume resources while active, leading to less system overhead.” http://www.reactivemanifesto.org/
  • 3. The problem: blocking APIs ● Blocking APIs consume the thread pool because of too much waiting time  ● We should have no more threads than cores on the machine
  • 4. How do I track blocking API calls? ● Modifying the JVM? ● Generating warnings during compilation? ● Instrumenting the code at runtime using a JVM agent? Code Compiler JRE
  • 5. Modifying the JDK ● This strategy has been used by Google in Android SDK in order to avoid the use of blocking API in a UI thread ● Not too hard for pure java methods but what about native methods (OS specific)?
  • 6. Generating warnings during compilation? ● Annotate JDK methods inside an IDE? Used by IntelliJ for @Nullable and @NotNull annotations but not standard ● JSR 269 allows to do things at compile time https://jcp.org/en/jsr/detail?id=269 ● Compilation occurs in several phases, we can access the syntax tree only after the first phase o The pure syntax, not the called method name
  • 7. Generating warnings during compilation? ● JSR308 allows to do things after the second phase http://types.cs.washington.edu/jsr308/ o The augmented syntax tree ● But not included in JDK 8
  • 8. Generating warnings during compilation? ● Many things can be seen only at runtime ● Ex: java.io.Reader.read() is blocking for a file or network connection but not for memory
  • 9. Instrumenting the code at runtime using a JVM agent? ● Patch the code at application startup ● Solution:
  • 10. Auditing using Aspect programing ● Load time weaving ● Java agent at JVM startup ● List all blocking methods ● But, can not be weaving the SDK itself Some tweaks: ● Some methods might be blocking depending on the arguments or internal use!
  • 13. Log output with Play DEMO
  • 14. Log output with Play HIGH : Call method void java.io.PrintWriter.print(String) with /tmp/sbt1269029892078438540.log com.octo.reactive.audit.lib.FileReactiveAuditException: Call method void java.io.PrintWriter.print(String) with /tmp/sbt1269029892078438540.log at thread "play-internal-execution-context-1" at sbt.ConsoleOut$$anon$3.print(ConsoleOut.scala:52) at sbt.ConsoleLogger.setColor(ConsoleLogger.scala:158) at sbt.ConsoleLogger.reset(ConsoleLogger.scala:153) at sbt.ConsoleLogger.sbt$ConsoleLogger$$printLabeledLine(ConsoleLogger.scala:168) at sbt.ConsoleLogger$$anonfun$log$1.apply(ConsoleLogger.scala:164) at sbt.ConsoleLogger$$anonfun$log$1.apply(ConsoleLogger.scala:163) at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108) at sbt.ConsoleLogger.log(ConsoleLogger.scala:163) at sbt.ConsoleLogger.log(ConsoleLogger.scala:151) at sbt.AbstractLogger.log(Logger.scala:31) ...
  • 15. Use it with in testing scope ● Because the analysis is performed on effective method calls at runtime ● The audit should be used while running o Integration tests o Functional tests ● Not relevant in unit tests
  • 16. Configuration ● Alert for all calls to blocking methods? ● We need some filters o Startup shift o Thread name (pattern matching) o Kind and level of blocking call (CPU, File, Network) o Annotations
  • 18. Log output with Play DEMO
  • 19. Checked SDK APIs +500 java.io java.lang java.net java.nio.channel java.nio.file java.rmi.registry java.rmi.server java.sql java.util java.util.concurrent java.util.concurrent.locks java.util.logger java.util.zip javax.activation javax.imageio javax.net javax.net.ssl javax.rmi javax.rmi.ssl javax.sql.rowset.spi javax.sql.rowset javax.sql javax.tools javax.transaction.xa javax.xml.bind javax.xml.parsers javax.xml.soap javax.xml.ws.spi javax.xml.ws org.xml.sax
  • 20. Supported frameworks/languages/servers Framework Windows Mac/linux unknown > reactive-audit > java %AUDIT_OPTS% ... $ source reactive-audit $ java %AUDIT_OPTS% ... jetty > reactive-audit jetty > java %AUDIT_OPTS% -jar start.jar $ source reactive-audit jetty $ java %AUDIT_OPTS% -jar start.jar catalina > reactive-audit catalina -run catalina run $ reactive-audit catalina -run catalina run play > reactive-audit play -run activator run $ reactive-audit play -run activator run vert.x > reactive-audit vertx -run vertx run ... $ reactive-audit vertx -run vertx run ... maven > reactive-audit maven -run mvn ... $ reactive-audit maven -run mvn ... gradle > reactive-audit gradle -run gradle ... $ reactive-audit gradle -run gradle ... sbt > reactive-audit sbt -run sbt ... $ reactive-audit sbt -run sbt ...
  • 21. Build integration and continuous testing ● Sample script for o Maven o Gradle o Sbt ● You’re welcome to propose others
  • 22. Use it with your reactive project ● Play ● Akka ● VertX ● AsyncHttpClient ● RxJava ● …
  • 23. We need you ! ● Check it with your project ● Improve the rules ● Submit some extensions ● Submit plugins for others tools ● Submit XSTL to format XML log file https://github.com/octo-online/reactive-audit
  • 25. Questions? LES CONTACTS Philippe PRADOS Manager Tribu Reactive +33 (0)6 20 66 71 00 [email protected] François-Xavier Bonnet Consultant +33 (0)6 13 26 82 99 [email protected]

Editor's Notes