Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reduce number of connections to one cluster node by shuffling nodes. #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

vstepanyuk
Copy link

No description provided.

@michael-grunder
Copy link
Member

Hey,

The logic is now merged in the branch shuffle-seeds so if you wouldn't mind testing it that would be great. Once it seems good i'll merge it into develop and php7.

I made some modifications to your pull request but not too much:

  • I made the seed shuffling it's own function as it keeps init_cluster_seeds focused on just that task.
  • Modified the logic of the shuffle & pick itself.

The way you randomized the seeds was to create an array from 0-N and then make it random. Then, once in the loop did this:

if (zend_hash_index_find(ht_seeds, seeds[i], (void**)&z_seed) != SUCCESS)  {
    continue;
}

The issue with that is that this is PHP, so the user could happily pass us:

$arr_seeds = ['myFancyServer' => $fancy_host, 'otherthing' => $other_host];

So all I did is change the logic such that I extract everything in the seeds array then use the same strategy you did, only operating on the extracted data, rather than the hash table itself.

Thanks again for your help!

Mike

@vstepanyuk
Copy link
Author

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants