SlideShare a Scribd company logo
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
YAPC::NA 2005
High Availability
DBI & MySQL
Steve Purkis
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
Slide 3
High Availability?
• What is High Availability?
• Ever have an application fail because a
mission critical server crashed?
• High Availability is an attempt to provide
zero application downtime.
Slide 4
High Availability?
• How do I achieve HA?:
• Analyze your apps
• Most important components?
• Remove single points of failure (SPOFs):
• Add redundant servers
• Replicate data (backups, realtime)
• Load balancing
• Failover when things go pear-shaped
Slide 5
High Availability?
• This talk…
• Introduces one approach to building HA
Perl apps that rely on MySQL.
• We’ve used similar techniques with Oracle
• They work for us…
• They may not be right for you!
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
Slide 7
Setting Up MySQL
• Some typical architectures…
Slide 8
Setting Up MySQL
• Ye olde basic setup
• Not HA.
Application Server
MySQL
Server
Slide 9
Setting Up MySQL
• One master, one read-only slave
• Good for load balancing
• Still not really HA!
Application Server
MySQL
Master
MySQL
Slave Data
Replication
reads writes
Load Balancer
Slide 10
Setting Up MySQL
• Two masters
• It’s HA, but…
• Flaky, tricky to work with!
Application Server
MySQL
MasterTwo-way
Replication
MySQL
Master
Load Balancer
Slide 11
MySQL
Slave
Setting Up MySQL
• Two masters, multiple slaves
• Only one master active at a time
• HA
Application Server
MySQL
Slaves Data
Replication
reads writes
Primary
Master
2nd
ary
Master
Master Failover
Load Balancer
• HA (unless your hosting center goes down)
Slide 12
Setting Up MySQL
• Your HA MySQL architecture will depend on:
• SLAs
• Application requirements
• Load
• Physical spread of servers
• Budget
• Caveats:
• Are your apps read or write heavy?
• Beware of replication lag time
• Common in high-latency networks
• Do your apps need the latest data?
• Transactions?
Slide 13
Setting Up MySQL
• Load balancing
• Hardware?
• Software?
• Master Failover
• On Slaves:
CHANGE MASTER TO …
• Manual?
• Automate?
• Cron? Application? SLB?
• On App servers:
• Connect to Secondary
• Not required if using a hot spare w/same ip
Slide 14
Setting Up MySQL
• Recommended reading:
• High Performance MySQL
- Jeremey Zawodny & Derek Balling
• MySQL Replication docs
• MySQL Cluster white paper
• For Linux:
• Linux Virtual Server Project
• Linux-HA
Slide 15
Setting Up MySQL
• If you have any trouble:
• MySQL mailing list
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
Slide 17
Our Approach
• Our requirements:
• Read-heavy apps
• Over 750 clients, many with SLAs
• Reliability:
• Read availability most important
• Must work if a server farm goes down
• Speed is of essence:
• Millions of requests a day
• Don’t need transactions
• Minimize costs
Slide 18
Our Approach
Application
Server
Application
Server
Application
Server
MySQL
Slave
MySQL
Slaves
MySQL
Slaves
Application
Server
MySQL
Master
MySQL
2nd
ary
MasterFailover
Data Replication
95% 5%
reads
writes
Slide 19
Farm 2
Farm 3
Farm 1
Our Approach
Application
Server
Application
Server
MySQL
Slave
Application
Server
MySQL
Master
MySQL
2nd
ary
MasterFailover
In-Farm Data Replication
Application
Server
MySQL
Slave
MySQL
Slaves
MySQL
Slave
MySQL
Slaves
Query caching
Slide 20
Our Approach
• DBI Framework:
• Load balancing
• Server selection
• Read / Write query?
• Failover
Application
DBI Framework
----------------------------------- snip: how to tell reads from writes? ---------------------------------
my ($action, $dbh) = $query =~ /Aselect|A(select|Ashow|Adesc/i
? ("read", $dbh_read)
: ("write", $dbh_write);
----------------------------------------------------------------------------------------------------------
Slide 21
Our Approach
• Load balancing
• On connect
• Weighted server selection
• Availability, number of processes,
user weights, which farm
• MySQL idle timeout
• Failover
• Connect to next slave
• Automatic query retry
Application
DBI Framework
MySQL
Slave
MySQL
Slave
reads
Slide 22
Our Approach
• Failover
• Persistent connection to
all masters
• Automatic query retry
• Automatic fallback
Application Server
DBI Framework
Primary
Master
2nd
ary
Master
MasterFailover
writes
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
Slide 24
DBI Framework
• Two wrapper functions:
• dbconnect( 'read' | 'write' )
• Read: Select slave to connect to
• Write: Connect to all masters
• $sth = sql( $query )
• Read / write dbh selection
• Failover & fallback
• Pseudo code?
Slide 25
DBI Framework
• dbconnect( 'read' | 'write' )
• Read:
For each slave
weight = 0, next if can’t ping
check number of processes with mysqladmin
weight = no. processes / user weighting
Connect to slave with lowest weight
Sanity check: run a simple query
Try next slave if that failed
• Write:
For each master
Connect
Sanity check: run a simple query
Set $write_dbh to primary master
Slide 26
DBI Framework
• $sth = sql( $query )
• Determine query type…
• Read:
Execute query.
Failover to next slave on error, and retry query.
• Write:
Fallback?
If not using primary, and we failed over X seconds ago, try
reconnecting to master.
Execute query.
Failover to next master on error, and retry query.
Slide 27
DBI Framework
• Major Drawbacks:
• Using DBI-based CPAN modules is hard!
Slide 28
DBI Framework
• Looking Ahead…
• Push HA logic into the DBI layer
• Write DBD::MysqlHA ?
• DBIx::HA ?
• DBD::Multiplex ?
• DBIx::DBCluster ?
• SQL Relay ?
• MySQL Cluster?
High Availability?
Setting Up MySQL
Our Approach
DBI Framework
Questions
High Availability DBI & MySQL
Slide 30
DBI Frameworks on CPAN
• If there’s time…
Slide 31
DBI Frameworks on CPAN
• The ones I know a bit about:
• DBIx::HA
• DBD::Multiplex
• DBIx::DBCluster
Slide 32
DBI Frameworks on CPAN
• DBIx::HA
• Generic HA solution
(written & tested for Sybase)
• Configurable by db name (%DATABASE::conf)
• Looks well thought out
Slide 33
DBIx::HA
Pros
• Does Failover
• On query failure & dbh
disconnected
• Does timeouts:
• connect, query execute
• Safe signals
• Connect all dsns on init
• Supports Apache::DBI
Cons
• No read / write distinction
• No way to choose which
dbh to use on failover
• (want to use a mysql-
specific algorithm)
• Timeouts with SIGALRM
• (but how else, really?)
• No ping checks for non-
Apache::DBI
• (uses $dbh->ping anyways
- we prefer ICMP ping)
Slide 34
DBIx::HA
• Also: written & tested for Sybase!
• Potential DBD::Mysql problems:
• auto_reconnect
we may reconnect to a db when we should be failing over
Slide 35
DBI Frameworks on CPAN
• DBD::Multiplex
• send requests to multiple dsn's
• Configure servers to use in $dsn
(pipe-separated list)
Slide 36
DBD::Multiplex
Pros
• Supports master/slave
setup:
• differentiates between
reads / writes
• Connects to all dsns
(good for fast master
failover)
• Does failover:
• default behaviour
reads: first_success
writes: first_error
Cons
• Can only specify one
master
• (though if you specify none,
writes can go to all with
'first_error' exit mode)
• Connects to all dsns
• (don't want to connect to all
slaves)
• No customizable slave
failover algorithm
• No reconnects
• No fallback!
Slide 37
DBI Frameworks on CPAN
• How could we re-use CPAN modules?
• DBIx::HA
• Sub-class to introduce MySQL specific functionality?
• Introduce a callback for server selection on failover?
• Use in conjunction with DBD::Multiplex for read/write dbh
selection?
• There could be problems though…
• In general:
• Backwards compat
• sql() wrapper (for backwards compat)
• Custom logging?
• Our db wrappers do other things too…
Slide 38
DBI Frameworks on CPAN
• Maybe the best way to reuse them is to nick their
ideas?
• DBD::MysqlHA ?
• Combination of DBIx::HA and DBD::Multiplex
• MySQL specific:
• Customizeable server selection algorithm
• Persistent connections

More Related Content

What's hot

DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop
Sascha Möllering
 
Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...
Andy Kucharski
 
Performance and scalability with drupal
Performance and scalability with drupalPerformance and scalability with drupal
Performance and scalability with drupal
Ronan Berder
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
cherryhillco
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
Tomer Gabel
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the Cloud
Ryan Cuprak
 
Redis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHPRedis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHP
Ricard Clau
 
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Fwdays
 
Why akka
Why akkaWhy akka
Why akka
Sapardi Sapardi
 
Camel oneactivemq posta-final
Camel oneactivemq posta-finalCamel oneactivemq posta-final
Camel oneactivemq posta-final
Christian Posta
 
Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012
Amazee Labs
 
How NOT to get lost in the current JavaScript landscape
How NOT to get lost in the current JavaScript landscapeHow NOT to get lost in the current JavaScript landscape
How NOT to get lost in the current JavaScript landscape
Radosław Scheibinger
 
Alfresco DevCon 2019 Performance Tools of the Trade
Alfresco DevCon 2019   Performance Tools of the TradeAlfresco DevCon 2019   Performance Tools of the Trade
Alfresco DevCon 2019 Performance Tools of the Trade
Luis Colorado
 
Performance out
Performance outPerformance out
Performance out
Andrea Martinez
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
Modern javascript
Modern javascriptModern javascript
Modern javascript
Kevin Ball
 
Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10
Derek Ashmore
 
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Derek Ashmore
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js Munich
Mike North
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
Joe Kutner
 

What's hot (20)

DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop
 
Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal commerce performance profiling and tunning using loadstorm experiments...
 
Performance and scalability with drupal
Performance and scalability with drupalPerformance and scalability with drupal
Performance and scalability with drupal
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the Cloud
 
Redis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHPRedis Everywhere - Sunshine PHP
Redis Everywhere - Sunshine PHP
 
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
 
Why akka
Why akkaWhy akka
Why akka
 
Camel oneactivemq posta-final
Camel oneactivemq posta-finalCamel oneactivemq posta-final
Camel oneactivemq posta-final
 
Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012
 
How NOT to get lost in the current JavaScript landscape
How NOT to get lost in the current JavaScript landscapeHow NOT to get lost in the current JavaScript landscape
How NOT to get lost in the current JavaScript landscape
 
Alfresco DevCon 2019 Performance Tools of the Trade
Alfresco DevCon 2019   Performance Tools of the TradeAlfresco DevCon 2019   Performance Tools of the Trade
Alfresco DevCon 2019 Performance Tools of the Trade
 
Performance out
Performance outPerformance out
Performance out
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
Modern javascript
Modern javascriptModern javascript
Modern javascript
 
Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10
 
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
 
Write Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js MunichWrite Once, Run Everywhere - Ember.js Munich
Write Once, Run Everywhere - Ember.js Munich
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 

Viewers also liked

Database Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::ClassDatabase Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::Class
Dave Cross
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
Marcos Rebelo
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
Utkarsh Sengar
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
Dave Cross
 
Apress.html5.and.java script.projects.oct.2011
Apress.html5.and.java script.projects.oct.2011Apress.html5.and.java script.projects.oct.2011
Apress.html5.and.java script.projects.oct.2011
Samuel K. Itotia
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
Joe Jiang
 
Dbi Advanced Talk 200708
Dbi Advanced Talk 200708Dbi Advanced Talk 200708
Dbi Advanced Talk 200708
oscon2007
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
Laurent Dami
 
My sql.ppt
My sql.pptMy sql.ppt
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
Dave Cross
 
LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners Perl
Dave Cross
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
Kazuho Oku
 

Viewers also liked (12)

Database Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::ClassDatabase Programming with Perl and DBIx::Class
Database Programming with Perl and DBIx::Class
 
Perl Introduction
Perl IntroductionPerl Introduction
Perl Introduction
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
Apress.html5.and.java script.projects.oct.2011
Apress.html5.and.java script.projects.oct.2011Apress.html5.and.java script.projects.oct.2011
Apress.html5.and.java script.projects.oct.2011
 
perl usage at database applications
perl usage at database applicationsperl usage at database applications
perl usage at database applications
 
Dbi Advanced Talk 200708
Dbi Advanced Talk 200708Dbi Advanced Talk 200708
Dbi Advanced Talk 200708
 
Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
LPW: Beginners Perl
LPW: Beginners PerlLPW: Beginners Perl
LPW: Beginners Perl
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 

Similar to High Availability Perl DBI + MySQL

SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
Amazon Web Services
 
Building resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless componentsBuilding resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless components
Jeremy Daly
 
SQL Azure for ISUG(SQL Server Israeli User Group)
SQL Azure for ISUG(SQL Server Israeli User Group)SQL Azure for ISUG(SQL Server Israeli User Group)
SQL Azure for ISUG(SQL Server Israeli User Group)
Pini Krisher
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database Connectivity
Bill Buchan
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
Scott Miao
 
Voldemort Nosql
Voldemort NosqlVoldemort Nosql
Voldemort Nosql
elliando dias
 
MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)
Colin Charles
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete Tutorial
Colin Charles
 
Moving Windows Applications to the Cloud
Moving Windows Applications to the CloudMoving Windows Applications to the Cloud
Moving Windows Applications to the Cloud
RightScale
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and Expansion
LetsConnect
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
Jonathan Klein
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
Building Resilient Serverless Systems with Non-Serverless Components
Building Resilient Serverless Systems with Non-Serverless ComponentsBuilding Resilient Serverless Systems with Non-Serverless Components
Building Resilient Serverless Systems with Non-Serverless Components
Jeremy Daly
 
PaaS with Java
PaaS with JavaPaaS with Java
PaaS with Java
Eberhard Wolff
 
Moving to the Cloud: AWS, Zend, RightScale
Moving to the Cloud: AWS, Zend, RightScaleMoving to the Cloud: AWS, Zend, RightScale
Moving to the Cloud: AWS, Zend, RightScale
mmoline
 
NoSQL and ACID
NoSQL and ACIDNoSQL and ACID
NoSQL and ACID
FoundationDB
 
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
Amazon Web Services
 
Cassandra Summit 2014: Deploying Cassandra for Call of Duty
Cassandra Summit 2014: Deploying Cassandra for Call of DutyCassandra Summit 2014: Deploying Cassandra for Call of Duty
Cassandra Summit 2014: Deploying Cassandra for Call of Duty
DataStax Academy
 
Framing the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQLFraming the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQL
Inside Analysis
 

Similar to High Availability Perl DBI + MySQL (20)

SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
 
Building resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless componentsBuilding resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless components
 
SQL Azure for ISUG(SQL Server Israeli User Group)
SQL Azure for ISUG(SQL Server Israeli User Group)SQL Azure for ISUG(SQL Server Israeli User Group)
SQL Azure for ISUG(SQL Server Israeli User Group)
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database Connectivity
 
001 hbase introduction
001 hbase introduction001 hbase introduction
001 hbase introduction
 
Voldemort Nosql
Voldemort NosqlVoldemort Nosql
Voldemort Nosql
 
MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete Tutorial
 
Moving Windows Applications to the Cloud
Moving Windows Applications to the CloudMoving Windows Applications to the Cloud
Moving Windows Applications to the Cloud
 
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
 
IBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and ExpansionIBM Connections – Managing Growth and Expansion
IBM Connections – Managing Growth and Expansion
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
Building Resilient Serverless Systems with Non-Serverless Components
Building Resilient Serverless Systems with Non-Serverless ComponentsBuilding Resilient Serverless Systems with Non-Serverless Components
Building Resilient Serverless Systems with Non-Serverless Components
 
PaaS with Java
PaaS with JavaPaaS with Java
PaaS with Java
 
Moving to the Cloud: AWS, Zend, RightScale
Moving to the Cloud: AWS, Zend, RightScaleMoving to the Cloud: AWS, Zend, RightScale
Moving to the Cloud: AWS, Zend, RightScale
 
NoSQL and ACID
NoSQL and ACIDNoSQL and ACID
NoSQL and ACID
 
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
Production NoSQL in an Hour: Introduction to Amazon DynamoDB (DAT101) | AWS r...
 
Cassandra Summit 2014: Deploying Cassandra for Call of Duty
Cassandra Summit 2014: Deploying Cassandra for Call of DutyCassandra Summit 2014: Deploying Cassandra for Call of Duty
Cassandra Summit 2014: Deploying Cassandra for Call of Duty
 
Framing the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQLFraming the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQL
 

More from Steve Purkis

Start the Wardley Mapping Foundation
Start the Wardley Mapping FoundationStart the Wardley Mapping Foundation
Start the Wardley Mapping Foundation
Steve Purkis
 
Maps: a better way to organise
Maps: a better way to organiseMaps: a better way to organise
Maps: a better way to organise
Steve Purkis
 
Making sense of complex systems
Making sense of complex systemsMaking sense of complex systems
Making sense of complex systems
Steve Purkis
 
Glasswall Wardley Maps & Services
Glasswall Wardley Maps & ServicesGlasswall Wardley Maps & Services
Glasswall Wardley Maps & Services
Steve Purkis
 
What do Wardley Maps mean to me? (Map Camp 2020)
What do Wardley Maps mean to me?  (Map Camp 2020)What do Wardley Maps mean to me?  (Map Camp 2020)
What do Wardley Maps mean to me? (Map Camp 2020)
Steve Purkis
 
Introduction to Wardley Maps
Introduction to Wardley MapsIntroduction to Wardley Maps
Introduction to Wardley Maps
Steve Purkis
 
COVID-19 - Systems & Complexity Thinking in Action
COVID-19 - Systems & Complexity Thinking in ActionCOVID-19 - Systems & Complexity Thinking in Action
COVID-19 - Systems & Complexity Thinking in Action
Steve Purkis
 
Predicting & Influencing with Kanban Metrics
Predicting & Influencing with Kanban MetricsPredicting & Influencing with Kanban Metrics
Predicting & Influencing with Kanban Metrics
Steve Purkis
 
Map Your Values: Connect & Collaborate
Map Your Values: Connect & CollaborateMap Your Values: Connect & Collaborate
Map Your Values: Connect & Collaborate
Steve Purkis
 
Modern agile overview
Modern agile overviewModern agile overview
Modern agile overview
Steve Purkis
 
Kanban in the Kitchen
Kanban in the KitchenKanban in the Kitchen
Kanban in the Kitchen
Steve Purkis
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
Steve Purkis
 
Entertaining pixie
Entertaining pixieEntertaining pixie
Entertaining pixie
Steve Purkis
 
Scalar::Footnote
Scalar::FootnoteScalar::Footnote
Scalar::Footnote
Steve Purkis
 
TAP-Harness + friends
TAP-Harness + friendsTAP-Harness + friends
TAP-Harness + friends
Steve Purkis
 

More from Steve Purkis (15)

Start the Wardley Mapping Foundation
Start the Wardley Mapping FoundationStart the Wardley Mapping Foundation
Start the Wardley Mapping Foundation
 
Maps: a better way to organise
Maps: a better way to organiseMaps: a better way to organise
Maps: a better way to organise
 
Making sense of complex systems
Making sense of complex systemsMaking sense of complex systems
Making sense of complex systems
 
Glasswall Wardley Maps & Services
Glasswall Wardley Maps & ServicesGlasswall Wardley Maps & Services
Glasswall Wardley Maps & Services
 
What do Wardley Maps mean to me? (Map Camp 2020)
What do Wardley Maps mean to me?  (Map Camp 2020)What do Wardley Maps mean to me?  (Map Camp 2020)
What do Wardley Maps mean to me? (Map Camp 2020)
 
Introduction to Wardley Maps
Introduction to Wardley MapsIntroduction to Wardley Maps
Introduction to Wardley Maps
 
COVID-19 - Systems & Complexity Thinking in Action
COVID-19 - Systems & Complexity Thinking in ActionCOVID-19 - Systems & Complexity Thinking in Action
COVID-19 - Systems & Complexity Thinking in Action
 
Predicting & Influencing with Kanban Metrics
Predicting & Influencing with Kanban MetricsPredicting & Influencing with Kanban Metrics
Predicting & Influencing with Kanban Metrics
 
Map Your Values: Connect & Collaborate
Map Your Values: Connect & CollaborateMap Your Values: Connect & Collaborate
Map Your Values: Connect & Collaborate
 
Modern agile overview
Modern agile overviewModern agile overview
Modern agile overview
 
Kanban in the Kitchen
Kanban in the KitchenKanban in the Kitchen
Kanban in the Kitchen
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Entertaining pixie
Entertaining pixieEntertaining pixie
Entertaining pixie
 
Scalar::Footnote
Scalar::FootnoteScalar::Footnote
Scalar::Footnote
 
TAP-Harness + friends
TAP-Harness + friendsTAP-Harness + friends
TAP-Harness + friends
 

Recently uploaded

What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
Vijayananda Mohire
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
ScyllaDB
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
Stephanie Beckett
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
Sally Laouacheria
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 

Recently uploaded (20)

What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 

High Availability Perl DBI + MySQL

  • 1. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL YAPC::NA 2005 High Availability DBI & MySQL Steve Purkis
  • 2. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL
  • 3. Slide 3 High Availability? • What is High Availability? • Ever have an application fail because a mission critical server crashed? • High Availability is an attempt to provide zero application downtime.
  • 4. Slide 4 High Availability? • How do I achieve HA?: • Analyze your apps • Most important components? • Remove single points of failure (SPOFs): • Add redundant servers • Replicate data (backups, realtime) • Load balancing • Failover when things go pear-shaped
  • 5. Slide 5 High Availability? • This talk… • Introduces one approach to building HA Perl apps that rely on MySQL. • We’ve used similar techniques with Oracle • They work for us… • They may not be right for you!
  • 6. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL
  • 7. Slide 7 Setting Up MySQL • Some typical architectures…
  • 8. Slide 8 Setting Up MySQL • Ye olde basic setup • Not HA. Application Server MySQL Server
  • 9. Slide 9 Setting Up MySQL • One master, one read-only slave • Good for load balancing • Still not really HA! Application Server MySQL Master MySQL Slave Data Replication reads writes Load Balancer
  • 10. Slide 10 Setting Up MySQL • Two masters • It’s HA, but… • Flaky, tricky to work with! Application Server MySQL MasterTwo-way Replication MySQL Master Load Balancer
  • 11. Slide 11 MySQL Slave Setting Up MySQL • Two masters, multiple slaves • Only one master active at a time • HA Application Server MySQL Slaves Data Replication reads writes Primary Master 2nd ary Master Master Failover Load Balancer • HA (unless your hosting center goes down)
  • 12. Slide 12 Setting Up MySQL • Your HA MySQL architecture will depend on: • SLAs • Application requirements • Load • Physical spread of servers • Budget • Caveats: • Are your apps read or write heavy? • Beware of replication lag time • Common in high-latency networks • Do your apps need the latest data? • Transactions?
  • 13. Slide 13 Setting Up MySQL • Load balancing • Hardware? • Software? • Master Failover • On Slaves: CHANGE MASTER TO … • Manual? • Automate? • Cron? Application? SLB? • On App servers: • Connect to Secondary • Not required if using a hot spare w/same ip
  • 14. Slide 14 Setting Up MySQL • Recommended reading: • High Performance MySQL - Jeremey Zawodny & Derek Balling • MySQL Replication docs • MySQL Cluster white paper • For Linux: • Linux Virtual Server Project • Linux-HA
  • 15. Slide 15 Setting Up MySQL • If you have any trouble: • MySQL mailing list
  • 16. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL
  • 17. Slide 17 Our Approach • Our requirements: • Read-heavy apps • Over 750 clients, many with SLAs • Reliability: • Read availability most important • Must work if a server farm goes down • Speed is of essence: • Millions of requests a day • Don’t need transactions • Minimize costs
  • 19. Slide 19 Farm 2 Farm 3 Farm 1 Our Approach Application Server Application Server MySQL Slave Application Server MySQL Master MySQL 2nd ary MasterFailover In-Farm Data Replication Application Server MySQL Slave MySQL Slaves MySQL Slave MySQL Slaves Query caching
  • 20. Slide 20 Our Approach • DBI Framework: • Load balancing • Server selection • Read / Write query? • Failover Application DBI Framework ----------------------------------- snip: how to tell reads from writes? --------------------------------- my ($action, $dbh) = $query =~ /Aselect|A(select|Ashow|Adesc/i ? ("read", $dbh_read) : ("write", $dbh_write); ----------------------------------------------------------------------------------------------------------
  • 21. Slide 21 Our Approach • Load balancing • On connect • Weighted server selection • Availability, number of processes, user weights, which farm • MySQL idle timeout • Failover • Connect to next slave • Automatic query retry Application DBI Framework MySQL Slave MySQL Slave reads
  • 22. Slide 22 Our Approach • Failover • Persistent connection to all masters • Automatic query retry • Automatic fallback Application Server DBI Framework Primary Master 2nd ary Master MasterFailover writes
  • 23. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL
  • 24. Slide 24 DBI Framework • Two wrapper functions: • dbconnect( 'read' | 'write' ) • Read: Select slave to connect to • Write: Connect to all masters • $sth = sql( $query ) • Read / write dbh selection • Failover & fallback • Pseudo code?
  • 25. Slide 25 DBI Framework • dbconnect( 'read' | 'write' ) • Read: For each slave weight = 0, next if can’t ping check number of processes with mysqladmin weight = no. processes / user weighting Connect to slave with lowest weight Sanity check: run a simple query Try next slave if that failed • Write: For each master Connect Sanity check: run a simple query Set $write_dbh to primary master
  • 26. Slide 26 DBI Framework • $sth = sql( $query ) • Determine query type… • Read: Execute query. Failover to next slave on error, and retry query. • Write: Fallback? If not using primary, and we failed over X seconds ago, try reconnecting to master. Execute query. Failover to next master on error, and retry query.
  • 27. Slide 27 DBI Framework • Major Drawbacks: • Using DBI-based CPAN modules is hard!
  • 28. Slide 28 DBI Framework • Looking Ahead… • Push HA logic into the DBI layer • Write DBD::MysqlHA ? • DBIx::HA ? • DBD::Multiplex ? • DBIx::DBCluster ? • SQL Relay ? • MySQL Cluster?
  • 29. High Availability? Setting Up MySQL Our Approach DBI Framework Questions High Availability DBI & MySQL
  • 30. Slide 30 DBI Frameworks on CPAN • If there’s time…
  • 31. Slide 31 DBI Frameworks on CPAN • The ones I know a bit about: • DBIx::HA • DBD::Multiplex • DBIx::DBCluster
  • 32. Slide 32 DBI Frameworks on CPAN • DBIx::HA • Generic HA solution (written & tested for Sybase) • Configurable by db name (%DATABASE::conf) • Looks well thought out
  • 33. Slide 33 DBIx::HA Pros • Does Failover • On query failure & dbh disconnected • Does timeouts: • connect, query execute • Safe signals • Connect all dsns on init • Supports Apache::DBI Cons • No read / write distinction • No way to choose which dbh to use on failover • (want to use a mysql- specific algorithm) • Timeouts with SIGALRM • (but how else, really?) • No ping checks for non- Apache::DBI • (uses $dbh->ping anyways - we prefer ICMP ping)
  • 34. Slide 34 DBIx::HA • Also: written & tested for Sybase! • Potential DBD::Mysql problems: • auto_reconnect we may reconnect to a db when we should be failing over
  • 35. Slide 35 DBI Frameworks on CPAN • DBD::Multiplex • send requests to multiple dsn's • Configure servers to use in $dsn (pipe-separated list)
  • 36. Slide 36 DBD::Multiplex Pros • Supports master/slave setup: • differentiates between reads / writes • Connects to all dsns (good for fast master failover) • Does failover: • default behaviour reads: first_success writes: first_error Cons • Can only specify one master • (though if you specify none, writes can go to all with 'first_error' exit mode) • Connects to all dsns • (don't want to connect to all slaves) • No customizable slave failover algorithm • No reconnects • No fallback!
  • 37. Slide 37 DBI Frameworks on CPAN • How could we re-use CPAN modules? • DBIx::HA • Sub-class to introduce MySQL specific functionality? • Introduce a callback for server selection on failover? • Use in conjunction with DBD::Multiplex for read/write dbh selection? • There could be problems though… • In general: • Backwards compat • sql() wrapper (for backwards compat) • Custom logging? • Our db wrappers do other things too…
  • 38. Slide 38 DBI Frameworks on CPAN • Maybe the best way to reuse them is to nick their ideas? • DBD::MysqlHA ? • Combination of DBIx::HA and DBD::Multiplex • MySQL specific: • Customizeable server selection algorithm • Persistent connections

Editor's Notes

  1. Start off by asking who knows what HA is, and get a feel for how much experience they’ve got with HA.
  2. Did your clients notice? Did you have an SLA? Were you in bed at the time? Did you have a backup server? Did you have a backup of the data? How long did it take to get the backup server with the backup data back online?
  3. HA for reads, but not for writes.
  4. Due to the way MySQL replication works - conflicting writes (typically auto increment keys) Mention FS replication
  5. Include further links
  6. Confirm with andrew on # requests a day.
  7. Speak about minimizing costs: replication across farms. Query caching run on all slaves out of memory to remove io bottleneck
  8. S/w Loadbalancing
  9. Mention Tear down / setup of connections.
  10. HA dsn: dsn1: Multiplex to primary master + many slaves dsn2: Multiplex to secondary master + many slaves If all slaves go down, will all reads go to master?