• Save
W-JAX Performance Workshop - Database Performance
Upcoming SlideShare
Loading in...5

W-JAX Performance Workshop - Database Performance






Total Views
Views on SlideShare
Embed Views



5 Embeds 333

http://www.techgig.com 292
http://blog.dynatrace.com 35
http://www.techgig.timesjobs.com 4
http://techgig.in 1
http://apmblog.compuware.com 1



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • Working with caches
  • Working with caches

W-JAX Performance Workshop - Database Performance W-JAX Performance Workshop - Database Performance Presentation Transcript

  • Java Enterprise Performance Database Performance
    • Architectural Considerations
  • Database Application from 10.000 ft
  • Database Applicaction X-Rayed
    • O/R Mapping
  • Peristence Frameworks
    • Enable
      • easy object-oriented access to relational data
      • faster development of database-centric applications
      • out-of-the-box generic database access logic
      • neglecting the complexity of SQL-based database access
    • Require
      • Deep understanding
      • Thorough tuning
      • Runtime Analysis
  • Persistence (JPA) Frameworks
    • Work ID oriented
    • Are object based
    • Seperate data loading and construction
    • Require query/loading tuning
    • Provide multi-level caching
  • Lazy vs. Eager loading Application Database select ... from master select ... from detail select ... from detail select ... from detail Application Database select ... from master, detail where ..
  • Too many SQL calls (N+1 Query) Application Database select ... where id=1 select ... where id=1 select ... where id=100
    • O/R Mapper Configuration
    • Container managed persistence
    • Bad coding practices
    • Live Demo
    • Caching
  • Generic Caching Architecture Persistence Framework JDBC Layer Database Execution Plan Cache Prepared Statement Cache Cross Session Cache Session Caches Query Cache(s)
  • Caching
    • Avoid unnecessary database access
    • Consumes system resources
    • Requires good configuration based on usage patterns
    • Checklist
      • Data is only read or also written
      • Data is used at many places in the applications
      • Data changes infrequently
      • Data is only used in current application
    • Live Demo
    • The JDBC Layer
  • Prepared Statements
    • Can speed up SQL execution
    • Execution plan of statement can be cached
    • Actual implementation depends on DB driver
      • always check impact
      • verify your implementation
    • Might consume expensive resources (DB cursors)
      • use with care
      • understand your SQL driver
  • Connection Pooling Application Database
    • Connection Pools are shared resources
    • Scaling depends on actual load
    • Wrong scaling may lead to volatile response times
  • Connection Handling Increased time to connect while DB and app stays stable
    • 1 DB connection
    • 10 DB connections
    • 1 DB connection 200 ms less connection usage
  • Query more data then needed Application First Name Last Name Country Mike Tom Frank Sinatra Jones Myers Germany firstname lastname birthdate USA Person Address street streetNo city country Austria Database select * from person, address
  • Release Connections early Application Connection getConnection() closeConnection() Connection locked Application Connection getConnection() closeConnection() Connection locked Code requiring DB access Code NOT requiring DB access
    • Problem Patterns
  • Antipattern – Application vs. Data Design
    • Description
    • Application and Database view of application do not match, resulting in bad performance
    • Resolution
    • Common design session between DBA and application developer
  • Antipattern – Bulk Operations via Framework
    • Description
    • Running bulk operations via O/R mappers consumes massive memory and results in unnecessary database operations
    • Resolution
    • Direct Maninpulation at SQL level
  • Antipattern – Wrong Loading Strategy
    • Description
    • Wrong usage of lazy and eager loading results in unnecessary database calls .
    • Resolution
    • Make everything lazy first and define eager fetching based on runtime behaviour
  • Antipattern – Wrong Caching Strategy
    • Description
    • Although caching is used the application is extremely slow and memory consumption is high.
    • Resolution
    • Verify caching works properly by runtime analysis and tune accordingly
    • Testing
  • What to consider during testing
    • Combine read/write queries
    • Vary input parameters
    • Test in realistic concurrency scenarios
    • Test at different load levels
  • Questions to Answer
    • Prepared Statement Usage
    • Duplicate queries
    • Long lasting queries
    • Queries per use case (transaction)
    • Time to get/use connection
    • Used access patterns
    • Monitoring
    • & Diagnosis
  • Statement Statistics are your friend
  • Monitoring your Connection Pools
    • Used Connections
    • Available/Idle Connections
    • Connection Wait Time
    • Connections created
    • Connections destroyed
  • Monitoring your Cache Usage
    • Cache Hits/Misses
    • Cache Size
    • In case of problems
      • Actual cache requests
      • Time between requests for same object
  • alois.reitbauer@dynatrace.com Mail blog.dynatrace.com Blog AloisReitbauer Twitter