PHP SDK failover handling
I'm trying to understand how the SDK handles failover. Manual says the following but it is not completely clear to me:
http://www.couchbase.com/docs/couchbase-sdk-php-1.1/api-reference-connec...
Create a connection to Couchbase Server with given parameters, such as node URL. Most SDKs accept a list of possible URL's to avoid an error in case one node is down. After initial connection a Couchbase Client uses node topology provided by Couchbase Server to reconnect after failover or rebalance.
For example, if you have a 2 node Couchbase v2.0 server cluster - 1.1.1.1 and 2.2.2.2. I connect via:
$cb = new Couchbase("1.1.1.1:8091", "user", "pass", true);
1.1.1.1 goes down. Does the couchbase sdk persist the topology info in static memory/apc or something? so that when 1.1.1.1 is down it knows to connect to 2.2.2.2? Or do I have to specify the $URL as a list (as the comment suggests)?
Thx in advance. Couldn't really find clear answer on the forums, sorry if this is a dup (http://www.couchbase.com/forums/thread/server-crash-etc kinda touches on it)
OK. How is that specified in the $url param of the constructor? its not clear here: http://www.couchbase.com/docs/couchbase-sdk-php-1.1/api-reference-connec...
Is it $cb = new Couchbase("1.1.1.1:8091,1.1.1.2:8091", "user", "pass", true);?
If so the text for that param in the doc is a bit misleading: "URL for Couchbase Server Instance, or node.". It implies only 1 node can be specified.
Is it $cb = new Couchbase("1.1.1.1:8091,1.1.1.2:8091", "user", "pass", true);?
If so the text for that param in the doc is a bit misleading: "URL for Couchbase Server Instance, or node.". It implies only 1 node can be specified.
You may use:
$handle = couchbase_connect(“host1[:port][;host2[:port]]”); $handle = couchbase_connect(array(“host1[:port]”, “host2[:port]”));
(it is of course not limited to two hosts)
Thank you.
We'll get that clarified in the docs too, thanks!
When the PHP client is initialized, it initializes the underlying libcouchbase with the different "bootstrap" nodes. The nodes must be specified as a list to libcouchbase, so it knows where to go if the node it's currently getting the configuration from is unavailable.
This does mean you'll want to maintain this list as your nodes change over the course of time.