java-based microservices: understanding the benefits and boundaries for your application structure
TRANSCRIPT
![Page 1: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/1.jpg)
1 #DynatraceCOMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
Asad Ali, @AsadThoughts
Java-Based Microservices
![Page 2: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/2.jpg)
2 #DynatraceCOMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
Topics
• Overview of Producer Consumer Pattern
• Usage of Producer Consumer Pattern @ Dynatrace AppMon
• Microservices & Producer Consumer Pattern
![Page 3: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/3.jpg)
3 #Dynatrace
Producer Consumer 2
Consumer 1
Consumer N
Work Queue
Producer Consumer Pattern
![Page 4: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/4.jpg)
4 #Dynatrace
Producer Consumer 2
Consumer 1
Consumer N
Collection
Work Queue
Producer Consumer Pattern
![Page 5: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/5.jpg)
5 #DynatraceCOMPANY CONFIDENTIAL – DO NOT DISTRIBUTE
Producer Consumer @ Dynatrace AppMon
![Page 6: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/6.jpg)
6 #Dynatrace
Dynatrace AppMon ArchitectureJava/.NET
PurePathCollector
dynaTraceServer
Web Server/ PHP
C++, VB, ADK
MQ/ESB
![Page 7: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/7.jpg)
7 #Dynatrace
Metrics sent by agents
Visits
![Page 8: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/8.jpg)
8 #Dynatrace
Producer Consumer 2
Consumer 1
Consumer N
Visit Store Collection
Work QueueCorrelation Engine
Real Time AnalyzerProducer Consumer Within AppMon
![Page 9: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/9.jpg)
9 #Dynatrace
Producer Consumer 2
Consumer 1
Consumer N
Visit Store Collection
Work Queue
Work Queue Getting Full
Problem Symptom
![Page 10: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/10.jpg)
10 #Dynatrace
Individual Transaction View
![Page 11: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/11.jpg)
11 #Dynatrace
Individual Transaction View
![Page 12: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/12.jpg)
12 #Dynatrace
46 threads are in Wait state
Thread Dump Analysis
![Page 13: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/13.jpg)
13 #Dynatrace
Performance Report
![Page 14: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/14.jpg)
14 #Dynatrace
Code Snippet
public synchronized void add(Visit visit) {Objects.requireNonNull(visit);super.add(visit);
}
public synchronized Visit get(int visitId) {return super.get(visitId);
}
![Page 15: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/15.jpg)
15 #Dynatrace
Code Snippet
public synchronized void add(Visit visit) {Objects.requireNonNull(visit);super.add(visit);
}
public synchronized Visit get(int visitId) {return super.get(visitId);
}
Exclusive lock on visitstore caused consumers
to wait on each other
![Page 16: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/16.jpg)
16 #Dynatrace
Optimized Code
public Visit get(int visitId) {final ReadLock readLock = rrwl.readLock();readLock.lock();try {
return super.get(visitId);} finally {
readLock.unlock();}
}
![Page 17: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/17.jpg)
17 #Dynatrace
Optimized Code
public void add(Visit visit) {Objects.requireNonNull(visit);final WriteLock writeLock = rrwl.writeLock();writeLock.lock();try {
size.incrementAndGet();super.add(visit);
} finally {writeLock.unlock();
}}
![Page 18: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/18.jpg)
18 #Dynatrace
Performance Report - Optimized
![Page 19: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/19.jpg)
19 #Dynatrace
Performance Report - Optimized
![Page 20: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/20.jpg)
20 #Dynatrace
Individual Transaction View - Optimized
![Page 21: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/21.jpg)
21 #Dynatrace
Individual Transaction View - Optimized
![Page 22: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/22.jpg)
22 #Dynatrace
![Page 23: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/23.jpg)
23 #Dynatrace
Lesson #1
Analyze response time of your transactions
![Page 24: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/24.jpg)
24 #Dynatrace
Lesson #2
public Visit get(int visitId) {final ReadLock readLock = rrwl.readLock();readLock.lock();try {
return super.get(visitId);} finally {
readLock.unlock();}
}
Parallelize reads
![Page 25: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/25.jpg)
25 #Dynatrace
Lesson #3
Compare before and afterresponse time and throughput
![Page 26: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/26.jpg)
26 #Dynatrace
Microservices & Producer Consumer Pattern
![Page 27: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/27.jpg)
27 #Dynatrace
Producer Consumer 2
Consumer 1
Consumer N
Work Queue
Producer Consumer Pattern
![Page 28: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/28.jpg)
28 #Dynatrace
JVM1
JVM
Producer
JMS
Producer Consumer With MicroservicesConsumer 1
JVM2
Consumer 2
JVMn
Consumer N
![Page 29: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/29.jpg)
29 #Dynatrace
Producer Consumer With Microservices
JMS JVM1
Consumer 1
JVM
ProducerJVM2
Consumer 2
JVMn
Consumer N
![Page 30: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/30.jpg)
30 #Dynatrace
Monolithic Application
![Page 31: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/31.jpg)
31 #Dynatrace
2.68s Load Time
Monolithic Application
![Page 32: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/32.jpg)
32 #Dynatrace
2.68s Load Time
94.09% CPU Bound
Monolithic Application
![Page 33: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/33.jpg)
33 #Dynatrace
Can‘t scale vertically endlessly!
2.68s Load Time
94.09% CPU Bound
Monolithic Application
![Page 34: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/34.jpg)
34 #Dynatrace
Frontendto Cloud
Scale Backendin Containers!
Service Approach
![Page 35: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/35.jpg)
35 #Dynatrace
Go Live - 7am
![Page 36: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/36.jpg)
36 #Dynatrace
Go Live - 12pm
![Page 37: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/37.jpg)
37 #Dynatrace
What Went Wrong?
![Page 38: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/38.jpg)
38 #Dynatrace
26.7s Load Time5kB Payload
Single Search Query End-to-End
![Page 39: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/39.jpg)
39 #Dynatrace
26.7s Load Time5kB Payload
33! Service Calls
99kB - 3kB for each call!
Single Search Query End-to-End
![Page 40: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/40.jpg)
40 #Dynatrace
26.7s Load Time5kB Payload
33! Service Calls
99kB - 3kB for each call!
Architecture ViolationDirect access to DB from frontend service
Single Search Query End-to-End
![Page 41: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/41.jpg)
41 #Dynatrace
26.7s Load Time5kB Payload
33! Service Calls
99kB - 3kB for each call!
171! Total SQL Count
Architecture ViolationDirect access to DB from frontend service
Single Search Query End-to-End
![Page 42: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/42.jpg)
42 #Dynatrace
The Fixed End-to-End Use Case
“Re-Architect” vs “Migrate” to Service-Orientation
2.5s (vs 26.7) 5kB Payload
![Page 43: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/43.jpg)
43 #Dynatrace
The Fixed End-to-End Use Case
“Re-Architect” vs “Migrate” to Service-Orientation
2.5s (vs 26.7) 5kB Payload
1! (vs 33!) Service Call
5kB (vs 99) Payload!
![Page 44: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/44.jpg)
44 #Dynatrace
The Fixed End-to-End Use Case
“Re-Architect” vs “Migrate” to Service-Orientation
2.5s (vs 26.7) 5kB Payload
1! (vs 33!) Service Call
5kB (vs 99) Payload!
3! (vs 177) Total SQL Count
![Page 45: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/45.jpg)
45 #Dynatrace
![Page 46: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/46.jpg)
46 #Dynatrace
Lesson #1
JMS JVM1
Consumer 1
JVM
ProducerJVM2
Consumer 2
JVMn
Consumer N
Pay attention to dependencies when using Microservices
![Page 47: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/47.jpg)
47 #Dynatrace
Lesson #2
Measure inter-tier communicationtime for every transaction
![Page 48: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/48.jpg)
48 #Dynatrace
Asad AliProduct Specialist
@AsadThoughts
http://blog.dynatrace.com
http://bit.ly/dtpersonal
![Page 49: Java-Based Microservices: Understanding the Benefits and Boundaries for Your Application Structure](https://reader035.vdocuments.mx/reader035/viewer/2022081605/58efc4381a28ab374b8b45a7/html5/thumbnails/49.jpg)
49 #Dynatrace
Over To You
• Power of producer consumer pattern• Parallelize your reads• Measure before and after • Affect of Inter-tier communication in
Microservices• Do not ignore dependencies