Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Membase | Membase Server 1.6.x

What is the best way to communicate with membase servers

18 replies [Last post]
  • Login or register to post comments
Wed, 01/19/2011 - 14:00
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

I have 2 loadbalanced frontend servers running PHP and Membase running in the backend as a DB cluster (not yet but soon to come).

Can any of you advice as to what is the prefered way to communicate from PHP to backend. I have heard of Moxi client side (smart client I think) is that the way to go or should the communication be handled by PHP as a sort of random connection to various Membase node in the backend to provide loadbalancing.

In either case do any of you have some examples (Moxi / PHP), as I have not found any examples myself.

Thanks in advance :)

Top
  • Login or register to post comments
Thu, 01/20/2011 - 11:00
bhawana@membase
Offline
Joined: 10/29/2010
Groups: None

There are php  clients for membase available that you can use. The php client uses client side moxi which  routes the requests to the right membase node. This is the recommended method to connect to Membase. You may read more about client side moxi here:

http://wiki.membase.org/display/membase/Client+Libraries#ClientLibraries...

You can choose to use the following php  client:

http://pecl.php.net/package/memcached

The documentation for the php memcached client is here:

http://us.php.net/memcached

If you want to understand what goes on under the hoods with moxi, you can read:

http://wiki.membase.org/display/membase/Moxi

Please let me know if you have further questions.

Bhawana

 

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Membase: http://www.membase.com/products-and-services/overview
Call or email "sales -at- membase -dot- com" today!

Top
  • Login or register to post comments
Sat, 01/22/2011 - 04:46
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

Hi

Thanks for your info.

I tried to first install libmemcached doing this:

extracted http://launchpad.net/libmemcached/1.0/0.44/+download/libmemcached-0.44.t...

and then build and install:

./configure
make
make install

... and for some time the installation seems to proceed smoothly but then suddeenly stops with these lines:

checking for memcached... no
configure: error: "could not find memcached binary"
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.
 

Also installing Memcache does not succeed when building and installing PHP extension with:

phpize
./configure
make
make install

... again the installation proceeds smoothly untill this appears:

checking for memcached igbinary support... disabled
checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.
 

... so it seems each installation requires the other to be installed first, what to do different?

Thanks in advance :)

 

 

 

 

Top
  • Login or register to post comments
Mon, 01/24/2011 - 11:09
bhawana@membase
Offline
Joined: 10/29/2010
Groups: None

Try this if you want to installl libmemcached:


You will need libevent installed before you can install memvcached :


wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz

tar -xvf libevent-1.4.13-stable.tar.gz

cd libevent-1.4.13-stable

./configure

make

make install

 

wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz

gunzip memcached-1.4.5.tar.gz

tar -xvf memcached-1.4.5.tar

cd memcached-1.4.5

./configure

 

Now install libmemcached.

 

Please let me know how it goes.

 

Bhawana

 

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Membase: http://www.membase.com/products-and-services/overview
Call or email "sales -at- membase -dot- com" today!

Top
  • Login or register to post comments
Tue, 01/25/2011 - 04:39
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

Hi

I got it working with a --without_memcached (I think it was) to the
./configure for the libmemcached so now I have installed libmemcached
and memcached and made a memcached.so for PHP.

After reading about Moxi http : // wiki . membase . org / display / membase / Moxi (sorry about the space - if not present i can not submit) I believe that the PHP memcached.so extension is making use of the client side
Moxi server is that not true? And because of that the best way to
communicate with backend Membase servers is to let Moxi handle all
this itself through the PHP extension, like this:

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

Moxi should know all about open connections in the pool and then
choose wisely among them is that not true. Will this equal
loadbalancing, ie. distributing read and writes among the backend
membase nodes?

My key question is - how will the
memcached.so/Moxi know about the
nodes in the cluster - I assmune this is done as a intialization
process of some sort but where? In the PHP code or maybe on the
commandline for Moxi?

Top
  • Login or register to post comments
Wed, 01/26/2011 - 11:20
perry
Offline
Joined: 10/11/2010
Groups:

You configure Moxi to know about the cluster, and then it will loadbalance and route the requests to the appropriate node.  Check out this link for instructions on how to configure Moxi: http://wiki.membase.org/display/membase/Standalone+Moxi+Component

 

Perry

 

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Thu, 01/27/2011 - 05:16
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

thanks for answering....

ok so I would have to download Moxi? I thought it was a part of the PHP client memcached.so

But is it not possible to do it like so to add servers to the cluster?

$m = new Memcached();
$m->addServers(array(
    array('mem1.domain.com', 11211, 20),
    array('mem2.domain.com', 11311, 80),
));
var_dump($m->getServerList());

But then perhaps all the benefits the Moxi client gives like loadbalancing?

Top
  • Login or register to post comments
Fri, 01/28/2011 - 00:29
perry
Offline
Joined: 10/11/2010
Groups:

 Yes, Moxi is a separate process that allows you to connect to a Membase server to get dynamic load balancing as well as client-side connection pooling (especially useful for php applications).

 

You can actually add the Membase servers exactly the way you have them and it will function just fine.  The difference is that performance may be a bit degraded under high loads since you're actually going through a Moxi process on each of those servers and it may be generating an extra network hop if it needs to retrieve data from a server other than the one that you generated the request to.  You'd also have to keep your client config up-to-date to best load balance across multiple servers whereas a client-side Moxi will allow you to dynamically add or remove servers without changing any configuration.

 

Hope that helps, let me know if there's anythign else I can do for you.

 

Perry

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Fri, 01/28/2011 - 08:08
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

Ok so Moxi is installed and I have supplied the REST URLS to backend servers like:

./moxi RESTURL1,RESTURL2

Will the moxi server process continue in the background if I exit with ctrl C?

When trying to call Memcached::connect(localhost,11211) it gives an error saying the connect method does not exist and I can see that it does not - how will I communicate with Moxi from PHP?

Thanks

 

Top
  • Login or register to post comments
Fri, 01/28/2011 - 09:43
perry
Offline
Joined: 10/11/2010
Groups:

 No, you will need to leave Moxi running...either in that terminal or more likely as a background process.  We've got an upcoming feature to turn it into a service.

 

Once you get Moxi up and running you should be able to do a quick test by telnetting to localhost on port 11211 and typing 'stats'.  If you get our memcached-style stats output then  you know it is working.  From there, we can investigate why your PHP is unable to connect.

 

By the way, have you looked into simply install the pecl-memcache or pecl-memcached (I know, confusing right?) extension rather than compiling and setting it up yourself?

 

Perry

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Fri, 01/28/2011 - 13:40
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

I can confirm that the Moxies are now running as background processes and i can Telnet them and with stats get some output.

$m = new Memcached();
$m->connect('localhost', 11211) or die ("Could not connect");
 

...and I get:

Fatal error: Call to undefined method Memcached::connect()

But true the connect method is not defined here http : // dk . php . net / manual / en / class . memcached . php so I understand the error but then how to connect?

I really appreciate all the help here it has been a great help so far.

Thanks.

 

 

 

 

Top
  • Login or register to post comments
Sun, 01/30/2011 - 15:09
perry
Offline
Joined: 10/11/2010
Groups:

 I'll have to look into this a bit deeper for you.   Are you able to install the pecl-memcache or pecl-memcached extension?

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Mon, 01/31/2011 - 16:19
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

Hi


 


No need, first off as stated earlier there is no connect method for the Memcached class (the one I have installed and not Memcache) so I thought I would have to use:


$m = new Memcached();
$m->addServer('localhost', 11211) or die ("Could not connect");
 


... and it worked - that way I can use the Moxi Server clientside and I guess all the benefits like loadbalancing, shortest way to a Membase node, perhaps also the abality to cache, or maybe taht is only Memcache?


I still do not know how to run the Moxi server as a background process - I have heard of "fork" once, but do you know how?


Thanks.

Top
  • Login or register to post comments
Mon, 01/31/2011 - 19:20
perry
Offline
Joined: 10/11/2010
Groups:

 Moxi will work with both Membase buckets and memcached buckets, but you only get the advantages of persistence, replication and dynamic scalability with Membase buckets.  A Membase bucket includes an in-memory cache that is transparent to the user for performance reasons, but acts like a database.

 

You can run Moxi in the background using a variety of different ways.  The simplest is to put an '&' at the end of the command.  You can also run it inside a 'screen' process, use 'nohup' or start it with the '&' in your linux startup scripts.  

 

We will be releasing Moxi as an actual service in an upcoming release.

 

Perry

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Wed, 02/02/2011 - 01:56
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

Hi Perry

Thanks again for great help.

I must admit that I'm a bit confused now so in order to have the entire setup in overview:

Frontend

http://launchpad.net/libmemcached/1.0/0.44/+download/libmemcached-0.44.t... (bulid and installed)

pecl install memcached

sudo dpkg -i moxi-server_x86_1.6.5.deb

Backend

sudo dpkg -i membase-server-community_x86_64_1.6.4.1.deb

You mention "Moxi will work with both Membase buckets and memcached buckets, but you only get the advantages of persistence, replication and dynamic scalability with Membase buckets" - is it not a matter of what is passed as argument with ./moxi RESTURL1 ? If so the resturl represent the membase bucket which in my case is the default one - or am I missing something

Regarding the background process, yes I tried the ampersand in the end on the commandline but I also noticed that I was not able to connect to Moxi from php as soon as I closed the terminal. So it seems that it only is a background process as long as you have a terminal running - off course it should continue running even if I close the terminal. So I looked around and found nohup (no hang up) which seems to work fine.

By the way a latency of 10.3 milliseconds between client and membase is that considered high?

Thanks.

Top
  • Login or register to post comments
Wed, 02/02/2011 - 15:14
perry
Offline
Joined: 10/11/2010
Groups:

 Yes, the RESTURL to Moxi determines which bucket it connects to.  If you have the default bucket setup as a Membase bucket, then you should be fine and get all the advantages there.

 

Glad to see you were able to get the nohup working.

 

That high of a latency is extremely high and definitely not expected at all.  Is that what you are seeing for requests or have you monitored that in some other way?

 

Perry

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Wed, 02/02/2011 - 23:53
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

The latency is measured with ping and may not serve as the right tool. The thing is I have the frontend placed with one datacenter and backend with another datacenter. The datacenters are not far from each other (same city).

What latency would you expect?

Thanks

Top
  • Login or register to post comments
Thu, 02/03/2011 - 16:12
perry
Offline
Joined: 10/11/2010
Groups:

 Yes, going to a second datacenter would certainly increase the latency.  I imagine you're going through multiple routers rather than staying within a single subnet?  In general, Membase works best under relatively low latency (below 1ms) but if your application can sustain the latency then Membase will happily serve the data.  

 

Is there better latency BETWEEN Membase nodes?  That will be desired for replication and cluster stability.  10ms is not horrible, but that's under ideal conditions and if it starts to grow the Membase cluster may experience problems.

 

Perry

__________________

Forum support is great for free but sometimes you need a guaranteed response time and dedicated resources for your questions or issues.
Consider purchasing enterprise-level support from Couchbase: http://www.couchbase.com/products-and-services/overview
Call or email "sales -at- couchbase-dot- com" today!

Top
  • Login or register to post comments
Thu, 02/03/2011 - 16:29
membaseuser_dk
Offline
Joined: 01/13/2011
Groups: None

I did a ping between 2 nodes and there is an average fo 0.596 ms.

Thank you Perry so much for taking your time all questions :)

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