Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Madisoft Labs:
Doctrine sharding
Jun 19, 2017 @ 16:17:06

On the Madisoft Labs site they've posted a tutorial looking at how to split out your application's data into shards, showing how to do it using Doctrine in a Symfony application.

In the previous article we explored why sharding by tenant is a very good solution for us. In this article we dig into how to divide our Symfony app by shard. [...] We chose Doctrine as our ORM so let’s see what it offers to us.

First of all you have to note that Doctrine is composed mainly by two different parts: DBAL and ORM. ORM leverages DBAL functionalities and it’s completely transparent for sharding. DBAL is the layer we’re interested in.

The author then walks you through the configuration required to make the sharding work including default and a global connections. Next they show the creation of a ShardChoser class that reads a configuration option provided and pulls in the configuration that matches (from YAML files). Finally the ShardManager class is created to handle the connection pool that also includes a "query all" method allowing for the execution of the same SQL on all shards.

tagged: doctrine sharding shard configuration manager chooser tutorial

Link: https://labs.madisoft.it/doctrine-sharding/

Zend Developer Zone:
MySQLND, MySQL_UH and other goodies available to PHP programmers
Jan 26, 2011 @ 17:16:02

On the Zend Developer Zone today there's a new post from Cal Evans mentioning some goodies that are available to PHP programmers in the world of MySQL.

PHP 5.3 shipped with a new driver for MySQL, mysqlnd or MySQL Native Driver. While one of it's biggest features is that it gives us a mysql driver that is part of PHP so it doesn't suffer from licensing issues that the previous driver did. However, in the redesign, the architecture was changed.

He mentions the mysqlnd_uh that's a part of this new MySQL driver and an interesting article from Ulf Wendel about its use in transparent load balancing and sharding. The article includes code that randomly picks a MySQL server for the script to use.

The article is a bit difficult to read at time but trust me, stick with them because the stuff in there is the stuff you want in your head when you are working on your next application.
tagged: mysqlnd mysqluh nativedriver loadbalance shard mysql tutorial

Link:


Trending Topics: