performance/scalability with jdbc, ucp & oracle database 12c

Download Performance/Scalability with JDBC, UCP & Oracle Database 12c

If you can't read please download the document

Upload: steven-barber

Post on 18-Jan-2018

257 views

Category:

Documents


1 download

DESCRIPTION

Performance/Scalability with JDBC, UCP & Oracle Database 12c Nirmala Sundarappa Principal Product Manager & Douglas Surber Consulting Member Technical Staff Oracle JDBC & UCP October 2nd, 2014 This is a Title Slide with Picture slide ideal for including a picture with a brief title, subtitle and presenter information. To customize this slide with your own picture: Right-click the slide area and choose Format Background from the pop-up menu. From the Fill menu, click Picture and texture fill. Under Insert from: click File. Locate your new picture and click Insert. To copy the Customized Background from Another Presentation on PC Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To copy the Customized Background from Another Presentation on Mac Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

TRANSCRIPT

Performance/Scalability with JDBC, UCP & Oracle Database 12c
Nirmala Sundarappa Principal Product Manager & Douglas Surber Consulting Member Technical Staff Oracle JDBC & UCP October 2nd, 2014 This is a Title Slide with Picture slide ideal for including a picture with a brief title, subtitle and presenter information. To customize this slide with your own picture: Right-click the slide area and choose Format Background from the pop-up menu. From the Fill menu, click Pictureand texture fill. Under Insert from: click File. Locate your new picture and click Insert. To copy the Customized Background from Another Presentation on PC Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation thatcontains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing thedesired layout from the layout gallery. Delete any unwanted slides or duplicates. To copy the Customized Background from Another Presentation on Mac Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click orpress Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background youwant. Hold Shift key to select multiple slides. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing thedesired layout from the layout gallery. Copyright 2014, Oracle and/or its affiliates. All rights reserved.| This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by OraclesRevenue Recognition Policy To learn more about this policy, For internal communication, Safe Harbor Statements are not required. However, there is an applicabledisclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for FutureProduct Communications. Copy and paste this link into a web browser, to find out more information. For all external communications such as press release, roadmaps, PowerPoint presentations, Safe HarborStatements are required. You can refer to the link mentioned above to find out additionalinformation/disclaimers required depending on your audience. Program Agenda 1 Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions 2 3 4 5 6 Program Agenda 1 Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions Calls for a Connection Strategy
Creating a DB connection is an expensive database operation Spawn O/S process, network connection, several roundtrips Associated database authentication and session creation Database Connections are expensive to tear down! Repeated Connection/Disconnection can be a huge scaling issue Calls for a ConnectionStrategy Connection Management Strategy
Client Side Connection Pool; Frequent short term connection usage Use Universal Connection Pool (UCP) Very large scale deployment Use Database Resident Connection Pool Single Instance and multiple databases Use Multi-tenant Database Multiple instances, single database scenario RAC Architecture Planned Maintenance Development Steps
Universal Connection Pool (UCP) Most convenient and works with most of the application containers such as Weblogic, Tomcat,Websphere, JBOSS etc., Built-in Failover mechanisms which makes it easier to use with RAC, RAC one etc., PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); Connection conn = pds.getConnection(); Set the below UCP properties for better performance (1) Each 12c DB transaction is associated with a logical transaction ID (LTXID) (2) The main and only purpose of LTXIDs is to help make a reliable determination of the outcome of thelast COMMIT statement (see Transaction Guard) (3) LTXIDs are issued by the RDBMS at the beginning of each transaction and changed only by when thetransaction is committed or rolled back. UCP Properties Description setInitialPoolSize(), setMinPoolSize(), setMaxPoolSize() Set the Pool size based on your application setTimeToLiveConnectionTimeout() , setAbandonConnectionTimeout() Set the Connection Timeout appropriately setMaxStatements() Enable Statement Caching Very Large Scale Deployment Database Resident Connection Pool (DRCP)
Problem to Solve: eCommerce-style deployment => thousands of mid- tiers, each with its own client-side pool Database Resident Connection Pool (DRCP) Thousands of clients requiring database server session for a shortperiod of time Applications mostly have same DB credentials & have identical sessionsettings Specify (SERVER=POOLED) in short URL to enable DRCP Example: Overwhlem the database Only 5 10% connbections in use => waste of memory and system resources RAC for Scalability RAC, RAC one customers
New Retry while service is unavailable alias = (DESCRIPTION_LIST= (LOAD_BALANCE=off) (FAILOVER=on) (DESCRIPTION=(CONNECT_TIMEOUT=90)(TRANSPORT_CONNECT_TIMEOUT=10)(RETRY_COUNT=10)(RETRY_DELAY=3) (ADDRESS_LIST= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=RAC-scan)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=gold))) (DESCRIPTION=(CONNECT_TIMEOUT=90)(TRANSPORT_CONNECT_TIMEOUT=10)(RETRY_COUNT=10)(RETRY_DELAY=10) (ADDRESS=(PROTOCOL=TCP)(HOST= DG-scan)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=gold)))) Connect time Load Balancing Safe for logon storms Balance IPs in Scan Talk about Connect Time Load Balancing Vs Run time Load Balancing. The above URL is for customers using RAC, RAC One etc., Talk about the LOAD_BALANCE = ON and how it does the load balancing between the cluster Program Agenda Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions 2 Hard Parses About Hard Parse
Parse structure andExecution Plan is thrownout when the statementis closed Problems to solve Causes library cache latchcontention Causes shared poolcontention Causes scalability issues Very bad on the server Solution Avoid Hard Parsing usingPrepared Statement &Bind Variables Reduces hard parses on theserver Reduces risk of SQLInjection: Potential Securityissues. Hard Parses An Example Instead of: Change to:
String query = "SELECT EMPLOYEE_ID, LAST_NAME,SALARYFROM "+"EMPLOYEES WHERE EMPLOYEE_ID = " generateNumber(MIN_EMPLOYEE_ID, MAX_EMPLOYEE_ID); pstmt = connection.prepareStatement(query); rs = pstmt.executeQuery(); Change to: String query = "SELECT EMPLOYEE_ID, LAST_NAME, SALARY FROM"+"EMPLOYEES WHERE EMPLOYEE_ID = ?"; pstmt = connection.prepareStatement(query); pstmt.setInt(1, n); rs = pstmt.executeQuery(); Soft Parses About Soft Parse
Parse structure andExecution Plan are savedand re-used. Session executes astatement that exists inshared pool Creates session specificcursor context Metadata processing Problems to solve Though light weight, cantake more time Solution Enable Statement caching oracleDataSource.setImplicit CachingEnabled(true) Choose the correct cachesize to best utilize thememory connection.setStatementCac heSize(10); Program Agenda Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions 3 Large Objects (LOBs) LOB API Data API
Recommended for offset based access Use for large LOBs (MBs) Data API Handle LOBs like LONG or LONG RAW columns Recommended for small LOBs No extra roundtrips Oracle Database 11g Improvements for LOBs BASIC LOBs: Tune SDU & Use PreFetching SECUREFILES LOBs: Vectored I/O (a.k.a. Zero Copy network transfer) Program Agenda Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions 4 Result Set Caching Shared across multiple connections from the same Data Source in themiddle tier Faster access to frequently queried data Some of the benchmarks showed 3x improvement Server side configuration to enable Result Set Caching RESULT_CACHE_MAX_SIZE Should be set to 0 RESULT_CACHE_REMOTE_EXPIRATION Specifies expiration time (in minutes) for a result in theserver result cache Result Set Caching Problems to Solve
Avoid Wasteful Re-execution Faster access to frequently queried data Some of the benchmarks showed 3x improvement Server side configuration to enable Result Set Caching RESULT_CACHE_MAX_SIZE Should be set to 0 RESULT_CACHE_REMOTE_EXPIRATION Specifies expiration time (in minutes) for a result in theserver result cache Program Agenda Connections Hard and Soft Parses LOB Operations Result Set Cache Array Operations/Stored Procedures Questions 5 Stored Procedures Best Practices
Bundle multiple SQL statements in one call Use anonymous blocks or stored procedures Eliminates roundtrips to database Eliminates moving data between database and client Can improve performance dramatically Monitor roundtrips and bytes transferred stats High values may indicate optimization opportunities Oracle furnishes Java and PL/SQL Stored Procedures Questions Questions ???