Post on 28-Mar-2020
transcript
Copyright©2016, Oracleand/oritsaffiliates.Allrightsreserved.|
UsingSQLandPLSQLforMid-TierDatabaseCaching
DougHood@ScalableDBDougConsultingMemberofTechnicalStaffProductManagerTimesTen In-MemoryDatabase,OracleIn-Memory&OracleNoSQLMay16,2019
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
MemoryHierarchies(oldschool)
Confidential– OracleInternal/Restricted/HighlyRestricted 2
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
MemoryHierarchies(anymodernCPU)
Confidential– OracleInternal/Restricted/HighlyRestricted 3
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
MemoryHierarchies(L1,L2andL3caches&4cores)
Confidential– OracleInternal/Restricted/HighlyRestricted 4
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
MemoryHierarchies(Intel’svision)
Confidential– OracleInternal/Restricted/HighlyRestricted 5
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Latency,ThroughputandScalabilityLatency Howquicklycanoneoperationcomplete
Onesprinterin9.58 seconds~40km/hfor100M[2009]
Throughput Howquicklycanmanyoperationscomplete
Tensprintersinunder11seconds~40km/hfor100m[2009]
Scalability Byaddingmoreresourcescanthroughput keepincreasing
33carson2.5mileovaltrack~250km/hfor804km[Indy500,2017]
Confidential– OracleInternal/Restricted/HighlyRestricted 6
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
LatencyOptimization
Confidential– OracleInternal/Restricted/HighlyRestricted 7
Oracle11.2.0.4RACOracleSunX7-2LNVMe StorageOver50MillionUsers
LatencyisinMicroSeconds…
Before After
43 3
69 6
105 8
121 20
140 18
163 19
231 18
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
WhyCacheData?
Confidential– OracleInternal/Restricted/HighlyRestricted 8
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
WhyCacheData?
• TogetlowerlatencyforSQLstatements• Togetmorethroughput• Togetmorescalability
Confidential– OracleInternal/Restricted/HighlyRestricted 9
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
CachingChallenges
Confidential– OracleInternal/Restricted/HighlyRestricted 10
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
TheBusinessProblem
• DBapps,makethemfasterandcheaper• Domorewithless
Confidential– OracleInternal/Restricted/HighlyRestricted 11
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
TheDevOpsChallenge
• Makeitboring,nosurprises• Standardized,runinVMsorcontainers• Everything isautomated• Figureouteverythingthatcangowrongandbewellbehaved
Confidential– OracleInternal/Restricted/HighlyRestricted 12
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges
• Howmanyusers?Howmanyconcurrentusers?• HowmanyconcurrentOracleDBconnections?• HowmanyconcurrentApplicationServerconnections?• WhataboutHA?WhataboutDR?• Whataboutlatency?
Confidential– OracleInternal/Restricted/HighlyRestricted 13
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges
Confidential– OracleInternal/Restricted/HighlyRestricted 14
Canwedobetter?
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges
Confidential– OracleInternal/Restricted/HighlyRestricted 15
Connectionpool
SharedServers(MTS)
Canwedobetter?
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges
Confidential– OracleInternal/Restricted/HighlyRestricted 16
Connectionpool
Canwedobetter?
Read/writecaches• Offloadwork fromOracle• Offloadconnections fromOracle
SharedServers(MTS)
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges• Gofaster thanNoSQLsolutions&minimize thehardwarecost– Lowerlatencyatthe99th percentile
Confidential– OracleInternal/Restricted/HighlyRestricted 17
• Simpleandscalableisgood,buthowmanymachinesdoyouneed?• Whataboutthe95th and99th percentileforlatency?• Whataboutcachemisses?• Howisthecachekeptuptodate?
99th percentilelatencycanbeashighas324ms…
100th percentilelatencyismanyseconds,timeout>100ms
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
YCSBWorkloadB(95%read,5%write)
Confidential– OracleInternal/Restricted/HighlyRestricted 18
Database TPS Nodes
Cassandra 221K 32
MongoDB 260K 2
CouchBase 454K 9
Redis 1M 3
VoltDB 1.5M 6
AeroSpike 1.6M 1
TimesTen 2.8M 1 Letstalk
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Architecturesandtechnicalchallenges
Confidential– OracleInternal/Restricted/HighlyRestricted 19
Connectionpool
Canwedobetter?
Read/writecaches• Offloadwork fromOracle• Offloadconnections fromOracle
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
CustomermeasuredTimesTenCachelatency
• 97%cachehitratio– 3%ofthetimethedatawasnotinthecache,soneededaroundtriptoOracle
• 99th percentilelatency=1ms
Confidential– OracleInternal/Restricted/HighlyRestricted 20
Percentile Latencyinms
87 0.016
98 0.125
99.7 1
99.99 8
100 423
NoSQLwas324ms
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
CustomermeasuredTimesTenCachelatency
• 97%cachehitratio– 3%ofthetimethedatawasnotinthecache,soneededaroundtriptoOracle
• 99th percentilelatency=1ms
Confidential– OracleInternal/Restricted/HighlyRestricted 21
Percentile Latencyinms
87 0.016
98 0.125
99.7 1
99.99 8
100 423Workingtoimprovethis• Goalis<50msfor100th percentile• Alsodefinea300ms timeout
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Improvingthe100th percentile[maxlatency]
Confidential– OracleInternal/Restricted/HighlyRestricted 22
SQLNetConnection
pool
Canwedobetter?
Read/writecaches• Offloadwork fromOracle• Offloadconnections fromOracle
TimesTenConnection
pool
Forcachemisses,createanewSQLNetconnection!
Thiscanbereallyslow…
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Improvingthe100th percentile[maxlatency]
Confidential– OracleInternal/Restricted/HighlyRestricted 23
SQLNetConnection
pool
Canwedobetter?
Read/writecaches• Offloadwork fromOracle• Offloadconnections fromOracle
SQLNetConnection
pool
TimesTenConnection
pool
Forcachemisses,getconnectionfromTTOCICPratherthanthesharedpool
Tunethepoolfortheexpectedmin/max
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Howisitpossible
• Useareallyfast In-memorySQLRDBMS• UseaCacheDB thatjustrequiresconfiguration• Somehardwareandsoftwaretuning
Confidential– OracleInternal/Restricted/HighlyRestricted 24
T1
T3
T2
• Prepare&bindSQLstatements• Usetherelevantindexes• Dosensiblejoins• UpdatestatisticsforSQLoptimizer• CheckTimesTenSQLstatsforSQLandIObottlenecks
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
MostWidelyUsedRelationalIn-MemoryDatabaseDeployedbyThousandsofCompanies
25
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
RelationalDatabase– Purein-memory– ACIDcompliant– StandardSQL/PLSQL– EntiredatabaseinDRAM
PersistentandRecoverable– DatabaseandTransactionlogspersistedonlocaldiskorflashstorage
– ReplicationtostandbyandDRsystems
26
ExtremelyFast– Microsecondsresponsetime– Veryhighthroughput
HighlyAvailable– Active-Standbyandmulti-masterreplication
– Veryhighperformanceparallelreplication
– HAandDisasterRecovery
OracleTimesTenIn-MemoryDatabase
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
LowLatency- Microseconds ResponseTimePerformance– ResponseTime
Millionthsofa
Second
Millionthsofa
Second
27
TPTBMReadandUpdateE5-2699v4@2.20GHz
2socket,22cores/socket,2threads/core
TimesTen11.2.2.8.0(100Mrows,17GBdata)
1.64
5.06
0.00
1.00
2.00
3.00
4.00
5.00
6.00
SELECTQuery UPDATETransaction
Microsecond
s
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
HLRMobileTransactionsResponseTimeResponseTimeImprovementWithTimesTenApplication-TierDatabaseCache
Intel®XeonCPUE5-2680@2.7GHZ2sockets8cores/socket2hyper-threads/core32vCPU
OracleDatabaseWithTimesTenCacheOracleDatabaseWithoutTimesTenCache
Speedup
17x
10x
17x
44x
69x
31x
29x
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
TimesTenIn-MemoryDatabasePersistenceandRecovery
• TimesTendatabasepersistencecanbeconfiguredon– Flash,SSD,harddiskstorage
• Alltransactionsareloggedandpersisted– Redo,undo,andrecovery
• DualdatabaseCheckpointfiles– Databaserestart– Databaserecoveryafterfailures
TimesTen Checkpoint
Files
TimesTen Transaction
Log Files
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
CacheDB =OracleApplicationTierDatabaseCacheAfeatureofOracleEnterpriseEdition
30
T1
T3
T2T1
T3
T2
CacheAgent
RepAgent
Metadata• Cachegroups
Batchreadstorefreshthecache
Parallelbatchwrites
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
FlexibleCacheGroupConfigurations
• CacheGroupdescribestheOracleDatabasetablestocache– Allorsubsetofrowsandcolumns– DefinedusingSQLCREATECACHEGROUPPremierUsersFROMOE.CUSTOMER(NAMEVARCHAR2(100)NOTNULL,ADDRVARCHAR2(100)
)WHEREOE.CUSTOMER.ORDER>500;
• CachetablesareregulartablesinTimesTen– Joins/search,insert/update/delete
ApplicationTransactions CacheGroups
AutomaticDataSynchronization
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
createdynamicreadonly cachegroupmyReadCache1autorefreshmodeincrementalinterval 100millsecondsstateonfrom hr.employees (employee_id number(6)notnull,
first_name varchar2(20),last_name varchar2(25)notnull,hire_datedatenotnull,job_id varchar2(10)notnull,salary number(8,2),manager_id number(6),department_id number(4),
primarykey(employee_id)),hr.job_history (employee_idnumber(6)notnull,
start_datedatenotnull,end_datedatenotnull,job_idvarchar2(10)notnull,department_idnumber(4),
primarykey (employee_id,start_date),foreignkey (employee_id)references hr.employees(employee_id));
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
OracleTimesTen• Onetechnology,twoproducts,threedeploymentmodes
ApplicationTierDatabaseCache
StandaloneIn-MemoryDatabaseforOLTP
andanalytics
Application
TimesTenScaleout
SingleSystemImageIn-MemoryDatabase
OracleTimesTenIn-MemoryDatabase
Application
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Summary• CloudScaleread/writecachingwith1mslatencyat99th percentile• OracleTimesTenisfasterthananyNoSQLDB• Cachingisconfiguration,notcoding• UseTimesTen PLSQLstoredprocedurestominimizenetworkhops
• WriteTimesTenappsasifitwereanOracleDB*– SQL,JDBC,PLSQL,OCI,ODBC,ODP.Net,Pro*C,Pro*COBOL– R,Python,Node.js,Go,Ruby&PHP
Subset oftheOracleSQLandPLSQL