jodebrui@microsoft.com
Microsoft Confidential
Version SessionState Performance Technology Bottleneck
SQL Server 2012 12,000 batch requests/sec SQL Server Interpreted T-SQL Latch contentions
SQL Server 2014 300,000 batch requests/sec Memory-Optimized Table, Interpreted T-SQL,
Handling of Split LOBs
CPU
SQL Server 2016 1,200,000 batch requests/sec Memory-Optimized Table with LOB support,
Natively Compiled stored procedures
CPU
In-Memory OLTP performance (bwin)
Source: https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/
Version Cache System Performance Hardware nodes
Mid-Tier Cache solution without SQL Server 150,000 batch requests/sec 19
Solution using SQL Server 2016 1,200,000 batch requests/sec 1
Microsoft Confidential
Version SessionState Performance Technology Bottleneck
SQL Server 2012 12,000 batch requests/sec SQL Server Interpreted T-SQL Latch contentions
SQL Server 2014 300,000 batch requests/sec Memory-Optimized Table, Interpreted T-SQL,
Handling of Split LOBs
CPU
SQL Server 2016 1,200,000 batch requests/sec Memory-Optimized Table with LOB support,
Natively Compiled stored procedures
CPU
In-Memory OLTP performance (bwin)
Source: https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/
Version Cache System Performance Hardware nodes
Mid-Tier Cache solution without SQL Server 150,000 batch requests/sec 19
Solution using SQL Server 2016 1,200,000 batch requests/sec 1
CREATE TABLE [Customer](
[CustomerID] INT NOT NULL
PRIMARY KEY NONCLUSTERED,
[Name] NVARCHAR(250) NOT NULL,
[CustomerSince] DATETIME2 NULL,
INDEX [ICustomerSince] NONCLUSTERED
(CustomerID, CustomerSince)
)
WITH (MEMORY_OPTIMIZED = ON,
DURABILITY = SCHEMA_AND_DATA);
This table is durable (default).
Non-durable tables:
DURABILITY=SCHEMA_ONLY
CREATE PROCEDURE [dbo].[InsertOrder] @id INT, @date DATETIME2
WITH
NATIVE_COMPILATION,
SCHEMABINDING
AS
BEGIN ATOMIC
WITH
(TRANSACTION
ISOLATION LEVEL = SNAPSHOT,
LANGUAGE = N‘Dutch')
-- insert T-SQL here
END
Durability
level
Configuration Pros/Cons Scenarios
Full
durability
Default
DURABILITY=SCHEMA_AND_DATA
Pro:
• Every committed change is
guaranteed to survive failure
Con:
• Latency impact: every commit
requires log IO
Default: most scenarios need full
durability
Delayed
durability
• Transaction commit time
COMMIT WITH (DELAYED_DURABILITY=ON)
• Atomic block of native procedure
BEGIN ATOMIC WITH
(DELAYED_DURABILITY=ON, …)
• Database level
ALTER DATABASE CURRENT SET
DELAYED_DURABILITY=FORCED
Pro:
• Low latency due to no log IO in
transaction execution path
• Efficient log IO due to batching
Con:
• Limited data loss on failure (usually
~60K or ~1ms worth)
Low latency requirements
Can accept some data loss
OR
Copy of recent data exists
elsewhere in case of failure
AlwaysOn auto-failover (sync
replicas) with low latency
Non-
durable
tables
Table creation
DURABILITY=SCHEMA_ONLY
Pro:
• No IO at all
Con:
• Lose data on failure
• Transient data such as session
state
• Caching
• ETL (staging tables)
Durability
level
Configuration Pros/Cons Scenarios
Full
durability
Default
DURABILITY=SCHEMA_AND_DATA
Pro:
• Every committed change is
guaranteed to survive failure
Con:
• Latency impact: every commit
requires log IO
Default: most scenarios need full
durability
Delayed
durability
• Transaction commit time
COMMIT WITH (DELAYED_DURABILITY=ON)
• Atomic block of native procedure
BEGIN ATOMIC WITH
(DELAYED_DURABILITY=ON, …)
• Database level
ALTER DATABASE CURRENT SET
DELAYED_DURABILITY=FORCED
Pro:
• Low latency due to no log IO in
transaction execution path
• Efficient log IO due to batching
Con:
• Limited data loss on failure (usually
~60K or ~1ms worth)
Low latency requirements
Can accept some data loss
OR
Copy of recent data exists
elsewhere in case of failure
AlwaysOn auto-failover (sync
replicas) with low latency
Non-
durable
tables
Table creation
DURABILITY=SCHEMA_ONLY
Pro:
• No IO at all
Con:
• Lose data on failure
• Transient data such as session
state
• Caching
• ETL (staging tables)
Durability
level
Configuration Pros/Cons Scenarios
Full
durability
Default
DURABILITY=SCHEMA_AND_DATA
Pro:
• Every committed change is
guaranteed to survive failure
Con:
• Latency impact: every commit
requires log IO
Default: most scenarios need full
durability
Delayed
durability
• Transaction commit time
COMMIT WITH (DELAYED_DURABILITY=ON)
• Atomic block of native procedure
BEGIN ATOMIC WITH
(DELAYED_DURABILITY=ON, …)
• Database level
ALTER DATABASE CURRENT SET
DELAYED_DURABILITY=FORCED
Pro:
• Low latency due to no log IO in
transaction execution path
• Efficient log IO due to batching
Con:
• Limited data loss on failure (usually
~60K or ~1ms worth)
Low latency requirements
Can accept some data loss
OR
Copy of recent data exists
elsewhere in case of failure
AlwaysOn auto-failover (sync
replicas) with low latency
Non-
durable
tables
Table creation
DURABILITY=SCHEMA_ONLY
Pro:
• No IO at all
Con:
• Lose data on failure
• Transient data such as session
state
• Caching
• ETL (staging tables)
In-Memory OLTP perf demo
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
order processing workload
Domain controllers
Domain controllers
Sensors
Temporal memory-
optimized table
release source code
Applications / Web servers
LineItem1
LineItem2
…
##temp
LineItem1
LineItem2
…
dbo.temp
Memory-optimized table variables and temp tables
Data Warehouse – SQL Server 2016
Resources
• Samples
Perf demo
WideWorldImporters sample DB
IoT sample leveraging temporal tables release page
Azure DB Sample
Enable database for In-Memory OLTP
SQL Server Samples GitHub Repository
• Documentation
Blog on In-Memory OLTP in SQL 2016
Memory-optimized table variables and temp tables
MSDN Documentation for In-Memory OLTP
Azure DB documentation for In-Memory
What’s new in SQL2016
• Migrating apps
In-Memory OLTP Common Workloads and Migration Considerations
Migrating to In-Memory OLTP
Guidelines for using Indexes
• Related videos
Microsoft Virtual Academy talks
Recent investments in In-Memory OLTP
jodebrui@microsoft.com

SQL Server In-Memory OLTP Case Studies

  • 1.
  • 2.
    Microsoft Confidential Version SessionStatePerformance Technology Bottleneck SQL Server 2012 12,000 batch requests/sec SQL Server Interpreted T-SQL Latch contentions SQL Server 2014 300,000 batch requests/sec Memory-Optimized Table, Interpreted T-SQL, Handling of Split LOBs CPU SQL Server 2016 1,200,000 batch requests/sec Memory-Optimized Table with LOB support, Natively Compiled stored procedures CPU In-Memory OLTP performance (bwin) Source: https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/ Version Cache System Performance Hardware nodes Mid-Tier Cache solution without SQL Server 150,000 batch requests/sec 19 Solution using SQL Server 2016 1,200,000 batch requests/sec 1
  • 3.
    Microsoft Confidential Version SessionStatePerformance Technology Bottleneck SQL Server 2012 12,000 batch requests/sec SQL Server Interpreted T-SQL Latch contentions SQL Server 2014 300,000 batch requests/sec Memory-Optimized Table, Interpreted T-SQL, Handling of Split LOBs CPU SQL Server 2016 1,200,000 batch requests/sec Memory-Optimized Table with LOB support, Natively Compiled stored procedures CPU In-Memory OLTP performance (bwin) Source: https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/ Version Cache System Performance Hardware nodes Mid-Tier Cache solution without SQL Server 150,000 batch requests/sec 19 Solution using SQL Server 2016 1,200,000 batch requests/sec 1
  • 7.
    CREATE TABLE [Customer]( [CustomerID]INT NOT NULL PRIMARY KEY NONCLUSTERED, [Name] NVARCHAR(250) NOT NULL, [CustomerSince] DATETIME2 NULL, INDEX [ICustomerSince] NONCLUSTERED (CustomerID, CustomerSince) ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); This table is durable (default). Non-durable tables: DURABILITY=SCHEMA_ONLY
  • 9.
    CREATE PROCEDURE [dbo].[InsertOrder]@id INT, @date DATETIME2 WITH NATIVE_COMPILATION, SCHEMABINDING AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N‘Dutch') -- insert T-SQL here END
  • 11.
    Durability level Configuration Pros/Cons Scenarios Full durability Default DURABILITY=SCHEMA_AND_DATA Pro: •Every committed change is guaranteed to survive failure Con: • Latency impact: every commit requires log IO Default: most scenarios need full durability Delayed durability • Transaction commit time COMMIT WITH (DELAYED_DURABILITY=ON) • Atomic block of native procedure BEGIN ATOMIC WITH (DELAYED_DURABILITY=ON, …) • Database level ALTER DATABASE CURRENT SET DELAYED_DURABILITY=FORCED Pro: • Low latency due to no log IO in transaction execution path • Efficient log IO due to batching Con: • Limited data loss on failure (usually ~60K or ~1ms worth) Low latency requirements Can accept some data loss OR Copy of recent data exists elsewhere in case of failure AlwaysOn auto-failover (sync replicas) with low latency Non- durable tables Table creation DURABILITY=SCHEMA_ONLY Pro: • No IO at all Con: • Lose data on failure • Transient data such as session state • Caching • ETL (staging tables)
  • 12.
    Durability level Configuration Pros/Cons Scenarios Full durability Default DURABILITY=SCHEMA_AND_DATA Pro: •Every committed change is guaranteed to survive failure Con: • Latency impact: every commit requires log IO Default: most scenarios need full durability Delayed durability • Transaction commit time COMMIT WITH (DELAYED_DURABILITY=ON) • Atomic block of native procedure BEGIN ATOMIC WITH (DELAYED_DURABILITY=ON, …) • Database level ALTER DATABASE CURRENT SET DELAYED_DURABILITY=FORCED Pro: • Low latency due to no log IO in transaction execution path • Efficient log IO due to batching Con: • Limited data loss on failure (usually ~60K or ~1ms worth) Low latency requirements Can accept some data loss OR Copy of recent data exists elsewhere in case of failure AlwaysOn auto-failover (sync replicas) with low latency Non- durable tables Table creation DURABILITY=SCHEMA_ONLY Pro: • No IO at all Con: • Lose data on failure • Transient data such as session state • Caching • ETL (staging tables)
  • 13.
    Durability level Configuration Pros/Cons Scenarios Full durability Default DURABILITY=SCHEMA_AND_DATA Pro: •Every committed change is guaranteed to survive failure Con: • Latency impact: every commit requires log IO Default: most scenarios need full durability Delayed durability • Transaction commit time COMMIT WITH (DELAYED_DURABILITY=ON) • Atomic block of native procedure BEGIN ATOMIC WITH (DELAYED_DURABILITY=ON, …) • Database level ALTER DATABASE CURRENT SET DELAYED_DURABILITY=FORCED Pro: • Low latency due to no log IO in transaction execution path • Efficient log IO due to batching Con: • Limited data loss on failure (usually ~60K or ~1ms worth) Low latency requirements Can accept some data loss OR Copy of recent data exists elsewhere in case of failure AlwaysOn auto-failover (sync replicas) with low latency Non- durable tables Table creation DURABILITY=SCHEMA_ONLY Pro: • No IO at all Con: • Lose data on failure • Transient data such as session state • Caching • ETL (staging tables)
  • 14.
  • 16.
  • 17.
  • 20.
  • 21.
  • 22.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
    Data Warehouse –SQL Server 2016
  • 36.
    Resources • Samples Perf demo WideWorldImporterssample DB IoT sample leveraging temporal tables release page Azure DB Sample Enable database for In-Memory OLTP SQL Server Samples GitHub Repository • Documentation Blog on In-Memory OLTP in SQL 2016 Memory-optimized table variables and temp tables MSDN Documentation for In-Memory OLTP Azure DB documentation for In-Memory What’s new in SQL2016 • Migrating apps In-Memory OLTP Common Workloads and Migration Considerations Migrating to In-Memory OLTP Guidelines for using Indexes • Related videos Microsoft Virtual Academy talks Recent investments in In-Memory OLTP
  • 38.