Top .NET, Java & Web Performance Problems. Why these apps failed, how to avoid it and which metrics to look at, e.g: # of Busy vs. Idle Worker Threads, Connection Pool Acquisition Time, # Exceptions Thrown, ...
18. 18 @Dynatrace
Online Banking: Slow Balance Check
1.69s (=101s!) To
Check Balance!
87% spent in IIS 600! SQL Executions
19. 19 @Dynatrace
#1 Time really spent in IIS?
Tip: Elapsed Time tells us WHEN a
Method was executed!
Finding: Thread 32 in IIS waited 87s to
pass control to Thread 30 in ASP.NET
Tip: Thread# gives us insight on
Thread Queues / Switches
20. 20 @Dynatrace
#2 What about these SQL Executions?
Finding: EVERY SQL
statement is executed on
ITS OWN Connection!
Tip: Look at
âGetConnectionâ
21. 21 @Dynatrace
#2 SQL Executions! continued âŚ
#1: Same SQL is executed 67! times
#2: NO PREPARATION
because everything
executed on new
Connection
27. 27 @Dynatrace
Using Hibernate results in 4k+ SQL Statements to
display 3 items!
Hibernate Executes
4k+ Statements
Individual Execution
VERY FAST
But Total SUM
takes 6s
28. 28 @Dynatrace
⢠Proper Sizing Specifications
⢠Understand the Frameworks you are using
Lessons Learned
32. 32 @Dynatrace
#1 Banking: Transaction History CSV Download!
Remember: High GC doesnât
necessarily mean that this request
has a memory problem â BUT - âŚ
Root Cause:
Heavy use of String.Concat to build the CSV output in Memory
Recommendations:
#1: Use System.Text.StringBuilder instead of String.Concat
#2: Write directly back to OutputStream
Problem: Takes 207s! To download.
87% of Time spent in Garbage
Collection
33. 33 @Dynatrace
#2 Store: Rendering Search Result
Problem: 4.4s to render
result page
Root Cause: Custom RegEx
Library with performance
issues on large strings
34. 34 @Dynatrace
#3 Store: Occasional Performance Spikes
Problem: Occasional Spikes!
Never seen in Development
38. 38 @Dynatrace
⢠CSV Export Example
⢠Donât build large Strings in Memory with String.Concat
⢠Write to output stream and use StringBuilder
⢠Search Result Page
⢠Donât implement custom RegEx Library â existing Tools are better
⢠Test with large results and not just small test data
⢠Geo Lookup
⢠Donât trust your Hosting Provider
⢠E.g: Use GeoIP Databases for accurate reverse lookups
Lessons Learned â Use Better Tools / Libraries
42. 42 @Dynatrace
⢠Symptoms
⢠HTML takes between 60 and 120s to render
⢠High GC Time
⢠Assumptions
⢠Bad GC Tuning
⢠Probably bad Database Performance as rendering was simple
Project: Online Room Reservation System
43. 43 @Dynatrace
Developers built own monitoring
void roomreservationReport(int roomid)
{
long startTime = System.currentTimeMillis();
Object data = loadDataForRoom(roomid);
long dataLoadTime = System.currentTimeMillis() - startTime;
generateReport(data, roomid);
}
Result:
Avg. Data Load Time: 45s!
DB Tool says:
Avg. SQL Query: <1ms!
44. 44 @Dynatrace
#1: Loading too much data
24889! Calls to the
Database API!
High CPU and High
Memory Usage to keep all
data in Memory
45. 45 @Dynatrace
#2: On individual connections 12444!
individual
connections
Classical N+1
Query Problem
Individual SQL
really <1ms
46. 46 @Dynatrace
#3: Putting all data in temp Hashtable
Lots of time
spent in
Hashtable.get
Called from their
Entity Objects
47. 47 @Dynatrace
⢠Custom Measuring
⢠Was impacted by Garbage Collection
⢠Just measured overall time but not # SQL Executions
⢠Learn SQL and donât use Hashtables as Workaround
Lesson Learned
void roomreservationReport(int roomid)
{
long startTime = System.currentTimeMillis();
Object data = loadDataForRoom(roomid);
long dataLoadTime = System.currentTimeMillis() - startTime;
generateReport(data, roomid);
}
61. 61 @Dynatrace
â˘# Images
â˘# Redirects
â˘Size of Resources
â˘# SQL Executions
â˘# of SAME SQLs
â˘# Items per Page
â˘# AJAX per Page
Look at these Metrics Before Checking In Code
â˘Time Spent in API
â˘# Calls into API
â˘# Functional Errors
â˘3rd Party calls
â˘# of Domains
â˘Total Size
â˘âŚ
64. 64 @Dynatrace
Example from Web Diagnostics 282! Objects
on that page9.68MB Page Size
8.8s Page Load
Time
Most objects are images
delivered from your main
domain
Very long Connect time
(1.8s) to your CDN
65. 65 @Dynatrace
Example from Server-Side Diagnostics
526s to render that
report
1 SQL running
210s!
Lots of time spent
in logging to Log4J
Lots of time spent
in rendering
67. 67 @Dynatrace
Your Benefits
⢠Free Performance Review
⢠Extended Dynatrace License
âShare Your PurePathâ
bit.ly/sharepurepath
My Benefits
⢠More blog material for next year ď
⢠Gratification that I could help you
More detailed stories can also be found on our blog: http://blog.dynatrace.com
All examples have been found using Dynatrace Free Trial â http://bit.ly/dttrial