blazing fast application performance using in-memory oltp...

43
Blazing Fast Application Performance Using In-Memory OLTP on Windows Azure VMs Balmukund, Support Escalation Engineer

Upload: others

Post on 08-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Blazing Fast Application Performance Using In-Memory OLTP on Windows Azure VMs

Balmukund, Support Escalation Engineer

Page 2: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Agenda

• What is IaaS?

• Overview of In-Memory OLTP

• Combining IaaS and In-Memory OLTP

• Demo

Page 3: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions
Page 4: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Ready?

Page 5: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Test # 1

Page 6: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Answer # 1

Page 7: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Ready?

Page 8: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Test # 2

FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITHTHE EXPERIENCE OF YEARS…

Page 9: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITHTHE EXPERIENCE OF YEARS…

Answer # 2

Page 10: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Ready?

Page 11: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Test # 3

You cnat bielveetaht u cuold raedtihs sneetcne

Page 12: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Solution for Slow Response?

Page 13: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Lord RAM

Page 14: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

RAM RUM?

Hekaton

Page 15: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Computer RAM?

Page 16: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

More CPU?

Page 17: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Super Heroes

Page 18: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory-optimized, but durable

Very high performance OLTP engine

Fully integrated into SQL Server

Memory-optimized, but durable

Very high performance OLTP engine

Fully integratedinto SQL Server

Architected for modern CPUs

Page 19: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Myths About In-Memory OLTP

• SQL Server In-Memory OLTP is a recent response to competitors’ offerings

• In-Memory OLTP is like DBCC PINTABLE

• In-Memory Databases are new separate products

• You can use In-Memory OLTP in an existing SQL Server app with NO changes whatsoever

• Since tables are in memory, the data is not Durable or Highly Available – I will lose it after server crash

Page 20: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Hekaton or In-Memory OLTP?

Page 21: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory-optimized Table

Filegroup Data Filegroup

SQLServr.exeHekaton Engine: Memory_optimized

Tables & Indexes

TDS Handler and Session Management

Native-

Compiled SPs

and Schema

Buffer Pool

Execution Plan cache for

ad-hoc T-SQL and SPs

Application

Transaction Log

Query

Interop

Non-durable

Table option T1 T3T2

T1 T3T2

T1 T3T2

T1 T3T2

Tables

Indexes

T-SQL Interpreter

T1 T3T2

T1 T3T2

Access Methods

Parser,

Catalog,

Optimizer

Hekaton

Compiler

Hekaton

Component

Key ==> Existing SQL

Component

Generated

.dll

20-40x more efficientReal Apps see 2-30x

Reduced log contention; Low

latency still critical for performance

Few improvements in comm layers

Page 22: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Interpretation of query plans

Page 23: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Page

#

Buffer FrameLatch

Q1 checks

for page 7

Frame

allocated

& latched

I/O Initiated

Q1 blocked

I/O

completes

Latch

released

Q1 & Q2

continue

25 ms.

Q2 checks

for page 7

TimeQ2

blocked by

latch

7

Buffer

Pool

Page 24: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Q1: A = A + 100 DB actions: Read A, A=A+100, Write A

Q1

Read A

A=A+100

Q1

Write A

A = 1100

Q2

Read A

A=A+500

Q2

Write A

A = 1600A = 1000

Time

A = 1000

TimeQ1

Read AQ2

Read A

A=A+100

Q1

Write A

A = 1100

A=A+500

Q2

Write A

A = 1500

Schedule 1 is a serial schedule: Q1 followed by Q2

Schedule 2 is not equivalent to any serialschedule.

Final value of A does not reflect Q1’s update!

Q2: A = A + 500 DB actions: Read A, A=A+500, Write A

Page 25: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions
Page 26: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

A = 1000Time

Q1 Set

X (eXclusive)

Lock on A

Q2

Read A

A=A+100A = 1100

A=A+500

Q2

Write A

A = 1600

Q1

Read A

Q2

Attempts

to Set X

Lock on A

Q2

Blocked

Q1

Write A

Q1

Release

Lock on A

Q2

Unblocked

Page 27: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

HOW TO USE IN-MEMORY OLTP?

Page 28: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

CREATE TABLE RecentSales (

ItemID int32 not null

PRIMARY KEY NONCLUSTERED HASH,

Name varchar not null,Price decimal not null

) with ( MEMORY_OPTIMIZED = ON,

DURABILITY = SCHEMA_AND_DATA)

Page 29: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions
Page 30: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Via standard ad-hoc T-SQL query interface

(termed “interop”) –Up to 3X perf boost

Adapt, recompile, & execute T-SQL stored procedures –

5X to 30X perf boost(Caveat: some language restrictions

for V1)

Page 31: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Slow Fa

st

Slow Fa

st

Read Thread

Throughput

Read

Threads

Read

Threads

Read Thread

Throughput

Latch

Lock-free

Latch

Page 32: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Latch

Lock-free

Slow Fa

st

Slow Fa

st

Read Thread

Throughput

Read

Threads

Read

Threads

Read Thread

Throughput

Latch

Page 33: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Latch

Slow Fa

st

Slow Fa

st

Read

Threads

Read

Threads

Update Thread

Read Thread

Throughput

Lock-free

Read Thread

Throughput

Latch

Page 34: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

In-Memory OLTP Architectural Pillars

SQL Server

Integration

• Same manageability,

administration &

development

experience

• Integrated queries &

transactions

• Integrated HA and

backup/restore

Main-Memory

Optimized

• Direct pointers to

rows

• Indexes exist only in

memory

• No buffer pool

• No write-ahead

logging

• Stream-based

storage

Non-Blocking

Execution

• Multi-version

optimistic

concurrency control,

full ACID support

• Lock-free data

structures

• No locks, latches or

spinlocks,

• No I/O in transaction

T-SQL Compiled to

Native Machine Code

• T-SQL compiled to

machine code

leveraging VC

compiler

• Procedure and its

queries, becomes a C

function

• Aggressive compile-

time optimizations

Arc

hitect

ura

l Pill

ars

Resu

lts

Hybrid engine and

integrated experience

In-memory cache

speed with capabilities

of a database

Transactions execute to

completion without

blocking

Queries & business

logic run at native-code

speed

Princi

ple

s

Performance-critical

data fits in memoryConflicts are Rare

Push decisions to

compilation timeBuilt-In

Page 35: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory Optimized Tables and Indexes

50, ∞ Pinal BLR

Timestamps NameChain ptrs City

Hash index

on CityHash index

on Name

90, ∞ Vinod Chennai

f(Pinal)

f(Vinod)

f(BLR)

f(Chennai)

Page 36: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory Optimized Tables and Indexes

50, ∞ Pinal BLR

Timestamps NameChain ptrs City

Hash index

on CityHash index

on Name

T100: INSERT (Balu, BLR)

100, ∞ Balu BLR

90, ∞ Vinod Chennai

f(Balu) f(BLR)

Page 37: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

90, 150 Vinod Chennai

Memory Optimized Tables and Indexes

50, ∞ Pinal BLR

Timestamps NameChain ptrs City

Hash index

on CityHash index

on Name

T150: DELETE (Vinod, Chennai)

100, ∞ Balu BLR

Page 38: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory Optimized Tables and Indexes

90, 150 Vinod Chennai

50, ∞ Pinal BLR

Timestamps NameChain ptrs City

Hash index

on CityHash index

on Name

T200: UPDATE

(Balu, BLR) to

(Balu, Chennai)

100, ∞ Balu BLR

200, ∞ Balu Chennai

100, 200

f(Chennai)

f(Balu)

Page 39: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Memory Optimized Tables and Indexes

90, 150 Vinod Chennai

50, ∞ Pinal BLR

Timestamps NameChain ptrs City

Hash index

on CityHash index

on Name

T250: Garbage collection

100, 200 Balu BLR

200, ∞ Balu Chennai

f(Balu)

f(Pinal)

f(Chennnai)

f(BLR)

Page 40: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Suitable Application Characteristics

• Application is suited for in-memory processing– All performance critical data already fits in memory

– Transaction locking or physical latching causing stalls and blocking

• Application is “OLTP-Like”– Relatively short-lived transactions

– High degree of concurrent transactions from many connections

– Examples: Stock trading, travel reservations, order processing

• Application migration simplified if– Stored procedures used

– Performance problems isolated to subset of tables and SPs

Page 41: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Special Thanks

• David Dewitt

• Microsoft Jim Gray Systems Lab

Page 42: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions

Cristian Diaconu

Craig Freedman

Mike Zwilling

Hideaki Kimura

Rimma

Nehme

Contributors

Page 43: Blazing Fast Application Performance Using In-Memory OLTP ...developermarch.com/developersummit/2015/report/... · • Application is “OLTP-Like” –Relatively short-lived transactions