networking internals for the sql server professional ...€¦ · networking internals for the sql...

30
Networking Internals for the SQL Server Professional Anthony E. Nocentino [email protected]

Upload: others

Post on 27-Jul-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Networking Internals for the SQL Server Professional

Anthony E. Nocentino [email protected]

Page 2: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Anthony E. Nocentino

• Consultant and Trainer

• Founder and President of Centino Systems

• Specialize in system architecture and performance

• Masters Computer Science (almost a PhD)

• Microsoft MVP - Data Platform - 2017

• Friend of Redgate - 2015-2017

• email: [email protected]

• Twitter: @nocentino

• Blog: www.centinosystems.com/blog

• Pluralsight Author: www.pluralsight.com

Page 3: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Overview

• Network Topologies and the OSI model

• Ethernet

• Internet Protocol

• Transmission Control Protocol

• DEMOS!

• SQL Server performance problems

• SQL Server availability problems

Page 4: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Key Concepts

• Throughput

• Latency

• Reliability

Page 5: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Network Topologies

LAN WAN

SwitchSwitch

Host Host

Switch

Router

Host

Router

Host

Page 6: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

OSI Model

Application Actual application Application Data Browser

PresentationTranslation of data for the application

layerApplication Data HTML, CSS

Session Application level socket

Application Data HTTP, SSH

TransportData

segmentation and delivery

Segment TCP, UDP

Network Addressing and routing

Packet IP, routers, computers

Data linkEncoding between end stations, and

access controlFrame

Ethernet encoding, switches

Physical The actual wire bits (0101010) Ethernet NICs, hubs, modems

Layer Description Transfer Unit Example

Page 7: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

How Data Moves Through a Network…Encapsulation

BrowserApplication

Web PagePresentation

HTTP GETSession Socket

101010101101010101101010101101010101Physical NIC

PortTCPTransport 0xab32ade

Router or PCTCPIPNetwork 0xab32ade

EthernetTCPIPFrame FrameData Link 0xab32ade

Code

Process Server Application

Web Page Presentation

HTTP GET Session

101010101101010101101010101101010101 Physical

TCP0xab32ade Transport

TCP IP0xab32ade Network

Frame TCP IP Frame0xab32ade Data Link

Encapsulation!

Page 8: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Layer 2 - Data Link

• Ethernet

• Responsible for encoding and transmitting frames on the LAN

• MAC Address - uniquely identifies an end station

• MTU - Total length of frame payload. Not fragment-able

• Very high bandwidth, very low latency

• Devices at this layer - switches, network interfaces

Page 9: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Ethernet Frame

6 bytes

Destination MAC

Source MAC Type

6 bytes 2 bytes

Payload

46-1500 bytes

CRC

4 bytes

Page 10: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Layer 2 - Data Link

• Things to look out for

• No link

• Speed or duplex mismatch

• CPU Saturation on switches

Page 11: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Layer 3 - Network

• Internet Protocol (IP)

• Responsible for addressing and routing between networks

• Packet - Addressing information and layer 4 data

• Devices at this layer - routers, firewalls…and your machines

Page 12: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Internet Protocol

• Connects networks

• Connectionless

• Source, destination are defined but the network determines the path

• Routers forward packets

• Routers and hosts define routing tables that define what to do with the packet

• Routers connect networks, generally with higher latency, lower bandwidth connections

• arp - binds layer 2 MAC to layer 3 IP

Page 13: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

IP Routing Decision Process

• Check the destination address in the IP header

• Compare that with the network mask to determine if the destination is on a remote network

• If it’s local deliver it on the directly connected interface

• If it’s not local, look up a specific route in the local routing table

• If it’s not local and not in the routing tables, send it to the default route

Page 14: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

IP Packet Header

8 bits32 bits

8 bits 8 bits8 bits8 bits

Total Length

Identifier Flags Fragment Offset

Time to Live

Source Address

Destination Address

Version HeaderLength

Protocol

Type of Service or DiffServ

Header Checksum

Options Padding

Page 15: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Internet Protocol

• Things to look out for

• Routing issues

• Time to live - TTL

• Bad network masks

• Dropped packets

• Misplaced resources

• Routers are choke points

• Bandwidth or CPU constrained

• Name Resolution Latency

Page 16: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Layer 4 - Transmission Control Protocol• Responsible for segmentation, ordering of data and reliable delivery

• Segment

• Application data is broken into segments, IP use used to transport the segment to the destination host

• Sockets and Ports

• Uniquely defines a connection

• source IP + source port + destination IP + destination port

• Devices at this layer

• Operating systems, application aware firewalls, load balancers and WAN optimizers

Page 17: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

TCP’s Killer Performance Optimization

• Positive acknowledgement of each segment

• ACK’ing every segment is slow, because latency!

• Bandwidth and latency are tightly correlated

• Congestion control

• Congestion Window - if the number of unacknowledged segments is too high, the sender will reduce the window

• Flow control

• Sliding Window - more than one segment in transport at a point in time. Managed by the receiver

Page 18: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

TCP Connection Establishment -Three Way Handshake

SYN - n

SYN - m/ACK - n+1

ACK - m+1

SYN_RECEIVED

ESTABLISHED

Establishes Initial Sequence Numbers Critical to ordered, reliable delivery in both

directions

SYN_SENT

Page 19: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

TCP

• Things to look out for

• Latency - at any layer

• Dropped Packets

• OS Queuing

• Firewalls

• Row by agonizing row (RBAR)

Page 20: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Data Encapsulation

DataIP Header

DataTCP Header

DataFrame Header Frame Trailer

Page 21: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Demos

• Wireshark

• Layer 2

• arp

• Layer 3

• tracert

• Time to live (TTL)

• Layer 4

• netstat

• Established connections

• Connections blocked by firewalls

• Measuring bandwidth

• iperf

• Impact of network latency

• Impact of reliability issues

Page 22: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

The Big Reveal!

• Why did I tell you about all these fundamental concepts?

• Throughput, latency and reliability are everything

• They determine how much data you move and how fast

• With the demos, you should be able to isolate a network bottleneck or anomaly

• If you’re suffering from a network performance or reliability issue…

• It WILL impact your SQL Server’s performance

• It WILL impact your SQL Server’s availability

Page 23: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Performance Problems

• Application Performance (pretty much anything that accesses your SQL Server over the network)

• ASYNC_NETWORK_IO

• Network based disk IO

• iSCSI/NFS

• Disk Latency Issues or even IO errors

• Slow Systems

• Locking/Blocking

• Intermittent database errors

Page 24: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Availability Problems

• Availability Group Latency

• HADR_SYNC_COMMIT

• HADR_SYNCHRONIZING_THROTTLE

• HADR_TRANSPORT_FLOW_CONTROL

• Mirroring, Log Shipping

• Backups

• BACKUPIO

• Restores!

Page 25: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

What do you need to do?

• Capacity planning - have you planned for the throughput and latency requirements of your application.

• Baselining and Benchmarking

• Ensure IO intense or latency sensitive resources are close to each other on properly sized interconnects

• Test!

Page 26: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Key Takeaways

• Knowing networking fundamentals are key to isolating performance or reliability issues

• Use the OSI layers as your troubleshooting methodology

• With the demos, you should be able to isolate a network bottleneck or anomaly

• SQL Server will suffer is network performance and reliability are questionable

• Benchmark and baseline your systems, so you know what’s normal and what’s not normal

Page 27: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Additional Resources

• Pluralsight

• LFCE - Advanced Linux Networking

• Internet Protocol, Routing, TCP Internals and Troubleshooting!

• Blog

• Understanding Network Latency and Impact on Availability Group Replication

• http://bit.ly/2l83AKu

Page 28: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Need more data or help?http://www.centinosystems.com/blog/talks/

Links to resources Demos

Presentation

[email protected]@nocentino

www.centinosystems.com

Solving tough business challenges with technical innovation

Page 29: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Questions?

Page 30: Networking Internals for the SQL Server Professional ...€¦ · Networking Internals for the SQL Server Professional Anthony E. Nocentino aen@centinosystems.com. ... • Knowing

Thank You!