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/

Johannes Schlüter:
Sharding PHP with MySQL Fabric
Oct 10, 2013 @ 13:30:16

Johannes Schlüter has a new post to his site today showing how to use the MySQL Fabric functionality to do sharding in your PHP application. The MySQL Fabric (recently released) is "an integrated environment for managing a farm of MySQL server supporting high-availability and sharding."

As this release of Fabric put the focus on sharding, this is what I want to show here, too. A general introduction to MySQL Fabric and its sharding features can be found on VN's blog so I'll be quite fast in some areas, for details please refer to the documentation and the mentiond blogs.

He walks you through the installation of the support for Fabric and how to configure it for storage. He then creates some groupings/shards with the "mysqlfabric" command line tool and sets up the sharding rules. Next up is the installation of the mysqlnd_ms extension for PHP and configuring it via a JSON file and in the php.ini. A sample test script is included showing how to create a table, insert a record and pull it back out from the sharded setup.

tagged: sharding mysql fabric tutorial install configure extension

Link: http://schlueters.de/blog/archives/175-Sharding-PHP-with-MySQL-Fabric.html

Derick Rethans:
Read Preferences wth the MongoDB PHP driver
Dec 20, 2012 @ 19:41:24

Derick Rethans has a new post to his site detailing some of the "read" preferences that you can customize in the latest versions of the MongoClient functionality in the MongoDB PHP extension for replica sets and sharing setups.

Read Preferences are a new Replica Set and Sharding feature implemented by most MongoDB drivers that are supported by 10gen. This functionality requires MongoDB 2.2. In short, Read Preferences allow you to configure from which nodes you prefer the driver reads data from. In a Replica Set environment it is the driver that does the selection of the preferred node, and in a Sharded environment it is the mongos process that routes queries according to the defined Read Preferences.

He starts with a look at the read preference types (like "primary", "secondary" and "nearest") how the connection manager works to handle each type. He includes some code samples showing how to configure your MongoClient connections to use these various types of preferences. He also introduces the concept of "tags" for the replica set - aliases to make them a bit easier to identify when making a connection and how to define them in the connection string.

tagged: mongodb mongoclient read preference replicaset sharding connection tutorial

Link:

Brian Swan's Blog:
Using SQL Azure Federations via PHP
Jan 20, 2012 @ 14:31:46

Brian Swan has a new post to his blog about using Azure Federations in your PHP applications:

In a nutshell, SQL Azure Federations introduces an abstraction layer for the sharding of SQL Azure databases. The value in federations lies in your ability to have elastic scalability of the database layer of your application (to match the elastic scalability of the rest of your application when it’s running in the cloud). And, one nice thing about the way federations work is that nearly everything can be done with simple SQL commands. Of course, that means that using SQL Azure Federations via PHP should be easy. So in this post, I’ll introduce you to SQL Azure federations by showing you how to use them via PHP.

He uses the SQL Server drivers to make the connection to the Azure instance and, based on his included code, creates a federation and tables inside it. He also shows how to insert data into these tables, split up a federation, insert data after this split and how to query a federation member with the filtering on or off.

tagged: azure federation tutorial windows sharding database

Link:

Oracle Technology Network:
Scaling a PHP MySQL Web Application, Part 2
Apr 12, 2011 @ 18:28:05

On the Oracle Technology Network today, the part two of "Scaling PHP MySQL Web Applications" (from Eli White) has been published. Part one can be found here.

In Part 1 of this article, I explained the basic steps to move your application from a single server to a scalable solution for both PHP and MySQL. While most Web applications will never need to expand beyond the concepts presented in that article, eventually you may find yourself in a situation where the basic steps aren’t enough. Here are some more advanced topics on how you might change your setup to support additional throughput, isolate "concerns" better, and take your scalability to the next level.

He starts with a look at database pooling and how it can not only help you on load balancing your application's resources but also in the caching of the requests. Different resources give different cache results and grouping those together makes life simpler (and faster) for your application. He also talks a a bit about sharding - vertical, manual horizontal and application level techniques.

tagged: scaling application mysql database sharding pooling performance

Link:


Trending Topics: