Orders of magnitude:
Scale-Out your SQL Server Data
Mark Broadbent
@retracement
A bit more about me!
•   More than 20 years in IT and more than 14 years using SQL Server.
    Worked at many large global corporations and SMEs such as Microsoft,
    Nokia, Hewlett Packard and Encyclopaedia Britannica.
•   Presented at SQLBits 7 and 8
•   MCITP Database Development SQL 2008
•   MCITP Database Administrator SQL 2008/ 2005 and MCDBA SQL 2000
•   Microsoft Certified Application Developer (C# .net)
•   Microsoft Certified Systems Engineer + Internet
•   Participate on #sqlhelp, MSDN Forums, Stackoverflow & Serverfault.
•   Used to be active in the MS newsgroups until their demise :(
•   Run the LinkedIn groups
•   Blog: tenbulls.co.uk
•   Linux Mint User Group http://www.linkedin.com/groups?gid=2989801
•   SQL Server Scripting http://www.linkedin.com/groups?gid=3033621

                                                Orders of magnitude: Scale-Out your
                                                                                      2
                                                                  SQL Server Data
Agenda

•   Why Scale-Out and what should we scale?
•   Benefits of Scale-Out?
•   Wait!!! Before you Scale-Out, Scale-In…
•   Lets look at some strategies and Scale-Out!
•   Hybrid Scale-Out
•   Taming the Beast



                                 Orders of magnitude: Scale-Out your
                                                                       3
                                                   SQL Server Data
Why Scale-Out
“Gartner Group study, for example, predicted that the
amount of data generated by enterprises will grow by a
staggering 650 percent over the next five years. Another
study sponsored by IBM found that 83 percent of the global
CIOs surveyed believe that analyzing and leveraging
enterprise data is critical to their companies’ long-term
competitiveness.” - Divining the Future of ERP Software
http://dell.to/jsoJik

Reference: http://bit.ly/k2kpwW (2009 Gartner IT
Infrastructure, Operations & Management Summit)

                                    Orders of magnitude: Scale-Out your
                                                                          4
                                                      SQL Server Data
Traditional Synchronous Activity
                      User                    “Database”
                    Request A             A

                    Request B
Wasted                                         B                                 Even
Processor                                                                        distribution
cycles              Request C                                                    of database




                                                                   Time
                                                   C                             load from
during waits
                    Request D                                                    application
                                                       D

                    Request E                               E

“A common error in client/server development is to prototype
an application in a small two tier environment, and then scale
up by simply adding more users to the server” – Lloyd Taylor
                                                       Orders of magnitude: Scale-Out your
                                                                                             5
                                                                         SQL Server Data
Asynchronous Activity?
                     User                  “Database”
                   Request A           A
                   Request B
User                                                                          Competing
experience         Request C                    C                             loads on
more                                        B                                 database




                                                                Time
                   Request D                                                  from
productive
application        Request E                        D                         application
                                                         E
thread more                                                                   faster all
active             Request x                                                  round
                                                                              execution
 “to increase the capacity or performance of a system, tuning
 can get up to 10% improvement. To get order or two magnitude
 of performance and capacity improvement a change in the
 architecture of the system is needed ” – W.H. Inmon

                                                    Orders of magnitude: Scale-Out your
                                                                                          6
                                                                      SQL Server Data
Separation of Function…
                      User                   “Database”
                                        A
                    Request A
                    Request B
Intensive                                                                     Separated
                    Request C               C                                 loads across
reporting
queries                                                B                      database




                                                                       Time
                    Request D                   E            D                based on
                    Request E                                                 function,
                                                                              even faster
                    Request x                                                 execution
                                            Units of Scale

“Building a system from ground up is an absolute requirement
for highly scalable systems” - P. Randal & K.L. Tripp


                                                    Orders of magnitude: Scale-Out your
                                                                                          7
                                                                      SQL Server Data
Separation of Requirements…
                        User                     “Database”
                                            A
                     Request A                               B
                     Request B
Queued,                                                                             Impact on
                     Request C                  C                 D                 database
Scheduled or
Governed                                                                            lessoned




                                                                             Time
                     Request D                      E
either by the                                                                       due to
application          Request E                                                      scheduled
server or                                                    B                      or governed
instance             Request x                                                      query
                                                Units of Scale

“in order to best implement a scaleout architecture, it
must be planned in advance.” – Bob Beauchemin


                                                          Orders of magnitude: Scale-Out your
                                                                                                8
                                                                            SQL Server Data
What is truly Mission Critical?
                                         Distribution of System Data
 Interactive
 (real-time)         OLTP
 Integrated
 (24hrs - 1 month)
                                                        Static Data
                                                        Aggregates
 Near line                      Probability            Denormalized
 (3 - 4 years)
                                 of access


 Archival
 (5 - 10 years)
                                                            DW /OLAP
         “Scale out workloads depending upon what is
         truly mission critical.” - Larry Chestnut

                                                  Orders of magnitude: Scale-Out your
                                                                                        9
                                                                    SQL Server Data
DEMO: Scaling for READS

Snapshots
Rolling Snapshots
Rolling Snapshots on Database Mirror
Database Mirror Failover?
How to make use of the Rolling Snapshots




                              Orders of magnitude: Scale-Out your
                                                                    10
                                                SQL Server Data
What can Scale-Out give us? # 1

• Availability
   – Portions of data can go offline but doesn't effect the whole
• Disaster
   – Recovery time (reduce time to restore - reduced when less to
     recover)
   – Large Disk Partitions can take long time to fix
   – Limit the impact of total disaster (i.e. when your DR strategy
     does not work)
• Cost
   – Reuse commodity hardware for less important data
   – Higher we Scale-Up, more expensive it becomes. Scale-Out can
     be cheaper

                                             Orders of magnitude: Scale-Out your
                                                                                   11
                                                               SQL Server Data
What can Scale-Out give us? #2

• Performance
  – Load balance
  – Mix and match (LOW consumers and BIG consumers)
  – Separation of workload types (OLAP and OLTP)
  – Parallelise a System (separate system requests across multiple
    hardware)
  – Overcome contentious parts of the DB server such as TempDB

• Capacity
  – Backup time (reduce time to backup)
  – Limited resources


                                          Orders of magnitude: Scale-Out your
                                                                                12
                                                            SQL Server Data
Before you Scale-Out…Scale-In #1
• Keep statistics accurate and up to date
   – Avoid big temp vars, they have no indexes or stats
   – Stats can get skewed, ensure they are maintained
• Query Tuning
   –   Avoid table scans
   –   Use indexes correctly, and remove duplicates
   –   Is parallelism right for your query (OLAP vs OLTP)
   –   Reduce size of the result set
   –   Always use a WHERE clause
   –   DON’T use SELECT * replace with precise column list
   –   Sensible clustered key, avoid large covered index and prefer
       include option

                                             Orders of magnitude: Scale-Out your
                                                                                   13
                                                               SQL Server Data
Before you Scale-Out…Scale-In #2

• Reduce PageIO
   –   Filtered indexes
   –   Sparse columns
   –   Use correct data types
   –   Use table/ row and page compression
   –   Remove your LOBs from tables
        • Use other technologies such as FILESTREAM
        • Vertically partition
• Reduce contention on shared resources
   – Denormalize
   – Filegroups

                                         Orders of magnitude: Scale-Out your
                                                                               14
                                                           SQL Server Data
Scalable Shared Database

   Report                    Report
   Server                    Server
                            Database
               SQL Server
               Instance A


                             Report
                             Server
                            Database
               SQL Server
 Application   Instance B
   Server      Instance C




                             Orders of magnitude: Scale-Out your
                                                                   15
                                               SQL Server Data
DEMO: Reporting Services Scale-Out

Reporting from Snapshots
Reporting Services Scale-Out deployment
Scalable Shared Database




                             Orders of magnitude: Scale-Out your
                                                                   16
                                               SQL Server Data
Partitioned tables, views and filegroups
   Table     Partitioned    Partitioned
                View          Tables

  payments                  payments2011                       Filegroup1
             payments2011

                                                               Filegroup2

                                                                 Filegroup3


             payments2010   payments2010


                                                              Filegroup4


             payments2009
                            payments2009
                                                              Filegroup5




                                          Orders of magnitude: Scale-Out your
                                                                                17
                                                            SQL Server Data
With Distributed Partitioned views
   Table       Distributed      Partitioned
             Partitioned View     Tables

  payments                      payments2011                      FilegroupA1
              payments2011
                                                                   FilegroupA2

             SQL Server
                                                                    FilegroupA3
             Instance A

              payments2010      payments2010


             SQL Server                                           FilegroupB1
             Instance B
               payments2009
                                payments2009
                                                                  FilegroupB2




                                              Orders of magnitude: Scale-Out your
                                                                                    18
                                                                SQL Server Data
Peer to Peer Replication
        Read-Write for User
                                                                  Read-Write for ETL
           Applications


                                               SQL Server
                                                                                            SSIS
                                               Instance B
                                                                                         Application
                                               Database X
                                                                                           Server
   SQL Server
   Instance A
   Database X
                                   Read-Only for Reporting



                      SQL Server                                 Report
                      Instance C                                 Server
                      Database X




                                                             Orders of magnitude: Scale-Out your
                                                                                                   19
                                                                               SQL Server Data
Hybrid Scale-Out

• Database Mirroring with rolling snapshots
• SQL Failover Cluster using over-provisioned
  failover node “hot-swap Scale-Out/Up”.
• Use Hyper-Visor, migrate to over-provisioned
  host server.
• Clusters, Peer to Peer, Mirroring on Hyper-Visor




                                Orders of magnitude: Scale-Out your
                                                                      20
                                                  SQL Server Data
Bringing it all together
                                        Report
    Virtual Cluster Nodes               Server                     Virtual Cluster Nodes


          Cluster A                    Snapshot                           Cluster B


    SQL Failover Clusters                Instance E                 SQL Failover Clusters
                                         Database Y
                                           Mirror


 Instance A       Instance B                                    Instance C        Instance D
 Database X       Database Y                                    Database Y        Database X

                                    Partition Views
        Hyper-Visor A                                                   Hyper-Visor B


                               Peer to Peer Replication



                                                          Orders of magnitude: Scale-Out your
                                                                                                21
                                                                            SQL Server Data
The SQL Server Scale-Out Toolkit
•   Service Broker                   •   Full Text Indexing
•   Integration Services             •   Vertical Partitioning
•   Replication                      •   Powershell
•   Horizontally Partitioned Views   •   CLR
•   Federated Databases              •   Linked Servers
•   Partitioned Views                •   Filegroups
•   Log Shipping                     •   Files
•   Scalable Shared Database         •   Clustering
•   Scalable Shared Database for     •   Backup and Restore
    Analysis Services                •   Mirroring
•   Reporting Services Scale-out     •   Database Snapshots
    Deployment                       •   Processor Affinity
•   Synonyms                         •   Triggers
•   Schemas                          •   Analysis Services Load
•   Query Notifications                  Balancing

                                             Orders of magnitude: Scale-Out your
                                                                                   22
                                                               SQL Server Data
Taming the Beast
• Governance
   – Policy Based Management
   – Resource Governor or WRSM
   – Source Control
• Monitoring
   –   MDW and Data Collection
   –   Performance condition alerts
   –   Extended Events
   –   Profiler
   –   DMVs
• Naming
   – SQL Client Aliases w/ GP
   – DNS

                                      Orders of magnitude: Scale-Out your
                                                                            23
                                                        SQL Server Data
In Summary

• We discussed
  –   Why we should start thinking about Scaling-Out?
  –   Benefits from Scale-Out
  –   Scaling in before you Scale-Out
  –   Scale-Out strategies
  –   Hybrid Scale-Out strategies
  –   Keeping your scaled environment under control




                                     Orders of magnitude: Scale-Out your
                                                                           24
                                                       SQL Server Data
Further References
•   Books
     – Apress - Pro SQL Server 2008 Service broker – Klaus Aschenbrenner
     – Apress - Pro SQL Server 2008 Replication - Sujoy Paul
     – Morgan Kaufman - DW 2.0 - The Architecture for the Next Generation of Data
       Warewhousing – William Inmon, Derek Strauss and Genia Neushloss
     – MS Press - Improving .NET Application Performance and Scalability

•   Blogs/ Websites
     –   Partitioned Table & Index Strategies Using SQL Server 2008 http://bit.ly/g28zQa
     –   VoltDB.NET: Synchronous vs. Asynchronous Request Processing http://bit.ly/k3rY2N
     –   Data Warehousing 2.0 and SQL Server: Architecture and Vision http://bit.ly/4tRXB4
     –   Performance Considerations of Data Types – Michelle Ufford http://bit.ly/aq9Wyr

•   Video/ Webcasts
     – PASS Summit 2010: AD270S Database Design Fundamentals - Louis Davidson
     – MCM #17 SQL Server Partitioning – SQLSkills http://bit.ly/ea3C6e




                                                          Orders of magnitude: Scale-Out your
                                                                                                25
                                                                            SQL Server Data
Please Complete the Evaluation Form

Pick up your evaluation form:
• In each presentation room
Drop off your completed form
• Near the exit of each presentation room
• At the registration area


                                                               Presented by Dell




                                            Orders of magnitude: Scale-Out your
                                                                                   26
                                                              SQL Server Data
THANK YOU!                       Presented by Dell


For attending this session and
PASS SQLRally Orlando, Florida


                                                          28
                                 Session Code | Session Title

Orders of-magnitude-scale-out-your-sql-server-data-slideshare

  • 1.
    Orders of magnitude: Scale-Outyour SQL Server Data Mark Broadbent @retracement
  • 2.
    A bit moreabout me! • More than 20 years in IT and more than 14 years using SQL Server. Worked at many large global corporations and SMEs such as Microsoft, Nokia, Hewlett Packard and Encyclopaedia Britannica. • Presented at SQLBits 7 and 8 • MCITP Database Development SQL 2008 • MCITP Database Administrator SQL 2008/ 2005 and MCDBA SQL 2000 • Microsoft Certified Application Developer (C# .net) • Microsoft Certified Systems Engineer + Internet • Participate on #sqlhelp, MSDN Forums, Stackoverflow & Serverfault. • Used to be active in the MS newsgroups until their demise :( • Run the LinkedIn groups • Blog: tenbulls.co.uk • Linux Mint User Group http://www.linkedin.com/groups?gid=2989801 • SQL Server Scripting http://www.linkedin.com/groups?gid=3033621 Orders of magnitude: Scale-Out your 2 SQL Server Data
  • 3.
    Agenda • Why Scale-Out and what should we scale? • Benefits of Scale-Out? • Wait!!! Before you Scale-Out, Scale-In… • Lets look at some strategies and Scale-Out! • Hybrid Scale-Out • Taming the Beast Orders of magnitude: Scale-Out your 3 SQL Server Data
  • 4.
    Why Scale-Out “Gartner Groupstudy, for example, predicted that the amount of data generated by enterprises will grow by a staggering 650 percent over the next five years. Another study sponsored by IBM found that 83 percent of the global CIOs surveyed believe that analyzing and leveraging enterprise data is critical to their companies’ long-term competitiveness.” - Divining the Future of ERP Software http://dell.to/jsoJik Reference: http://bit.ly/k2kpwW (2009 Gartner IT Infrastructure, Operations & Management Summit) Orders of magnitude: Scale-Out your 4 SQL Server Data
  • 5.
    Traditional Synchronous Activity User “Database” Request A A Request B Wasted B Even Processor distribution cycles Request C of database Time C load from during waits Request D application D Request E E “A common error in client/server development is to prototype an application in a small two tier environment, and then scale up by simply adding more users to the server” – Lloyd Taylor Orders of magnitude: Scale-Out your 5 SQL Server Data
  • 6.
    Asynchronous Activity? User “Database” Request A A Request B User Competing experience Request C C loads on more B database Time Request D from productive application Request E D application E thread more faster all active Request x round execution “to increase the capacity or performance of a system, tuning can get up to 10% improvement. To get order or two magnitude of performance and capacity improvement a change in the architecture of the system is needed ” – W.H. Inmon Orders of magnitude: Scale-Out your 6 SQL Server Data
  • 7.
    Separation of Function… User “Database” A Request A Request B Intensive Separated Request C C loads across reporting queries B database Time Request D E D based on Request E function, even faster Request x execution Units of Scale “Building a system from ground up is an absolute requirement for highly scalable systems” - P. Randal & K.L. Tripp Orders of magnitude: Scale-Out your 7 SQL Server Data
  • 8.
    Separation of Requirements… User “Database” A Request A B Request B Queued, Impact on Request C C D database Scheduled or Governed lessoned Time Request D E either by the due to application Request E scheduled server or B or governed instance Request x query Units of Scale “in order to best implement a scaleout architecture, it must be planned in advance.” – Bob Beauchemin Orders of magnitude: Scale-Out your 8 SQL Server Data
  • 9.
    What is trulyMission Critical? Distribution of System Data Interactive (real-time) OLTP Integrated (24hrs - 1 month) Static Data Aggregates Near line Probability Denormalized (3 - 4 years) of access Archival (5 - 10 years) DW /OLAP “Scale out workloads depending upon what is truly mission critical.” - Larry Chestnut Orders of magnitude: Scale-Out your 9 SQL Server Data
  • 10.
    DEMO: Scaling forREADS Snapshots Rolling Snapshots Rolling Snapshots on Database Mirror Database Mirror Failover? How to make use of the Rolling Snapshots Orders of magnitude: Scale-Out your 10 SQL Server Data
  • 11.
    What can Scale-Outgive us? # 1 • Availability – Portions of data can go offline but doesn't effect the whole • Disaster – Recovery time (reduce time to restore - reduced when less to recover) – Large Disk Partitions can take long time to fix – Limit the impact of total disaster (i.e. when your DR strategy does not work) • Cost – Reuse commodity hardware for less important data – Higher we Scale-Up, more expensive it becomes. Scale-Out can be cheaper Orders of magnitude: Scale-Out your 11 SQL Server Data
  • 12.
    What can Scale-Outgive us? #2 • Performance – Load balance – Mix and match (LOW consumers and BIG consumers) – Separation of workload types (OLAP and OLTP) – Parallelise a System (separate system requests across multiple hardware) – Overcome contentious parts of the DB server such as TempDB • Capacity – Backup time (reduce time to backup) – Limited resources Orders of magnitude: Scale-Out your 12 SQL Server Data
  • 13.
    Before you Scale-Out…Scale-In#1 • Keep statistics accurate and up to date – Avoid big temp vars, they have no indexes or stats – Stats can get skewed, ensure they are maintained • Query Tuning – Avoid table scans – Use indexes correctly, and remove duplicates – Is parallelism right for your query (OLAP vs OLTP) – Reduce size of the result set – Always use a WHERE clause – DON’T use SELECT * replace with precise column list – Sensible clustered key, avoid large covered index and prefer include option Orders of magnitude: Scale-Out your 13 SQL Server Data
  • 14.
    Before you Scale-Out…Scale-In#2 • Reduce PageIO – Filtered indexes – Sparse columns – Use correct data types – Use table/ row and page compression – Remove your LOBs from tables • Use other technologies such as FILESTREAM • Vertically partition • Reduce contention on shared resources – Denormalize – Filegroups Orders of magnitude: Scale-Out your 14 SQL Server Data
  • 15.
    Scalable Shared Database Report Report Server Server Database SQL Server Instance A Report Server Database SQL Server Application Instance B Server Instance C Orders of magnitude: Scale-Out your 15 SQL Server Data
  • 16.
    DEMO: Reporting ServicesScale-Out Reporting from Snapshots Reporting Services Scale-Out deployment Scalable Shared Database Orders of magnitude: Scale-Out your 16 SQL Server Data
  • 17.
    Partitioned tables, viewsand filegroups Table Partitioned Partitioned View Tables payments payments2011 Filegroup1 payments2011 Filegroup2 Filegroup3 payments2010 payments2010 Filegroup4 payments2009 payments2009 Filegroup5 Orders of magnitude: Scale-Out your 17 SQL Server Data
  • 18.
    With Distributed Partitionedviews Table Distributed Partitioned Partitioned View Tables payments payments2011 FilegroupA1 payments2011 FilegroupA2 SQL Server FilegroupA3 Instance A payments2010 payments2010 SQL Server FilegroupB1 Instance B payments2009 payments2009 FilegroupB2 Orders of magnitude: Scale-Out your 18 SQL Server Data
  • 19.
    Peer to PeerReplication Read-Write for User Read-Write for ETL Applications SQL Server SSIS Instance B Application Database X Server SQL Server Instance A Database X Read-Only for Reporting SQL Server Report Instance C Server Database X Orders of magnitude: Scale-Out your 19 SQL Server Data
  • 20.
    Hybrid Scale-Out • DatabaseMirroring with rolling snapshots • SQL Failover Cluster using over-provisioned failover node “hot-swap Scale-Out/Up”. • Use Hyper-Visor, migrate to over-provisioned host server. • Clusters, Peer to Peer, Mirroring on Hyper-Visor Orders of magnitude: Scale-Out your 20 SQL Server Data
  • 21.
    Bringing it alltogether Report Virtual Cluster Nodes Server Virtual Cluster Nodes Cluster A Snapshot Cluster B SQL Failover Clusters Instance E SQL Failover Clusters Database Y Mirror Instance A Instance B Instance C Instance D Database X Database Y Database Y Database X Partition Views Hyper-Visor A Hyper-Visor B Peer to Peer Replication Orders of magnitude: Scale-Out your 21 SQL Server Data
  • 22.
    The SQL ServerScale-Out Toolkit • Service Broker • Full Text Indexing • Integration Services • Vertical Partitioning • Replication • Powershell • Horizontally Partitioned Views • CLR • Federated Databases • Linked Servers • Partitioned Views • Filegroups • Log Shipping • Files • Scalable Shared Database • Clustering • Scalable Shared Database for • Backup and Restore Analysis Services • Mirroring • Reporting Services Scale-out • Database Snapshots Deployment • Processor Affinity • Synonyms • Triggers • Schemas • Analysis Services Load • Query Notifications Balancing Orders of magnitude: Scale-Out your 22 SQL Server Data
  • 23.
    Taming the Beast •Governance – Policy Based Management – Resource Governor or WRSM – Source Control • Monitoring – MDW and Data Collection – Performance condition alerts – Extended Events – Profiler – DMVs • Naming – SQL Client Aliases w/ GP – DNS Orders of magnitude: Scale-Out your 23 SQL Server Data
  • 24.
    In Summary • Wediscussed – Why we should start thinking about Scaling-Out? – Benefits from Scale-Out – Scaling in before you Scale-Out – Scale-Out strategies – Hybrid Scale-Out strategies – Keeping your scaled environment under control Orders of magnitude: Scale-Out your 24 SQL Server Data
  • 25.
    Further References • Books – Apress - Pro SQL Server 2008 Service broker – Klaus Aschenbrenner – Apress - Pro SQL Server 2008 Replication - Sujoy Paul – Morgan Kaufman - DW 2.0 - The Architecture for the Next Generation of Data Warewhousing – William Inmon, Derek Strauss and Genia Neushloss – MS Press - Improving .NET Application Performance and Scalability • Blogs/ Websites – Partitioned Table & Index Strategies Using SQL Server 2008 http://bit.ly/g28zQa – VoltDB.NET: Synchronous vs. Asynchronous Request Processing http://bit.ly/k3rY2N – Data Warehousing 2.0 and SQL Server: Architecture and Vision http://bit.ly/4tRXB4 – Performance Considerations of Data Types – Michelle Ufford http://bit.ly/aq9Wyr • Video/ Webcasts – PASS Summit 2010: AD270S Database Design Fundamentals - Louis Davidson – MCM #17 SQL Server Partitioning – SQLSkills http://bit.ly/ea3C6e Orders of magnitude: Scale-Out your 25 SQL Server Data
  • 26.
    Please Complete theEvaluation Form Pick up your evaluation form: • In each presentation room Drop off your completed form • Near the exit of each presentation room • At the registration area Presented by Dell Orders of magnitude: Scale-Out your 26 SQL Server Data
  • 27.
    THANK YOU! Presented by Dell For attending this session and PASS SQLRally Orlando, Florida 28 Session Code | Session Title