MySQL 5.6 Global Transaction IDs - Use case: (session) consistency

U
Ulf WendelSenior Software Engineer um Oracle
Ulf Wendel, Oracle


     MySQL 5.6
Global Transaction Ids
Use case: Consistency
   MySQL 5.6, PECL/mysqlnd_ms 1.3
The speaker says...
We need new database cluster-aware APIs in PHP.
Many of us use clusters for availability and performance
reasons. No matter what data storage solution, there is
hardly a one-fits-all solution.

Cluster-wide consistency varies by solution. Some
solutions, such as MySQL Replication, provide
different levels, depending on usage pattern. Our APIs
shall allow requesting any level needed.


Simplified consistency level definitions first before its
explained how Global Transaction Ids (GTIDs) fit in.
Strong consistency
All nodes have all the latest copies
  All cients see the latest (comitted) copies
  Synchronous



SET X = 1         MySQL Node


        MySQL Node            MySQL Node        GET X, X = 1
The speaker says...
In this presentation a cluster is considered to deliver
strong consistency if all nodes immediately serve the
latest comitted copies. Clients see each others
changes immediately. The nodes in the cluster are
synchronous. Use, if transactions don't allow for any
„fuzzyness“, for example, for financial or booking
transactions.


As will be shown, strong consistency is possible even in lazy
primary copy systems. It does not always require an eager
read-one, update-any design.
Session consistency
Some nodes have the latest copies
  A client reads his latest (comitted) copies
  Other clients may read old copies


 Client A
                         MySQL Node
SET X = 1

                                                  Client A
            MySQL Node           MySQL Node
                                                GET X, X = 1

              Client B

        GET X, X = 0
The speaker says...
Session consistency ensures that one client will be
able to read all his updates for the duration of a
session. Clients may or may not see comitted
transactions of each other immediately. A load
balancer must pick nodes appropriately.


This relaxed consistency level is good enough to please a
discussion forum user. The user will see his latest
contributions immediately.
It becomes unlikely that users resubmit their posts as they
are displayed immediately. However, other readers may not
see the very latest posts.
Eventual consistency
Nodes may or may not serve the latest copies
  Nodes may serve stale copies
  Nodes may not have copies at all



SET X = 1        MySQL Node



       MySQL Node          MySQL Node   GET X, X = 0



       GET X, NULL
The speaker says...
An eventual consistent node may or may not serve
the latest copy. In fact, there is no promise that a
particular copy is available from every node. Many
systems that default to eventual consistency reach strong
consistency over time. Eventually all nodes get
synchronized. This model is similar to that of a cache.


Eventual consistency is good enoug for browsing product
catalogs or other infrequently changing contents in areas
where stale data is acceptable. It is the default consistency
level with MySQL Replication. Whatever, why bother ?! Can't
vendors provide proper solutions?
Are vendors fooling you?
There is no one-fits-all replication solution
  The dangers of replication and a solution (Jim Gray, Pat
  Helland, 1996): a ten-fold increase in nodes and traffic
  gives a thousand fold increase in deadlocks or
  reconciliations
  CAP theorem (Eric Brewer, 2000): consistency,
  availability and paritition tolerance can't be achieved
  together
  … vendors are forced to offer compromises
  … vendors are faced with a highly complex problem
  … you are forced to know about consistency :-(
The speaker says...
I would love to stop talking about consistency. But
replication has limits. Keep on pushing but know the
limits. Every synchronous, update anywhere solution has a
scalability limit. Partitioning (sharding) only shifts the limits
and creates other issues (rebuilding aggregates). Until its
solved...
Applications shall state their QoS/consistency needs:
To allow vendors to relax consistency for performance
reasons, but only if feasible, if allowed by the app
To allow load balancers to make an optimal node choice


= PECL/mysqlnd_ms 1.2+ build around GTIDs...
PECL/mysqlnd_ms 1.2+ API
Tell the plugin/load balancer what you need!
/* Yes, works with PDO and mysql as well. */
$mysqli = new mysqli("myapp", "username", "password", "database");
/* read-write splitting: master used */
$mysqli->query("INSERT INTO orders(item) VALUES ('spring flowers')");
/* Request session consistency: read your writes */
mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION);
/* Plugin picks a node which has the changes, here: master */
$res = $mysqli->query("SELECT item FROM orders WHERE order_id = 1");
var_dump($res->fetch_assoc());
/* Back to eventual consistency: stale data allowed */
mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL);
/* Plugin picks any slave, stale data is allowed */
$res = $mysqli->query("SELECT item, price FROM specials");
The speaker says...
Because PECL/mysqlnd_ms is a load balancer at the driver
level, it can be controlled not only through SQL hints but
also provide API calls. mysqlnd_ms_set_qos() defines
the quality of service (QoS) that shall be provided. It
instructs the load balancer to select only MySQL
database cluster nodes that cen deliver the
requested quality of service, for example, with regards
to consistency.


Without GTIDs the rules for a MySQL Replication
cluster are simple: eventual consistency – any slave,
session and strong consistency – master only.
Global transaction identifier
Combination of server id and sequence number
  Emulation: PECL/mysqlnd_ms 1.2, MySQL Proxy
  Built-in: MySQL 5.6


                         MySQL Master

            Log 7, Pos 34, GTID M:1: UPDATE x=1
            Log 7, Pos 35, GTID M:2: UPDATE x=9


         MySQL Slave 1                  MySQL Slave 2

    … , GTID M:1: UPDATE x=1     … , GTID M:1: UPDATE x=1
    … , GTID M:2: UPDATE x=9
The speaker says...
A global transaction identifier is a cluster-wide
unique transaction identifier. MySQL 5.6 can generate it
automatically. MySQL Proxy and PECL/mysqlnd_ms 1.2
feature client-side emulations for use with any MySQL
version. SQL can be used to access the GTIDs.


GTIDs have been been created to make MySQL Replication
failover easier. However, they are useful for load balancing
as well in a primary copy system.
MySQL Replication: strong con.
With or without GTID: primary only
  Only the primary has all comitted transactions




 Client A                              Client B
                 MySQL Master
SET X = 1                            GET X, X = 1




        MySQL Slave         MySQL Slave
The speaker says...
Configuring PECL/mysqlnd_ms for use with a MySQL
Replication cluster and calling mysqlnd_ms_set_qos($conn,
MYSQLND_MS_QOS_CONSISTENCY_STRONG) instructs
PECL/mysqlnd_ms to use only the MySQL Replication
master server for requests.


In a lazy primary copy system there is only one node that is
guaranteed to have all comitted updates: the primary. Note
that its possible to achieve higher consistency levels than
eventual consistency in an lazy primary copy system by
appropriately choosing nodes.
MySQL Replication: session con.
  Use GTID to find „synchronous“ slave
     Check slave status using SQL
     Reduce read load on master

               SET X = 9         MySQL Master

                            ..., GTID M:1: UPDATE x=1
                            ..., GTID M:2: UPDATE x=9


GET X, X = 9        MySQL Slave 1               MySQL Slave 2

               … , GTID M:1: UPDATE x=1   … , GTID M:1: UPDATE x=1
               … , GTID M:2: UPDATE x=9
The speaker says...
Global transaction identifier help to find „up-to-date“
slaves that have already replicated the latest
updates of a client. Thus, session consistency can
now be achieved by reading from the master and
selected „up-to-date“ slaves.


This works with the GTID emulation of PECL/mysqlnd_ms
1.2 and any MySQL server version as well as with
PECL/mysqlnd_ms 1.3 (not yet released) and MySQL 5.6
with its built-in GTIDs.


Remember: only one API call for your PHP application...
MySQL Replication: eventual c.
With or without GTID: all slaves
  Optional QoS level: upper slave lag limit
  MySQL estimates slave lag!


               SET X = 9         MySQL Master



GET X, X = 8        MySQL Slave 1             MySQL Slave 2

                  Slave lag = 1 second   Slave lag = 7 seconds
The speaker says...
A MySQL Replication slave is eventual consistent – it
may or may not have the latest updates. There is no
need to filter nodes with regards to consistency.


However, slaves can be filtered by replication lag:
mysqlnd_ms_set_qos($conn,
MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL,
MYSQLND_MS_QOS_OPTION_AGE, 5) filters out all slaves
that report an estimated lag of more than five seconds.
Slave selection logic
Same logic whenever slaves are to be filtered
  applied for: session consistency + GTID
  applied for: eventual consistency + Lag
  Stage 1: send SQL to check status to all slaves
  Stage 2: fetch replies in order
  Stage 3: apply filter logic
  SQL is documented in the manual
The speaker says...
Whenever PECL/mysqlnd_ms has to check the slave status
for filtering slaves, the check is done in two stages. First, all
slaves are queried. Then, replies are fetched from the slaves
in order. Usually, many requests can be send out in stage
one before the servers reply.


The SQL details are documented at php.net/mysqlnd_ms.
Stateless and shared-nothing
PECL/mysqlnd_ms is a PHP solution
  Stateless: decisions are not „remembered“
  Shared-nothing: instances don't communicate
  Optional: user hooks to make statefull decisions
The speaker says...
Please recall, that we are talking about a PHP integrated
solution. By default PHP is stateless and promotes a shared-
nothing architecture.


PHP and PECL/mysqlnd_ms loose their state at the end of a
web request. State is neither persisted nor shared between
different processes. Thus, there is no single point of failure.


If you want PECL/mysqlnd_ms to remember decisions,
install user hooks and persist their decisions.
THE END


Contact: ulf.wendel@oracle.com
1 von 25

Recomendados

MySQL 5.6 Global Transaction Identifier - Use case: Failover von
MySQL 5.6 Global Transaction Identifier - Use case: FailoverMySQL 5.6 Global Transaction Identifier - Use case: Failover
MySQL 5.6 Global Transaction Identifier - Use case: FailoverUlf Wendel
2.2K views16 Folien
Vote NO for MySQL von
Vote NO for MySQLVote NO for MySQL
Vote NO for MySQLUlf Wendel
3.2K views61 Folien
DIY: A distributed database cluster, or: MySQL Cluster von
DIY: A distributed database cluster, or: MySQL ClusterDIY: A distributed database cluster, or: MySQL Cluster
DIY: A distributed database cluster, or: MySQL ClusterUlf Wendel
10.6K views81 Folien
The mysqlnd replication and load balancing plugin von
The mysqlnd replication and load balancing pluginThe mysqlnd replication and load balancing plugin
The mysqlnd replication and load balancing pluginUlf Wendel
3K views50 Folien
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011 von
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011
MySQL native driver for PHP (mysqlnd) - Introduction and overview, Edition 2011Ulf Wendel
2.4K views17 Folien
PHP mysqlnd connection multiplexing plugin von
PHP mysqlnd connection multiplexing pluginPHP mysqlnd connection multiplexing plugin
PHP mysqlnd connection multiplexing pluginUlf Wendel
11.2K views20 Folien

Más contenido relacionado

Was ist angesagt?

MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4 von
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4Ulf Wendel
8.5K views67 Folien
MySQL Group Replication von
MySQL Group ReplicationMySQL Group Replication
MySQL Group ReplicationUlf Wendel
33.1K views92 Folien
PoC: Using a Group Communication System to improve MySQL Replication HA von
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HAUlf Wendel
6.1K views46 Folien
Intro to PECL/mysqlnd_ms (4/7/2011) von
Intro to PECL/mysqlnd_ms (4/7/2011)Intro to PECL/mysqlnd_ms (4/7/2011)
Intro to PECL/mysqlnd_ms (4/7/2011)Chris Barber
7K views25 Folien
The PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy von
The PHP mysqlnd plugin talk - plugins an alternative to MySQL ProxyThe PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy
The PHP mysqlnd plugin talk - plugins an alternative to MySQL ProxyUlf Wendel
3K views75 Folien
MySQL 5.7 clustering: The developer perspective von
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveUlf Wendel
5.8K views85 Folien

Was ist angesagt?(20)

MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4 von Ulf Wendel
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
Ulf Wendel8.5K views
MySQL Group Replication von Ulf Wendel
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
Ulf Wendel33.1K views
PoC: Using a Group Communication System to improve MySQL Replication HA von Ulf Wendel
PoC: Using a Group Communication System to improve MySQL Replication HAPoC: Using a Group Communication System to improve MySQL Replication HA
PoC: Using a Group Communication System to improve MySQL Replication HA
Ulf Wendel6.1K views
Intro to PECL/mysqlnd_ms (4/7/2011) von Chris Barber
Intro to PECL/mysqlnd_ms (4/7/2011)Intro to PECL/mysqlnd_ms (4/7/2011)
Intro to PECL/mysqlnd_ms (4/7/2011)
Chris Barber7K views
The PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy von Ulf Wendel
The PHP mysqlnd plugin talk - plugins an alternative to MySQL ProxyThe PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy
The PHP mysqlnd plugin talk - plugins an alternative to MySQL Proxy
Ulf Wendel3K views
MySQL 5.7 clustering: The developer perspective von Ulf Wendel
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspective
Ulf Wendel5.8K views
Built-in query caching for all PHP MySQL extensions/APIs von Ulf Wendel
Built-in query caching for all PHP MySQL extensions/APIsBuilt-in query caching for all PHP MySQL extensions/APIs
Built-in query caching for all PHP MySQL extensions/APIs
Ulf Wendel3.4K views
Data massage: How databases have been scaled from one to one million nodes von Ulf Wendel
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodes
Ulf Wendel24.3K views
HTTP Plugin for MySQL! von Ulf Wendel
HTTP Plugin for MySQL!HTTP Plugin for MySQL!
HTTP Plugin for MySQL!
Ulf Wendel95.4K views
Award-winning technology: Oxid loves the query cache von Ulf Wendel
Award-winning technology: Oxid loves the query cacheAward-winning technology: Oxid loves the query cache
Award-winning technology: Oxid loves the query cache
Ulf Wendel3.2K views
Introduction to Galera von Henrik Ingo
Introduction to GaleraIntroduction to Galera
Introduction to Galera
Henrik Ingo9.6K views
MySQL Multi Master Replication von Moshe Kaplan
MySQL Multi Master ReplicationMySQL Multi Master Replication
MySQL Multi Master Replication
Moshe Kaplan19.9K views
MySQL Database Architectures - InnoDB ReplicaSet & Cluster von Kenny Gryp
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
Kenny Gryp2.6K views
Galera cluster for MySQL - Introduction Slides von Severalnines
Galera cluster for MySQL - Introduction SlidesGalera cluster for MySQL - Introduction Slides
Galera cluster for MySQL - Introduction Slides
Severalnines144.3K views
MySQL High Availability: Managing Farms of Distributed Servers (MySQL Fabric) von Alfranio Júnior
MySQL High Availability: Managing Farms of Distributed Servers (MySQL Fabric)MySQL High Availability: Managing Farms of Distributed Servers (MySQL Fabric)
MySQL High Availability: Managing Farms of Distributed Servers (MySQL Fabric)
Alfranio Júnior2.7K views
High-Availability using MySQL Fabric von Mats Kindahl
High-Availability using MySQL FabricHigh-Availability using MySQL Fabric
High-Availability using MySQL Fabric
Mats Kindahl4.8K views
Using and Benchmarking Galera in different architectures (PLUK 2012) von Henrik Ingo
Using and Benchmarking Galera in different architectures (PLUK 2012)Using and Benchmarking Galera in different architectures (PLUK 2012)
Using and Benchmarking Galera in different architectures (PLUK 2012)
Henrik Ingo3.9K views

Destacado

Cloud os and management overview of windows server 2012 and system center 2... von
Cloud os and management   overview of windows server 2012 and system center 2...Cloud os and management   overview of windows server 2012 and system center 2...
Cloud os and management overview of windows server 2012 and system center 2...☁️Carl Nakamura [MSFT]☁️
811 views60 Folien
Model based transaction-aware cloud resources management case study and met... von
Model based transaction-aware cloud resources management   case study and met...Model based transaction-aware cloud resources management   case study and met...
Model based transaction-aware cloud resources management case study and met...Leonid Grinshpan, Ph.D.
1.2K views39 Folien
SaaS Model in economic downturn von
SaaS Model in economic downturnSaaS Model in economic downturn
SaaS Model in economic downturnJitendra Maan
916 views18 Folien
MySQL Proxy: Architecture and concepts of misuse von
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuseweigon
1.5K views20 Folien
MySQL Fabric: High Availability using Python/Connector von
MySQL Fabric: High Availability using Python/ConnectorMySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/ConnectorVishal Yadav
1.1K views20 Folien
High Availability with MySQL von
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQLThava Alagu
4.7K views39 Folien

Destacado(19)

Model based transaction-aware cloud resources management case study and met... von Leonid Grinshpan, Ph.D.
Model based transaction-aware cloud resources management   case study and met...Model based transaction-aware cloud resources management   case study and met...
Model based transaction-aware cloud resources management case study and met...
SaaS Model in economic downturn von Jitendra Maan
SaaS Model in economic downturnSaaS Model in economic downturn
SaaS Model in economic downturn
Jitendra Maan916 views
MySQL Proxy: Architecture and concepts of misuse von weigon
MySQL Proxy: Architecture and concepts of misuseMySQL Proxy: Architecture and concepts of misuse
MySQL Proxy: Architecture and concepts of misuse
weigon1.5K views
MySQL Fabric: High Availability using Python/Connector von Vishal Yadav
MySQL Fabric: High Availability using Python/ConnectorMySQL Fabric: High Availability using Python/Connector
MySQL Fabric: High Availability using Python/Connector
Vishal Yadav1.1K views
High Availability with MySQL von Thava Alagu
High Availability with MySQLHigh Availability with MySQL
High Availability with MySQL
Thava Alagu4.7K views
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy! von ScaleBase
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase Webinar: Scaling MySQL - Sharding Made Easy!
ScaleBase1.6K views
MySQL Proxy. From Architecture to Implementation von Ronald Bradford
MySQL Proxy. From Architecture to ImplementationMySQL Proxy. From Architecture to Implementation
MySQL Proxy. From Architecture to Implementation
Ronald Bradford2.4K views
MySQL HA Solutions von Mat Keep
MySQL HA SolutionsMySQL HA Solutions
MySQL HA Solutions
Mat Keep4.9K views
MySQL Proxy. A powerful, flexible MySQL toolbox. von Miguel Araújo
MySQL Proxy. A powerful, flexible MySQL toolbox.MySQL Proxy. A powerful, flexible MySQL toolbox.
MySQL Proxy. A powerful, flexible MySQL toolbox.
Miguel Araújo3.3K views
MySQL High Availability Deep Dive von hastexo
MySQL High Availability Deep DiveMySQL High Availability Deep Dive
MySQL High Availability Deep Dive
hastexo1.4K views
MySQL High Availability and Disaster Recovery with Continuent, a VMware company von Continuent
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
Continuent1.8K views
MySQL Replication: What’s New in MySQL 5.7 and Beyond von Andrew Morgan
MySQL Replication: What’s New in MySQL 5.7 and BeyondMySQL Replication: What’s New in MySQL 5.7 and Beyond
MySQL Replication: What’s New in MySQL 5.7 and Beyond
Andrew Morgan17.7K views
ProxySQL - High Performance and HA Proxy for MySQL von René Cannaò
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
René Cannaò5.1K views
Using MySQL Fabric for High Availability and Scaling Out von OSSCube
Using MySQL Fabric for High Availability and Scaling OutUsing MySQL Fabric for High Availability and Scaling Out
Using MySQL Fabric for High Availability and Scaling Out
OSSCube715 views
Project Management Example von Moin Uddin
Project Management ExampleProject Management Example
Project Management Example
Moin Uddin1.9K views
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster von Olivier DASINI
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB ClusterMySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
Olivier DASINI2.3K views

Similar a MySQL 5.6 Global Transaction IDs - Use case: (session) consistency

Galera Cluster 3.0 Features von
Galera Cluster 3.0 FeaturesGalera Cluster 3.0 Features
Galera Cluster 3.0 FeaturesCodership Oy - Creators of Galera Cluster
3.1K views91 Folien
Introduction to Galera Cluster von
Introduction to Galera ClusterIntroduction to Galera Cluster
Introduction to Galera ClusterCodership Oy - Creators of Galera Cluster
4.6K views28 Folien
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices von
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesKenny Gryp
2.9K views74 Folien
MySQL HA with PaceMaker von
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMakerKris Buytaert
15.6K views49 Folien
Midwest PHP Presentation - New MSQL Features von
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesDave Stokes
104 views59 Folien
MySQL InnoDB Cluster HA Overview & Demo von
MySQL InnoDB Cluster HA Overview & DemoMySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & DemoKeith Hollman
239 views63 Folien

Similar a MySQL 5.6 Global Transaction IDs - Use case: (session) consistency(20)

MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices von Kenny Gryp
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
Kenny Gryp2.9K views
MySQL HA with PaceMaker von Kris Buytaert
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
Kris Buytaert15.6K views
Midwest PHP Presentation - New MSQL Features von Dave Stokes
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
Dave Stokes104 views
MySQL InnoDB Cluster HA Overview & Demo von Keith Hollman
MySQL InnoDB Cluster HA Overview & DemoMySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & Demo
Keith Hollman239 views
Distribute key value_store von drewz lin
Distribute key value_storeDistribute key value_store
Distribute key value_store
drewz lin431 views
Distribute Key Value Store von Santal Li
Distribute Key Value StoreDistribute Key Value Store
Distribute Key Value Store
Santal Li2.2K views
MySQL Replication Evolution -- Confoo Montreal 2017 von Dave Stokes
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
Dave Stokes612 views
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK) von Jean-François Gagné
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
Highly Available Load Balanced Galera MySql Cluster von Amr Fawzy
Highly Available Load Balanced  Galera MySql ClusterHighly Available Load Balanced  Galera MySql Cluster
Highly Available Load Balanced Galera MySql Cluster
Amr Fawzy551 views
Percona XtraDB 集群文档 von YUCHENG HU
Percona XtraDB 集群文档Percona XtraDB 集群文档
Percona XtraDB 集群文档
YUCHENG HU744 views
ConFoo MySQL Replication Evolution : From Simple to Group Replication von Dave Stokes
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Dave Stokes316 views
MySQL 101 PHPTek 2017 von Dave Stokes
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
Dave Stokes551 views
Mysqlnd, an unknown powerful PHP extension von julien pauli
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
julien pauli6.8K views
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension von Frederic Descamps
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
Frederic Descamps169 views
Software architecture for data applications von Ding Li
Software architecture for data applicationsSoftware architecture for data applications
Software architecture for data applications
Ding Li192 views
MySQL High Availability Solutions - Avoid loss of service by reducing the r... von Olivier DASINI
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
Olivier DASINI1K views

Más de Ulf Wendel

HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL von
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLUlf Wendel
41.9K views89 Folien
PHPopstar der PHP Unconference 2011 von
PHPopstar der PHP Unconference 2011PHPopstar der PHP Unconference 2011
PHPopstar der PHP Unconference 2011Ulf Wendel
2K views44 Folien
The power of mysqlnd plugins von
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd pluginsUlf Wendel
1.6K views72 Folien
Mysqlnd query cache plugin benchmark report von
Mysqlnd query cache plugin benchmark reportMysqlnd query cache plugin benchmark report
Mysqlnd query cache plugin benchmark reportUlf Wendel
870 views45 Folien
mysqlnd query cache plugin: user-defined storage handler von
mysqlnd query cache plugin: user-defined storage handlermysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handlerUlf Wendel
1.2K views48 Folien
Mysqlnd query cache plugin statistics and tuning von
Mysqlnd query cache plugin statistics and tuningMysqlnd query cache plugin statistics and tuning
Mysqlnd query cache plugin statistics and tuningUlf Wendel
1.6K views66 Folien

Más de Ulf Wendel(7)

HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL von Ulf Wendel
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQLHTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Ulf Wendel41.9K views
PHPopstar der PHP Unconference 2011 von Ulf Wendel
PHPopstar der PHP Unconference 2011PHPopstar der PHP Unconference 2011
PHPopstar der PHP Unconference 2011
Ulf Wendel2K views
The power of mysqlnd plugins von Ulf Wendel
The power of mysqlnd pluginsThe power of mysqlnd plugins
The power of mysqlnd plugins
Ulf Wendel1.6K views
Mysqlnd query cache plugin benchmark report von Ulf Wendel
Mysqlnd query cache plugin benchmark reportMysqlnd query cache plugin benchmark report
Mysqlnd query cache plugin benchmark report
Ulf Wendel870 views
mysqlnd query cache plugin: user-defined storage handler von Ulf Wendel
mysqlnd query cache plugin: user-defined storage handlermysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handler
Ulf Wendel1.2K views
Mysqlnd query cache plugin statistics and tuning von Ulf Wendel
Mysqlnd query cache plugin statistics and tuningMysqlnd query cache plugin statistics and tuning
Mysqlnd query cache plugin statistics and tuning
Ulf Wendel1.6K views
Mysqlnd Async Ipc2008 von Ulf Wendel
Mysqlnd Async Ipc2008Mysqlnd Async Ipc2008
Mysqlnd Async Ipc2008
Ulf Wendel14.2K views

Último

Digital Personal Data Protection (DPDP) Practical Approach For CISOs von
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOsPriyanka Aash
162 views59 Folien
Evaluation of Quality of Experience of ABR Schemes in Gaming Stream von
Evaluation of Quality of Experience of ABR Schemes in Gaming StreamEvaluation of Quality of Experience of ABR Schemes in Gaming Stream
Evaluation of Quality of Experience of ABR Schemes in Gaming StreamAlpen-Adria-Universität
38 views34 Folien
"Package management in monorepos", Zoltan Kochan von
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan KochanFwdays
34 views18 Folien
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue von
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
224 views7 Folien
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online von
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineShapeBlue
225 views19 Folien
CryptoBotsAI von
CryptoBotsAICryptoBotsAI
CryptoBotsAIchandureddyvadala199
42 views5 Folien

Último(20)

Digital Personal Data Protection (DPDP) Practical Approach For CISOs von Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash162 views
"Package management in monorepos", Zoltan Kochan von Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue von ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue224 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online von ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue225 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... von The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... von ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue108 views
"Surviving highload with Node.js", Andrii Shumada von Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays58 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue von ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue137 views
The Role of Patterns in the Era of Large Language Models von Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... von ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue120 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT von ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue208 views
Business Analyst Series 2023 - Week 4 Session 7 von DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10146 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... von ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue171 views
NTGapps NTG LowCode Platform von Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu437 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue von ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue152 views
The Power of Heat Decarbonisation Plans in the Built Environment von IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE84 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... von ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue162 views

MySQL 5.6 Global Transaction IDs - Use case: (session) consistency

  • 1. Ulf Wendel, Oracle MySQL 5.6 Global Transaction Ids Use case: Consistency MySQL 5.6, PECL/mysqlnd_ms 1.3
  • 2. The speaker says... We need new database cluster-aware APIs in PHP. Many of us use clusters for availability and performance reasons. No matter what data storage solution, there is hardly a one-fits-all solution. Cluster-wide consistency varies by solution. Some solutions, such as MySQL Replication, provide different levels, depending on usage pattern. Our APIs shall allow requesting any level needed. Simplified consistency level definitions first before its explained how Global Transaction Ids (GTIDs) fit in.
  • 3. Strong consistency All nodes have all the latest copies All cients see the latest (comitted) copies Synchronous SET X = 1 MySQL Node MySQL Node MySQL Node GET X, X = 1
  • 4. The speaker says... In this presentation a cluster is considered to deliver strong consistency if all nodes immediately serve the latest comitted copies. Clients see each others changes immediately. The nodes in the cluster are synchronous. Use, if transactions don't allow for any „fuzzyness“, for example, for financial or booking transactions. As will be shown, strong consistency is possible even in lazy primary copy systems. It does not always require an eager read-one, update-any design.
  • 5. Session consistency Some nodes have the latest copies A client reads his latest (comitted) copies Other clients may read old copies Client A MySQL Node SET X = 1 Client A MySQL Node MySQL Node GET X, X = 1 Client B GET X, X = 0
  • 6. The speaker says... Session consistency ensures that one client will be able to read all his updates for the duration of a session. Clients may or may not see comitted transactions of each other immediately. A load balancer must pick nodes appropriately. This relaxed consistency level is good enough to please a discussion forum user. The user will see his latest contributions immediately. It becomes unlikely that users resubmit their posts as they are displayed immediately. However, other readers may not see the very latest posts.
  • 7. Eventual consistency Nodes may or may not serve the latest copies Nodes may serve stale copies Nodes may not have copies at all SET X = 1 MySQL Node MySQL Node MySQL Node GET X, X = 0 GET X, NULL
  • 8. The speaker says... An eventual consistent node may or may not serve the latest copy. In fact, there is no promise that a particular copy is available from every node. Many systems that default to eventual consistency reach strong consistency over time. Eventually all nodes get synchronized. This model is similar to that of a cache. Eventual consistency is good enoug for browsing product catalogs or other infrequently changing contents in areas where stale data is acceptable. It is the default consistency level with MySQL Replication. Whatever, why bother ?! Can't vendors provide proper solutions?
  • 9. Are vendors fooling you? There is no one-fits-all replication solution The dangers of replication and a solution (Jim Gray, Pat Helland, 1996): a ten-fold increase in nodes and traffic gives a thousand fold increase in deadlocks or reconciliations CAP theorem (Eric Brewer, 2000): consistency, availability and paritition tolerance can't be achieved together … vendors are forced to offer compromises … vendors are faced with a highly complex problem … you are forced to know about consistency :-(
  • 10. The speaker says... I would love to stop talking about consistency. But replication has limits. Keep on pushing but know the limits. Every synchronous, update anywhere solution has a scalability limit. Partitioning (sharding) only shifts the limits and creates other issues (rebuilding aggregates). Until its solved... Applications shall state their QoS/consistency needs: To allow vendors to relax consistency for performance reasons, but only if feasible, if allowed by the app To allow load balancers to make an optimal node choice = PECL/mysqlnd_ms 1.2+ build around GTIDs...
  • 11. PECL/mysqlnd_ms 1.2+ API Tell the plugin/load balancer what you need! /* Yes, works with PDO and mysql as well. */ $mysqli = new mysqli("myapp", "username", "password", "database"); /* read-write splitting: master used */ $mysqli->query("INSERT INTO orders(item) VALUES ('spring flowers')"); /* Request session consistency: read your writes */ mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION); /* Plugin picks a node which has the changes, here: master */ $res = $mysqli->query("SELECT item FROM orders WHERE order_id = 1"); var_dump($res->fetch_assoc()); /* Back to eventual consistency: stale data allowed */ mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL); /* Plugin picks any slave, stale data is allowed */ $res = $mysqli->query("SELECT item, price FROM specials");
  • 12. The speaker says... Because PECL/mysqlnd_ms is a load balancer at the driver level, it can be controlled not only through SQL hints but also provide API calls. mysqlnd_ms_set_qos() defines the quality of service (QoS) that shall be provided. It instructs the load balancer to select only MySQL database cluster nodes that cen deliver the requested quality of service, for example, with regards to consistency. Without GTIDs the rules for a MySQL Replication cluster are simple: eventual consistency – any slave, session and strong consistency – master only.
  • 13. Global transaction identifier Combination of server id and sequence number Emulation: PECL/mysqlnd_ms 1.2, MySQL Proxy Built-in: MySQL 5.6 MySQL Master Log 7, Pos 34, GTID M:1: UPDATE x=1 Log 7, Pos 35, GTID M:2: UPDATE x=9 MySQL Slave 1 MySQL Slave 2 … , GTID M:1: UPDATE x=1 … , GTID M:1: UPDATE x=1 … , GTID M:2: UPDATE x=9
  • 14. The speaker says... A global transaction identifier is a cluster-wide unique transaction identifier. MySQL 5.6 can generate it automatically. MySQL Proxy and PECL/mysqlnd_ms 1.2 feature client-side emulations for use with any MySQL version. SQL can be used to access the GTIDs. GTIDs have been been created to make MySQL Replication failover easier. However, they are useful for load balancing as well in a primary copy system.
  • 15. MySQL Replication: strong con. With or without GTID: primary only Only the primary has all comitted transactions Client A Client B MySQL Master SET X = 1 GET X, X = 1 MySQL Slave MySQL Slave
  • 16. The speaker says... Configuring PECL/mysqlnd_ms for use with a MySQL Replication cluster and calling mysqlnd_ms_set_qos($conn, MYSQLND_MS_QOS_CONSISTENCY_STRONG) instructs PECL/mysqlnd_ms to use only the MySQL Replication master server for requests. In a lazy primary copy system there is only one node that is guaranteed to have all comitted updates: the primary. Note that its possible to achieve higher consistency levels than eventual consistency in an lazy primary copy system by appropriately choosing nodes.
  • 17. MySQL Replication: session con. Use GTID to find „synchronous“ slave Check slave status using SQL Reduce read load on master SET X = 9 MySQL Master ..., GTID M:1: UPDATE x=1 ..., GTID M:2: UPDATE x=9 GET X, X = 9 MySQL Slave 1 MySQL Slave 2 … , GTID M:1: UPDATE x=1 … , GTID M:1: UPDATE x=1 … , GTID M:2: UPDATE x=9
  • 18. The speaker says... Global transaction identifier help to find „up-to-date“ slaves that have already replicated the latest updates of a client. Thus, session consistency can now be achieved by reading from the master and selected „up-to-date“ slaves. This works with the GTID emulation of PECL/mysqlnd_ms 1.2 and any MySQL server version as well as with PECL/mysqlnd_ms 1.3 (not yet released) and MySQL 5.6 with its built-in GTIDs. Remember: only one API call for your PHP application...
  • 19. MySQL Replication: eventual c. With or without GTID: all slaves Optional QoS level: upper slave lag limit MySQL estimates slave lag! SET X = 9 MySQL Master GET X, X = 8 MySQL Slave 1 MySQL Slave 2 Slave lag = 1 second Slave lag = 7 seconds
  • 20. The speaker says... A MySQL Replication slave is eventual consistent – it may or may not have the latest updates. There is no need to filter nodes with regards to consistency. However, slaves can be filtered by replication lag: mysqlnd_ms_set_qos($conn, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL, MYSQLND_MS_QOS_OPTION_AGE, 5) filters out all slaves that report an estimated lag of more than five seconds.
  • 21. Slave selection logic Same logic whenever slaves are to be filtered applied for: session consistency + GTID applied for: eventual consistency + Lag Stage 1: send SQL to check status to all slaves Stage 2: fetch replies in order Stage 3: apply filter logic SQL is documented in the manual
  • 22. The speaker says... Whenever PECL/mysqlnd_ms has to check the slave status for filtering slaves, the check is done in two stages. First, all slaves are queried. Then, replies are fetched from the slaves in order. Usually, many requests can be send out in stage one before the servers reply. The SQL details are documented at php.net/mysqlnd_ms.
  • 23. Stateless and shared-nothing PECL/mysqlnd_ms is a PHP solution Stateless: decisions are not „remembered“ Shared-nothing: instances don't communicate Optional: user hooks to make statefull decisions
  • 24. The speaker says... Please recall, that we are talking about a PHP integrated solution. By default PHP is stateless and promotes a shared- nothing architecture. PHP and PECL/mysqlnd_ms loose their state at the end of a web request. State is neither persisted nor shared between different processes. Thus, there is no single point of failure. If you want PECL/mysqlnd_ms to remember decisions, install user hooks and persist their decisions.