View Source


h2. Types of Membase Clients

This section summarizes the 3 types of clients that can communicate with a Couchbase Server. The [Bucket types|http://www.couchbase.com/docs/couchbase-manual-1.8/couchbase-introduction-architecture-buckets.html] provides valuable background knowledge assumed on this page.


h3. Type 1: "Classic" Memcached clients (non-vBucket-aware)

Type 1 clients are not "vBucket aware." These are traditional memcached clients that distribute data across the cluster via a hashing algorithm that maps keys to one of a fixed number of servers in a server list stored in a configuration file. When adding and removing servers from a Memcached cluster, these clients typically require a change to the server configuration file. This change directly, and immediately upon client restart, impacts the mapping of keys to servers, moving some keys to new servers. This results in cache misses until data is repopulated in from the database to the cache.

Because Couchbase is a database, "misses" are unacceptable. To allow orderly transitions of cluster configuration and data, Type 1 clients communicate on the standard Memcached TCP port, which in Membase is serviced by Moxi - the membase proxy. The embedded Moxi Server forwards requests to the proper place.


h3. Type 2 Couchbase clients (vBucket-aware)

Type 2 clients use a layer of indirection between the hashing algorithm and the server list - mapping keys first to one of a fixed number of "vBuckets". This layer of indirection permits an orderly transition of data when cluster configuration is changed (servers added to or removed from the cluster). These clients communicate with Membase, by default, on port 11210.

Type 2 clients also make a connection to the [REST interface|http://www.couchbase.com/docs/couchbase-manual-1.8/couchbase-admin-restapi.html] of Membase in order to retrieve the cluster topology and vbucket map configuration.  This allows them to by dynamically updated when nodes are added/removed/failed over.

The [Couchbase .NET client|http://www.couchbase.com/develop/net/current] .NET client is an example of a Type 2 Couchbase client.

h3. Moxi (deployed client-side)

Moxi can be deployed on a client server, underneath a Type 1 memcached client. In this case, the Type 1 client is configured to communicate on port 11211 on localhost. Moxi receives all requests then forwards them to the appropriate server in the cluster.  In some cases, however, it is advantageous to use client-side Moxi to maintain persistent connections to Membase servers and to pool those connections. PHP applications frequently benefit from this architecture where processes come and go rapidly.

Client-side Moxi can also be useful if no Type 2 clients are available for a given language or application framework.

h2. Couchbase Recommended Clients

Memached is the most widely adopted distributed caching technology, with more languages and packaged client libraries supported than any other technology in its class.
*Couchbase works with all of these client-side technologies, enabling developers to use their tools of choice without any modification.*

For those who have yet to select a client library, Membase has vetted and tested a number of them and recommends those listed below.

Refer to [Couchbase Development|http://couchbase.com/wiki/display/couchbase/Couchbase+Development] to read more about the different types of Couchbase clients.