SlideShare a Scribd company logo
SQL Server Service Broker
Scale out by Reliable Messaging
• Scalability – what does Scale Out means?
• Sharding
• Problems of sharding
• How does Service Broker help?
Agenda
• Is the ability of a system to handle growing
amount of work in a capable manner
• or its ability to be enlarged to accommodate
that growth
http://en.wikipedia.org/wiki/Scalability
Scalability
• Scale up – scale vertically
• Scale out – scale horizontally
Scalability Methods
• means vertically
• add resources to a single node in a system
– CPU
– memory
– storage
– etc
Scaling Up
• means horizontally
• add more nodes to a system
• in databases that’s called Sharding
• Microsoft used another term in SQL Azure -
Federations
Scaling Out
• Twitter Gizzard -
https://github.com/twitter/gizzard
• written in Scala
Sharding Frameworks
Sharding involves two technologies:
• Partitioning
• Replication
Sharding
• Data is divided into chunks
• Stored across computers
• Each chunk is small enough that we can
manipulate and query efficiently
User = “Denis” User = “Eva”
Partitioning
• multiple copies of data are stored across
several machines
• efficiently responds to tons of queries
• resilient to failures
User = “Denis”
User = “Eva”
User = “Denis”
User = “Eva”
Replication
Besides Scaling Out:
• Disaster Recovery strategies have You to make
database backups
• Replicated shards are working copies
• Need a new backup? Replicate a new Shard!
Benefits of Sharding
• Yes! Sharding is difficult!
• We have to think of how to partition our data
correctly
• How to ensure that all copies of data are
consistent?
• Write conflicts – no guarantee that operations
will apply in order
Are there any Problems?
• “Shared Nothing Architecture”
• no ongoing need to retain shared access
between shards
• each Shard can live in a totally separate
– instance
– database server
– data center
– continent
Design Principle
• Orders table is partitioned by Region
• Orders references to Users
• Users is not partitioned, it is replicated
• How to maintain Users in a consistent state?
Users (not partitioned)
Orders [Region = “US”]
Users (not partitioned)
Orders [Region = “Russia”]
Partitioning Problem
Wall Statuses
User [Name = “Denis”]
Wall Statuses
User [Name = “Eva”]
Front-End
POST
Denis writes a new Status
GET
We should see that status
on Eva’s wall
How do we get Denis’ statuses?
Facebook Sample
Wall Statuses
User [Name = “Denis”]
Wall Statuses
User [Name = “Eva”]
Front-End
POST
Denis writes a new Status
POST
Duplicate the status?
No benefit from Shards then! Wrong!
Possible Solution 1
Wall Statuses
User [Name = “Denis”]
Wall Statuses
User [Name = “Eva”]
Front-End
POST
Denis writes a new Status
GET
Gets a user data
No benefit from Shards then! Wrong!
Possible Solution 2
Wall Statuses
User [Name = “Denis”]
Wall Statuses
User [Name = “Eva”]
Front-End
POST
Denis writes a new Status
POST
Propogate the status
GET
All OK
Real Solution
• custom application which reads from one
Shard and writes to the others
• add all Shards as Linked servers, write stored
procedures to write a new record to each
remote server
• SQL Server Service Broker
Possible Technologies
• allows Internal and External processes to send
and receive guaranteed asynchronous
messages
• messages are sent to Queues in the same
database, same instance, same server,
another database, another instance, remote
server
Service Broker
the largest known implementation is in MySpace
• 440 SQL Server instances
• over 1,000 databases
• 1 Petabyte of data (1 million gigabytes)
Performance:
• 5,000 messages/second in Labs
• 18,000 messages/second in MySpace
Implementations
• Always Transactional
• Asynchronous
• Queued
• All messages are in XML format
• Routing
• Multicast messages in SQL Server 2012
Advantages
• No Administration Tools – not a lack - no at all
• Queue is a Table in database – index
fragmentation when we cannot empty queue
• complicated T-SQL syntax and object model
Disadvantages
• Message Types
• Contracts
• Queues
• Services
• Routes
• Activation
• Remote Service Bindings
• Dialog Conversation
• Conversation Groups
Service Broker Concepts
• Dialog Security – between two Services
– encrypts messages in a dialog conversation
– provides the remote authorization
• Transport Security
– establishes an authenticated network connection
between two Databases
Service Broker Security
• Enable Service Broker at Database level
ALTER DATABASE SampleDatabase
SET ENABLE_BROKER;
GO
• Always enable Service Broker in MSDB system database in each SQL Server
instance
• Enable SQL Server to communicate to another instance at Database level
ALTER DATABASE SampleDatabase
SET TRUSTWORTHY ON;
GO
SQL Server Configuration
• Create Send Message type
CREATE MESSAGE TYPE NewUserRequest
VALIDATION = WELL_FORMED_XML;
• Create Receive Message Type
CREATE MESSAGE TYPE NewUserResponse
VALIDATION = WELL_FORMED_XML;
Message Types
• create Contract between two services
CREATE CONTRACT NewUserContract (
NewUserRequest SENT BY INITIATOR,
NewUserResponse SENT BY TARGET
);
Service Contracts
CREATE QUEUE NewUserReceiveQueue
WITH STATUS = ON,
ACTIVATION (
PROCEDURE_NAME = OnReceiveNewUser,
MAX_QUEUE_READERS = 5,
Execute AS 'dbuser‘
) ;
CREATE QUEUE NewUserSendQueue
WITH STATUS = ON;
Queues
• Service will be listening for messages in a queue and react
only on those which apply to the spicified contract
CREATE SERVICE NewUserSendService
ON QUEUE NewUserSendQueue (
[NewUserContract]
);
CREATE SERVICE NewUserReceiveService
ON QUEUE NewUserReceiveQueue (
[NewUserContract]
);
Services
Sender:
• begins a transaction
• begins a dialog conversation from
NewUserSendService to NewUserReceiveService
• sends one or more XML messages to that dialog
• commits a transaction
• Waits for a Reply message
• Processes Reply messages when arrived
Sending a Messgae
Receiver (Target):
• when a new message is delivered to Receiver's
NewUserReceiveQueue the OnReceiveNewUser stored
procedure is activated by Service Broker
• Stored procedure begins a transaction
• receives messages out of the NewUserReceiveQueue
queue
• sends Reply messages
• ends a dialog conversation
• Do what you want with that message
• commits a transaction
Receiving a Message

More Related Content

What's hot

High availability solutions bakostech
High availability solutions bakostechHigh availability solutions bakostech
High availability solutions bakostech
Viktoria Bakos
 
Distributed database
Distributed databaseDistributed database
Distributed database
sanjay joshi
 
Understanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQLUnderstanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQL
Hyderabad Scalability Meetup
 
Types of server
Types of serverTypes of server
Types of server
Muhammad Mudarrak
 
What is a database server and client ?
What is a database server and client ?What is a database server and client ?
What is a database server and client ?
Open E-School
 
24 Hours Of Exchange Server 2007 (Part 1 Of 24)
24 Hours Of Exchange Server 2007 (Part 1 Of 24)24 Hours Of Exchange Server 2007 (Part 1 Of 24)
24 Hours Of Exchange Server 2007 (Part 1 Of 24)
Harold Wong
 
24 Hours Of Exchange Server 2007 (Part 8 Of 24)
24 Hours Of Exchange Server 2007 (Part 8 Of 24)24 Hours Of Exchange Server 2007 (Part 8 Of 24)
24 Hours Of Exchange Server 2007 (Part 8 Of 24)
Harold Wong
 
24 Hours Of Exchange Server 2007 (Part 3 Of 24)
24 Hours Of Exchange Server 2007 (Part 3 Of 24)24 Hours Of Exchange Server 2007 (Part 3 Of 24)
24 Hours Of Exchange Server 2007 (Part 3 Of 24)
Harold Wong
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
Amit Nirala
 
Mule database connector
Mule database connectorMule database connector
Mule database connector
D.Rajesh Kumar
 
Client Server Architecture ppt
Client Server Architecture pptClient Server Architecture ppt
Client Server Architecture ppt
OECLIB Odisha Electronics Control Library
 
SOA with NServiceBus 20130124
SOA with NServiceBus 20130124SOA with NServiceBus 20130124
SOA with NServiceBus 20130124
Sean Farmar
 
Windows Azure Service Bus
Windows Azure Service BusWindows Azure Service Bus
Windows Azure Service Bus
Pavel Revenkov
 
Web Server And Database Server
Web Server And Database ServerWeb Server And Database Server
Web Server And Database Server
Mahbubur Rahman
 
Apache ActiveMQ
Apache ActiveMQApache ActiveMQ
Apache ActiveMQ
Engin Yoeyen
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overview
Raveendra Bhat
 
Securing Your MongoDB Deployment
Securing Your MongoDB DeploymentSecuring Your MongoDB Deployment
Securing Your MongoDB Deployment
MongoDB
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
Whitireia New Zealand
 
About HTTP and REST
About HTTP and RESTAbout HTTP and REST
About HTTP and REST
Maggie Georgieva
 
Mdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgrMdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgr
Daniel M. Farrell
 

What's hot (20)

High availability solutions bakostech
High availability solutions bakostechHigh availability solutions bakostech
High availability solutions bakostech
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Understanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQLUnderstanding and building big data Architectures - NoSQL
Understanding and building big data Architectures - NoSQL
 
Types of server
Types of serverTypes of server
Types of server
 
What is a database server and client ?
What is a database server and client ?What is a database server and client ?
What is a database server and client ?
 
24 Hours Of Exchange Server 2007 (Part 1 Of 24)
24 Hours Of Exchange Server 2007 (Part 1 Of 24)24 Hours Of Exchange Server 2007 (Part 1 Of 24)
24 Hours Of Exchange Server 2007 (Part 1 Of 24)
 
24 Hours Of Exchange Server 2007 (Part 8 Of 24)
24 Hours Of Exchange Server 2007 (Part 8 Of 24)24 Hours Of Exchange Server 2007 (Part 8 Of 24)
24 Hours Of Exchange Server 2007 (Part 8 Of 24)
 
24 Hours Of Exchange Server 2007 (Part 3 Of 24)
24 Hours Of Exchange Server 2007 (Part 3 Of 24)24 Hours Of Exchange Server 2007 (Part 3 Of 24)
24 Hours Of Exchange Server 2007 (Part 3 Of 24)
 
What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)What is Server? (Web Server vs Application Server)
What is Server? (Web Server vs Application Server)
 
Mule database connector
Mule database connectorMule database connector
Mule database connector
 
Client Server Architecture ppt
Client Server Architecture pptClient Server Architecture ppt
Client Server Architecture ppt
 
SOA with NServiceBus 20130124
SOA with NServiceBus 20130124SOA with NServiceBus 20130124
SOA with NServiceBus 20130124
 
Windows Azure Service Bus
Windows Azure Service BusWindows Azure Service Bus
Windows Azure Service Bus
 
Web Server And Database Server
Web Server And Database ServerWeb Server And Database Server
Web Server And Database Server
 
Apache ActiveMQ
Apache ActiveMQApache ActiveMQ
Apache ActiveMQ
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overview
 
Securing Your MongoDB Deployment
Securing Your MongoDB DeploymentSecuring Your MongoDB Deployment
Securing Your MongoDB Deployment
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
About HTTP and REST
About HTTP and RESTAbout HTTP and REST
About HTTP and REST
 
Mdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgrMdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgr
 

Similar to SQL Server -Service Broker - Reliable Messaging

Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregation
Andrew Siemer
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
Fernando G. Guerrero
 
數據庫遷移到雲端的成功秘訣
數據庫遷移到雲端的成功秘訣數據庫遷移到雲端的成功秘訣
數據庫遷移到雲端的成功秘訣
Amazon Web Services
 
MySQL Security in a Cloudy World
MySQL Security in a Cloudy WorldMySQL Security in a Cloudy World
MySQL Security in a Cloudy World
Dave Stokes
 
MSSQL SERVER
MSSQL SERVERMSSQL SERVER
MSSQL SERVER
Dharmendrasingh417
 
Modern ETL: Azure Data Factory, Data Lake, and SQL Database
Modern ETL: Azure Data Factory, Data Lake, and SQL DatabaseModern ETL: Azure Data Factory, Data Lake, and SQL Database
Modern ETL: Azure Data Factory, Data Lake, and SQL Database
Eric Bragas
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops
Mydbops
 
Where should I be encrypting my data?
Where should I be encrypting my data? Where should I be encrypting my data?
Where should I be encrypting my data?
Information Technology Society Nepal
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_upload
Rajini Ramesh
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
Fernando G. Guerrero
 
Scalability in cloud applications
Scalability in cloud applicationsScalability in cloud applications
Scalability in cloud applications
Radu Vunvulea
 
Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure  Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure
Jethro Seghers
 
Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure  Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure
Jethro Seghers
 
Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that grow
Gibraltar Software
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
Michaela Murray
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database Development
Steve Jones
 
CV-Kumar_TAM
CV-Kumar_TAMCV-Kumar_TAM
CV-Kumar_TAM
Kumar R
 
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
Manolis Vavalis
 
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
Amazon Web Services
 
NoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using CouchbaseNoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using Couchbase
Brant Burnett
 

Similar to SQL Server -Service Broker - Reliable Messaging (20)

Introduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregationIntroduction to CQRS - command and query responsibility segregation
Introduction to CQRS - command and query responsibility segregation
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
 
數據庫遷移到雲端的成功秘訣
數據庫遷移到雲端的成功秘訣數據庫遷移到雲端的成功秘訣
數據庫遷移到雲端的成功秘訣
 
MySQL Security in a Cloudy World
MySQL Security in a Cloudy WorldMySQL Security in a Cloudy World
MySQL Security in a Cloudy World
 
MSSQL SERVER
MSSQL SERVERMSSQL SERVER
MSSQL SERVER
 
Modern ETL: Azure Data Factory, Data Lake, and SQL Database
Modern ETL: Azure Data Factory, Data Lake, and SQL DatabaseModern ETL: Azure Data Factory, Data Lake, and SQL Database
Modern ETL: Azure Data Factory, Data Lake, and SQL Database
 
Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops Exploring the Fundamentals of YugabyteDB - Mydbops
Exploring the Fundamentals of YugabyteDB - Mydbops
 
Where should I be encrypting my data?
Where should I be encrypting my data? Where should I be encrypting my data?
Where should I be encrypting my data?
 
Slide presentation pycassa_upload
Slide presentation pycassa_uploadSlide presentation pycassa_upload
Slide presentation pycassa_upload
 
Dealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NETDealing with SQL Security from ADO.NET
Dealing with SQL Security from ADO.NET
 
Scalability in cloud applications
Scalability in cloud applicationsScalability in cloud applications
Scalability in cloud applications
 
Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure  Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure
 
Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure  Supporting architecture office 365 on windows azure
Supporting architecture office 365 on windows azure
 
Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that grow
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database Development
 
CV-Kumar_TAM
CV-Kumar_TAMCV-Kumar_TAM
CV-Kumar_TAM
 
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
 
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
Simplify Your Database Migration to AWS | AWS Public Sector Summit 2016
 
NoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using CouchbaseNoSQL for SQL Server Developers using Couchbase
NoSQL for SQL Server Developers using Couchbase
 

More from Sperasoft

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4
Sperasoft
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted World
Sperasoft
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4
Sperasoft
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек
Sperasoft
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay Tags
Sperasoft
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4
Sperasoft
 
Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks
Sperasoft
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databases
Sperasoft
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen Framework
Sperasoft
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security Threats
Sperasoft
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015
Sperasoft
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective Мeetings
Sperasoft
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
Sperasoft
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA Development
Sperasoft
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
Sperasoft
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JS
Sperasoft
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into Kanban
Sperasoft
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
Sperasoft
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutes
Sperasoft
 

More from Sperasoft (20)

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted World
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay Tags
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4
 
Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databases
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen Framework
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security Threats
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective Мeetings
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA Development
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JS
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into Kanban
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutes
 

Recently uploaded

FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptxFIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Alliance
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
Zilliz
 
Keynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive SecurityKeynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive Security
Priyanka Aash
 
Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1
DianaGray10
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptxFIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Alliance
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
jorgelebrato
 
DefCamp_2016_Chemerkin_Yury_--_publish.pdf
DefCamp_2016_Chemerkin_Yury_--_publish.pdfDefCamp_2016_Chemerkin_Yury_--_publish.pdf
DefCamp_2016_Chemerkin_Yury_--_publish.pdf
Yury Chemerkin
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
siddu769252
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Alliance
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
Priyanka Aash
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Alliance
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
Badri_Bady
 
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
OnBoard
 
Indian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for StartupsIndian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for Startups
AMol NAik
 
The Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdfThe Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdf
Sara Kroft
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
Priyanka Aash
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
Razin Mustafiz
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
Priyanka Aash
 

Recently uploaded (20)

FIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptxFIDO Munich Seminar Introduction to FIDO.pptx
FIDO Munich Seminar Introduction to FIDO.pptx
 
The History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal EmbeddingsThe History of Embeddings & Multimodal Embeddings
The History of Embeddings & Multimodal Embeddings
 
Keynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive SecurityKeynote : AI & Future Of Offensive Security
Keynote : AI & Future Of Offensive Security
 
Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1Discovery Series - Zero to Hero - Task Mining Session 1
Discovery Series - Zero to Hero - Task Mining Session 1
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
 
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptxFIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
 
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partesExchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
Exchange, Entra ID, Conectores, RAML: Todo, a la vez, en todas partes
 
DefCamp_2016_Chemerkin_Yury_--_publish.pdf
DefCamp_2016_Chemerkin_Yury_--_publish.pdfDefCamp_2016_Chemerkin_Yury_--_publish.pdf
DefCamp_2016_Chemerkin_Yury_--_publish.pdf
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
 
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptxFIDO Munich Seminar In-Vehicle Payment Trends.pptx
FIDO Munich Seminar In-Vehicle Payment Trends.pptx
 
Finetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and DefendingFinetuning GenAI For Hacking and Defending
Finetuning GenAI For Hacking and Defending
 
FIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptxFIDO Munich Seminar Workforce Authentication Case Study.pptx
FIDO Munich Seminar Workforce Authentication Case Study.pptx
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
 
History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )History and Introduction for Generative AI ( GenAI )
History and Introduction for Generative AI ( GenAI )
 
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
Mastering Board Best Practices: Essential Skills for Effective Non-profit Lea...
 
Indian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for StartupsIndian Privacy law & Infosec for Startups
Indian Privacy law & Infosec for Startups
 
The Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdfThe Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdf
 
Demystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity ApplicationsDemystifying Neural Networks And Building Cybersecurity Applications
Demystifying Neural Networks And Building Cybersecurity Applications
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
 

SQL Server -Service Broker - Reliable Messaging

  • 1. SQL Server Service Broker Scale out by Reliable Messaging
  • 2. • Scalability – what does Scale Out means? • Sharding • Problems of sharding • How does Service Broker help? Agenda
  • 3. • Is the ability of a system to handle growing amount of work in a capable manner • or its ability to be enlarged to accommodate that growth http://en.wikipedia.org/wiki/Scalability Scalability
  • 4. • Scale up – scale vertically • Scale out – scale horizontally Scalability Methods
  • 5. • means vertically • add resources to a single node in a system – CPU – memory – storage – etc Scaling Up
  • 6. • means horizontally • add more nodes to a system • in databases that’s called Sharding • Microsoft used another term in SQL Azure - Federations Scaling Out
  • 7. • Twitter Gizzard - https://github.com/twitter/gizzard • written in Scala Sharding Frameworks
  • 8. Sharding involves two technologies: • Partitioning • Replication Sharding
  • 9. • Data is divided into chunks • Stored across computers • Each chunk is small enough that we can manipulate and query efficiently User = “Denis” User = “Eva” Partitioning
  • 10. • multiple copies of data are stored across several machines • efficiently responds to tons of queries • resilient to failures User = “Denis” User = “Eva” User = “Denis” User = “Eva” Replication
  • 11. Besides Scaling Out: • Disaster Recovery strategies have You to make database backups • Replicated shards are working copies • Need a new backup? Replicate a new Shard! Benefits of Sharding
  • 12. • Yes! Sharding is difficult! • We have to think of how to partition our data correctly • How to ensure that all copies of data are consistent? • Write conflicts – no guarantee that operations will apply in order Are there any Problems?
  • 13. • “Shared Nothing Architecture” • no ongoing need to retain shared access between shards • each Shard can live in a totally separate – instance – database server – data center – continent Design Principle
  • 14. • Orders table is partitioned by Region • Orders references to Users • Users is not partitioned, it is replicated • How to maintain Users in a consistent state? Users (not partitioned) Orders [Region = “US”] Users (not partitioned) Orders [Region = “Russia”] Partitioning Problem
  • 15. Wall Statuses User [Name = “Denis”] Wall Statuses User [Name = “Eva”] Front-End POST Denis writes a new Status GET We should see that status on Eva’s wall How do we get Denis’ statuses? Facebook Sample
  • 16. Wall Statuses User [Name = “Denis”] Wall Statuses User [Name = “Eva”] Front-End POST Denis writes a new Status POST Duplicate the status? No benefit from Shards then! Wrong! Possible Solution 1
  • 17. Wall Statuses User [Name = “Denis”] Wall Statuses User [Name = “Eva”] Front-End POST Denis writes a new Status GET Gets a user data No benefit from Shards then! Wrong! Possible Solution 2
  • 18. Wall Statuses User [Name = “Denis”] Wall Statuses User [Name = “Eva”] Front-End POST Denis writes a new Status POST Propogate the status GET All OK Real Solution
  • 19. • custom application which reads from one Shard and writes to the others • add all Shards as Linked servers, write stored procedures to write a new record to each remote server • SQL Server Service Broker Possible Technologies
  • 20. • allows Internal and External processes to send and receive guaranteed asynchronous messages • messages are sent to Queues in the same database, same instance, same server, another database, another instance, remote server Service Broker
  • 21. the largest known implementation is in MySpace • 440 SQL Server instances • over 1,000 databases • 1 Petabyte of data (1 million gigabytes) Performance: • 5,000 messages/second in Labs • 18,000 messages/second in MySpace Implementations
  • 22. • Always Transactional • Asynchronous • Queued • All messages are in XML format • Routing • Multicast messages in SQL Server 2012 Advantages
  • 23. • No Administration Tools – not a lack - no at all • Queue is a Table in database – index fragmentation when we cannot empty queue • complicated T-SQL syntax and object model Disadvantages
  • 24. • Message Types • Contracts • Queues • Services • Routes • Activation • Remote Service Bindings • Dialog Conversation • Conversation Groups Service Broker Concepts
  • 25. • Dialog Security – between two Services – encrypts messages in a dialog conversation – provides the remote authorization • Transport Security – establishes an authenticated network connection between two Databases Service Broker Security
  • 26. • Enable Service Broker at Database level ALTER DATABASE SampleDatabase SET ENABLE_BROKER; GO • Always enable Service Broker in MSDB system database in each SQL Server instance • Enable SQL Server to communicate to another instance at Database level ALTER DATABASE SampleDatabase SET TRUSTWORTHY ON; GO SQL Server Configuration
  • 27. • Create Send Message type CREATE MESSAGE TYPE NewUserRequest VALIDATION = WELL_FORMED_XML; • Create Receive Message Type CREATE MESSAGE TYPE NewUserResponse VALIDATION = WELL_FORMED_XML; Message Types
  • 28. • create Contract between two services CREATE CONTRACT NewUserContract ( NewUserRequest SENT BY INITIATOR, NewUserResponse SENT BY TARGET ); Service Contracts
  • 29. CREATE QUEUE NewUserReceiveQueue WITH STATUS = ON, ACTIVATION ( PROCEDURE_NAME = OnReceiveNewUser, MAX_QUEUE_READERS = 5, Execute AS 'dbuser‘ ) ; CREATE QUEUE NewUserSendQueue WITH STATUS = ON; Queues
  • 30. • Service will be listening for messages in a queue and react only on those which apply to the spicified contract CREATE SERVICE NewUserSendService ON QUEUE NewUserSendQueue ( [NewUserContract] ); CREATE SERVICE NewUserReceiveService ON QUEUE NewUserReceiveQueue ( [NewUserContract] ); Services
  • 31. Sender: • begins a transaction • begins a dialog conversation from NewUserSendService to NewUserReceiveService • sends one or more XML messages to that dialog • commits a transaction • Waits for a Reply message • Processes Reply messages when arrived Sending a Messgae
  • 32. Receiver (Target): • when a new message is delivered to Receiver's NewUserReceiveQueue the OnReceiveNewUser stored procedure is activated by Service Broker • Stored procedure begins a transaction • receives messages out of the NewUserReceiveQueue queue • sends Reply messages • ends a dialog conversation • Do what you want with that message • commits a transaction Receiving a Message