Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

PHP SDK failover handling

5 replies [Last post]
  • Login or register to post comments
Fri, 12/28/2012 - 07:38
rynop
Offline
Joined: 09/15/2011
Groups: None

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)

Top
  • Login or register to post comments
Fri, 12/28/2012 - 12:00
ingenthr
Offline
Joined: 03/16/2010
Groups:

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.

Top
  • Login or register to post comments
Fri, 12/28/2012 - 13:26
rynop
Offline
Joined: 09/15/2011
Groups: None

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.

Top
  • Login or register to post comments
Sun, 12/30/2012 - 01:45
trond
trond's picture
Offline
Joined: 03/15/2010
Groups: None

rynop wrote:
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.

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)

Top
  • Login or register to post comments
Mon, 12/31/2012 - 08:47
rynop
Offline
Joined: 09/15/2011
Groups: None

Thank you.

Top
  • Login or register to post comments
Mon, 12/31/2012 - 13:46
ingenthr
Offline
Joined: 03/16/2010
Groups:

We'll get that clarified in the docs too, thanks!

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker