SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
Scaling Databases with
     DBIx::Router
        Perrin Harkins
       We Also Walk Dogs
What is DBIx::Router?

Load-balancing
Failover
Sharding
Transparent
   (Mostly.)
Why would you need this?


Web and app servers are easy to scale
   Just add another dozen boxes
Why would you need this?

Databases not so much
   Big iron
   Commercial clustering solutions
   Human sacrifice
Advice from Experts




       Brad Fitzpatrick,                Cal Henderson,               Jeremy Zawodny
“Inside LiveJournal’s Backend”   “Building Scalable Websites”       and Derek J Balling,
                                                                “High Performance MySQL”
Caching

Keep your hot data in a fast cache
You get this one for free, thanks to DBI::Gofer
Can use Cache::FastMmap, memcached, etc. through CHI
Read-only Copies
Replication to local server or remote slaves
Be careful of replication lag




                (from MySQL 5.1 docs)
Sharding
Large data is split across multiple machines
   Users A-L, M-Z
   Logs by month
   Consistent hashing algorithm
May involve directory server
JOINs are now the programmer’s problem
This is going to mean a custom database layer

And rewriting all your old code to use it

DBIx::Router tries to separate this plumbing
Shoulders of Giants

Enter DBI::Gofer
   “A scalable stateless proxy architecture for DBI”
   Bundles up requests, sends them over a transport,
   executes them, sends back results
Shoulders of Giants

Used by shopzilla.com and petfinder.com to pool connections
Lots of good stuff like caching, timeouts, tracing
DBIx::Router is a Gofer transport
   But it executes the calls locally
Shoulders of Giants

CPAN makes everything easy
   SQL::Statement parses SQL (!)
   Config::Any solves the XML problem
How does it work?

DataSources
   Individual (DSNs) or Group
   Group handles failover
   Also load-balancing
Single DataSource
  {
       name       =>   'Master1',
       dsn        =>   'dbi:Pg:dbname=lolcats',
       user       =>   ‘icanhas’,
       password   =>   ‘ch33zeburger’,
  },
Group DataSource
  {
       name        => 'ReadCluster',
       class       => 'random',
       datasources => [ ‘Slave1’, ‘Slave2’ ],
  },
Group DataSource
  {
       name        => 'ReadCluster',
       class       => 'roundrobin',
       datasources => [ ‘Slave1’, ‘Slave2’ ],
  },
Group DataSource
  {
       name          =>   'ReadCluster',
       class         =>   'roundrobin',
       datasources   =>   [ ‘Slave1’, ‘Slave2’ ],
       failover      =>   1,
       timeout       =>   8,
  },
Group DataSource
  {
       name        => 'ReadWriteCluster',
       class       => 'repeater',
       datasources => [ ‘Master1’, ‘Master2’ ],
  },
Group DataSource
    {
         name      =>   'StoreShards',
         class     =>   'shard',
         type      =>   'list',
         table     =>   'orders',
         column    =>   'store_id',
         shards    =>   [
             {
                   values     => [ 1, 3, 5 ],
                   datasource => 'EastCoast',
              },
              {
                   values     => [ 2, 4, 6 ],
                   datasource => 'WestCoast',
              },
         ],
    },
Subclass DataSources

Custom auth schemes for the paranoid
Ye olde insane load-balancing scheme
Shards with a directory server
Rules

Map queries to DataSources
Organized in RuleLists
   Most specific to least
   Can fall back to pass-through
Rule: regex
  {
       class        =>   'regex',
       datasource   =>   'ReadCluster',
       match        =>   ['^ s* SELECT b '],
       not_match    =>   ['b FOR s+ UPDATE b '],
  },
Rule: readonly
  {
       class      => 'readonly',
       datasource => 'ReadCluster',
  },
Rule: parser
  {
        class => 'parser',
        match => [
            {
                structure => 'tables',
                operator => 'all',
                tokens     => ['order_history’]
            },
  },

      Operators: all, any, none, only
      Structures: command, tables, columns
Rule: not
  {
       class      => 'not',
       rule       => { class => ‘readonly’ }
       datasource => 'Master1',
  },
Rule: default
  {
       class      => 'default',
       datasource => 'Master1',
  },
{
    datasources => [
        {
            name => 'Master1',
            dsn => 'dbi:mysql:dbname=lolcats',
            user => undef,
            password => undef,
        },
        {
            name => 'Slave1',
            dsn => 'dbi:mysql:dbname=zomg1',
            user => undef,
            password => undef,
        },
        {
            name => 'Slave2',
            dsn => 'dbi:mysql:dbname=zomg2',
            user => undef,
            password => undef,
        },
        {
            name        => 'ReadCluster',
            class       => 'random',
            datasources => [ 'Slave1', 'Slave2', ],
            failover    => 1,
            timeout     => 8,
        },
    ],
    rules => [
        {
            class      => 'readonly',
            datasource => 'ReadCluster',
        },
        {
            class      => 'default',
            datasource => 'Master1',
        },
    ],
}
How do you run it?
DBI_AUTOPROXY=”dbi:Gofer: 
  transport=DBIx::Router; 
  conf=/path/to/conf.pl”

$dbh = DBI->connect("dbi:Gofer: 
  transport=DBIx::Router;        
  conf=/path/to/conf.pl;         
  dsn=$original_dsn",
  $user, $passwd, %attributes);
What’s the bad news?

AutoCommit
   But Tim plans to fix that
No streaming results
   Also fixable
Failover and sharding are tough to generalize
Status
Hosted on Google Code
Mostly there, but some bits need work
   Sharding
   Failover
Needs user feedback
Needs more tests
Future Directions

Make routing decisions optionally sticky
Support explicit hints in method call attributes
   Helps with sharding
   Workaround for tricky queries that fool SQL::Parser
Thanks!
http://code.google.com/p/dbix-router/
What else is out there?

Mostly faux DBD drivers
   DBD::Multi
   DBD::Multiplex
   DBIx::HA
DBI::Role

Más contenido relacionado

La actualidad más candente

Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
Randall Hunt
 
Create manula and automaticly database
Create manula and automaticly databaseCreate manula and automaticly database
Create manula and automaticly database
Anar Godjaev
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
Roland Bouman
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and Creativity
MongoDB
 

La actualidad más candente (18)

veracruz
veracruzveracruz
veracruz
 
BITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQL
 
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
 
My sql administration
My sql administrationMy sql administration
My sql administration
 
What's New in the PHP Driver
What's New in the PHP DriverWhat's New in the PHP Driver
What's New in the PHP Driver
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
Mongodb replication
Mongodb replicationMongodb replication
Mongodb replication
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Sequelize
SequelizeSequelize
Sequelize
 
Create manula and automaticly database
Create manula and automaticly databaseCreate manula and automaticly database
Create manula and automaticly database
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
 
Introduction databases and MYSQL
Introduction databases and MYSQLIntroduction databases and MYSQL
Introduction databases and MYSQL
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Brief introduction of Slick
Brief introduction of SlickBrief introduction of Slick
Brief introduction of Slick
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
BITS: Introduction to MySQL - Introduction and Installation
BITS: Introduction to MySQL - Introduction and InstallationBITS: Introduction to MySQL - Introduction and Installation
BITS: Introduction to MySQL - Introduction and Installation
 
Optimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and CreativityOptimizing Slow Queries with Indexes and Creativity
Optimizing Slow Queries with Indexes and Creativity
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 

Destacado (9)

Cam on doi
Cam on doiCam on doi
Cam on doi
 
Eastern state
Eastern stateEastern state
Eastern state
 
Introduction to performance tuning perl web applications
Introduction to performance tuning perl web applicationsIntroduction to performance tuning perl web applications
Introduction to performance tuning perl web applications
 
PyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to ProfilingPyGotham 2014 Introduction to Profiling
PyGotham 2014 Introduction to Profiling
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for Perl
 
Care and Feeding of Large Web Applications
Care and Feeding of Large Web ApplicationsCare and Feeding of Large Web Applications
Care and Feeding of Large Web Applications
 
Introduzione al web marketing
Introduzione al web marketingIntroduzione al web marketing
Introduzione al web marketing
 
Hanh phuc
Hanh phucHanh phuc
Hanh phuc
 
Top 10 Perl Performance Tips
Top 10 Perl Performance TipsTop 10 Perl Performance Tips
Top 10 Perl Performance Tips
 

Similar a Scaling Databases with DBIx::Router

Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDB
MongoDB
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
chuvainc
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
MongoDB
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 

Similar a Scaling Databases with DBIx::Router (20)

Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
DataMapper
DataMapperDataMapper
DataMapper
 
About Data::ObjectDriver
About Data::ObjectDriverAbout Data::ObjectDriver
About Data::ObjectDriver
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
 
Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDB
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
 
Kerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit eastKerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit east
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
Drupal II: The SQL
Drupal II: The SQLDrupal II: The SQL
Drupal II: The SQL
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
Dynomite Nosql
Dynomite NosqlDynomite Nosql
Dynomite Nosql
 
2013 london advanced-replication
2013 london advanced-replication2013 london advanced-replication
2013 london advanced-replication
 
Slow Database in your PHP stack? Don't blame the DBA!
Slow Database in your PHP stack? Don't blame the DBA!Slow Database in your PHP stack? Don't blame the DBA!
Slow Database in your PHP stack? Don't blame the DBA!
 
Php summary
Php summaryPhp summary
Php summary
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013
 

Más de Perrin Harkins

Más de Perrin Harkins (8)

Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Scalable talk notes
Scalable talk notesScalable talk notes
Scalable talk notes
 
Low maintenance perl notes
Low maintenance perl notesLow maintenance perl notes
Low maintenance perl notes
 
Building Scalable Websites with Perl
Building Scalable Websites with PerlBuilding Scalable Websites with Perl
Building Scalable Websites with Perl
 
Efficient Shared Data in Perl
Efficient Shared Data in PerlEfficient Shared Data in Perl
Efficient Shared Data in Perl
 
Choosing a Templating System
Choosing a Templating SystemChoosing a Templating System
Choosing a Templating System
 
Low-Maintenance Perl
Low-Maintenance PerlLow-Maintenance Perl
Low-Maintenance Perl
 
The Most Common Template Toolkit Mistake
The Most Common Template Toolkit MistakeThe Most Common Template Toolkit Mistake
The Most Common Template Toolkit Mistake
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Scaling Databases with DBIx::Router

  • 1. Scaling Databases with DBIx::Router Perrin Harkins We Also Walk Dogs
  • 3. Why would you need this? Web and app servers are easy to scale Just add another dozen boxes
  • 4. Why would you need this? Databases not so much Big iron Commercial clustering solutions Human sacrifice
  • 5. Advice from Experts Brad Fitzpatrick, Cal Henderson, Jeremy Zawodny “Inside LiveJournal’s Backend” “Building Scalable Websites” and Derek J Balling, “High Performance MySQL”
  • 6. Caching Keep your hot data in a fast cache You get this one for free, thanks to DBI::Gofer Can use Cache::FastMmap, memcached, etc. through CHI
  • 7. Read-only Copies Replication to local server or remote slaves Be careful of replication lag (from MySQL 5.1 docs)
  • 8. Sharding Large data is split across multiple machines Users A-L, M-Z Logs by month Consistent hashing algorithm May involve directory server JOINs are now the programmer’s problem
  • 9. This is going to mean a custom database layer And rewriting all your old code to use it DBIx::Router tries to separate this plumbing
  • 10. Shoulders of Giants Enter DBI::Gofer “A scalable stateless proxy architecture for DBI” Bundles up requests, sends them over a transport, executes them, sends back results
  • 11. Shoulders of Giants Used by shopzilla.com and petfinder.com to pool connections Lots of good stuff like caching, timeouts, tracing DBIx::Router is a Gofer transport But it executes the calls locally
  • 12. Shoulders of Giants CPAN makes everything easy SQL::Statement parses SQL (!) Config::Any solves the XML problem
  • 13. How does it work? DataSources Individual (DSNs) or Group Group handles failover Also load-balancing
  • 14. Single DataSource { name => 'Master1', dsn => 'dbi:Pg:dbname=lolcats', user => ‘icanhas’, password => ‘ch33zeburger’, },
  • 15. Group DataSource { name => 'ReadCluster', class => 'random', datasources => [ ‘Slave1’, ‘Slave2’ ], },
  • 16. Group DataSource { name => 'ReadCluster', class => 'roundrobin', datasources => [ ‘Slave1’, ‘Slave2’ ], },
  • 17. Group DataSource { name => 'ReadCluster', class => 'roundrobin', datasources => [ ‘Slave1’, ‘Slave2’ ], failover => 1, timeout => 8, },
  • 18. Group DataSource { name => 'ReadWriteCluster', class => 'repeater', datasources => [ ‘Master1’, ‘Master2’ ], },
  • 19. Group DataSource { name => 'StoreShards', class => 'shard', type => 'list', table => 'orders', column => 'store_id', shards => [ { values => [ 1, 3, 5 ], datasource => 'EastCoast', }, { values => [ 2, 4, 6 ], datasource => 'WestCoast', }, ], },
  • 20. Subclass DataSources Custom auth schemes for the paranoid Ye olde insane load-balancing scheme Shards with a directory server
  • 21. Rules Map queries to DataSources Organized in RuleLists Most specific to least Can fall back to pass-through
  • 22. Rule: regex { class => 'regex', datasource => 'ReadCluster', match => ['^ s* SELECT b '], not_match => ['b FOR s+ UPDATE b '], },
  • 23. Rule: readonly { class => 'readonly', datasource => 'ReadCluster', },
  • 24. Rule: parser { class => 'parser', match => [ { structure => 'tables', operator => 'all', tokens => ['order_history’] }, }, Operators: all, any, none, only Structures: command, tables, columns
  • 25. Rule: not { class => 'not', rule => { class => ‘readonly’ } datasource => 'Master1', },
  • 26. Rule: default { class => 'default', datasource => 'Master1', },
  • 27. { datasources => [ { name => 'Master1', dsn => 'dbi:mysql:dbname=lolcats', user => undef, password => undef, }, { name => 'Slave1', dsn => 'dbi:mysql:dbname=zomg1', user => undef, password => undef, }, { name => 'Slave2', dsn => 'dbi:mysql:dbname=zomg2', user => undef, password => undef, }, { name => 'ReadCluster', class => 'random', datasources => [ 'Slave1', 'Slave2', ], failover => 1, timeout => 8, }, ], rules => [ { class => 'readonly', datasource => 'ReadCluster', }, { class => 'default', datasource => 'Master1', }, ], }
  • 28. How do you run it? DBI_AUTOPROXY=”dbi:Gofer: transport=DBIx::Router; conf=/path/to/conf.pl” $dbh = DBI->connect("dbi:Gofer: transport=DBIx::Router; conf=/path/to/conf.pl; dsn=$original_dsn", $user, $passwd, %attributes);
  • 29. What’s the bad news? AutoCommit But Tim plans to fix that No streaming results Also fixable Failover and sharding are tough to generalize
  • 30. Status Hosted on Google Code Mostly there, but some bits need work Sharding Failover Needs user feedback Needs more tests
  • 31. Future Directions Make routing decisions optionally sticky Support explicit hints in method call attributes Helps with sharding Workaround for tricky queries that fool SQL::Parser
  • 33. What else is out there? Mostly faux DBD drivers DBD::Multi DBD::Multiplex DBIx::HA DBI::Role