php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66064 random once load balancer ignoring weights
Submitted: 2013-11-08 14:43 UTC Modified: 2014-02-28 11:15 UTC
From: skunk at legalise dot it Assigned: uw (profile)
Status: Closed Package: mysqlnd_ms (PECL)
PHP Version: 5.4.21 OS: linux
Private report: No CVE-ID: None
 [2013-11-08 14:43 UTC] skunk at legalise dot it
Description:
------------
hi,
i'm running php-fpm with mysql master-master backends (one worker and one backup).
as suggested by the documentation (http://php.net/manual/en/mysqlnd-ms.supportedclusters.php) i've disabled r/w splitting and enabled multi master support.
it's also suggested to use random once load balancing strategy and since i want one worker and one backup backend, i wrote this configuration file:

{
        "spin": {  
                "master": {
                        "master1": {  
                                "host": "192.168.10.212",
                                "port": 3306  
                        },
                        "master2": {  
                                "host": "192.168.10.213",
                                "port": 3306  
                        }
                },  
                "slave": {
                },  
                "filters": {
                        "random": {  
                                "sticky": "1",
                                "weights": {
                                        "master1": 65535,  
                                        "master2": 1
                                }  
                        }
                },  
                "failover": {
                        "strategy": "loop_before_master",  
                        "remember_failed": true
                }  
        }
}  

unfortunately it's not working as expected since the weights values are ignored if sticky is present (query are distributed 50/50 on both backends), indeed it works as expected when sticky is removed...
i know that with two servers where just one is serving queries at time the sticky parameter doesn't make much sense, but in the future, when the load on the mysql backends rises, i'm planning to scale by adding new master nodes in circular replication, so by that time the sticky parameter will became more relevant...


Expected result:
----------------
weight balanced distribution even on random once

Actual result:
--------------
with random once queries get distributed 50/50 on all backends regardless their weight

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-27 15:24 UTC] uw@php.net
Hmm, this might be a simple parse/setup error. Config parsing seems buggy, I'm having a look...
 [2014-02-28 10:37 UTC] uw@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&revision=332901
Log: Bug #66064
 [2014-02-28 11:15 UTC] uw@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: uw
 [2014-02-28 11:15 UTC] uw@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Quite sure its fixed, it was a tiny config parsing bug.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Jul 04 19:01:16 2020 UTC