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

Do I need HAProxy in front of Couchbase?

6 replies [Last post]
  • Login or register to post comments
Sun, 12/16/2012 - 02:24
Peter Karlsson
Offline
Joined: 12/16/2012
Groups: None

The project I am working on is a image database and it's written in PHP. I use MySQL as the database. I want to use Couchbase instead so I can build a cluster in an easy way. I have installed Couchbase on a couple of Mac Minis and one iMac and it's extremely easy to build, I absolutely love it. I have not managed to install Couchbase SDK PHP support yet but I will soon get the hang of it.

I apologize if this is a stupid question but I am still learning and to make it even harder, english is not my native language :-)

Lets say that I have 4 Mac minis in the cluster. Do I need HAProxy in front these 4 Mac Minis? Should I have my PHP scripts on every Mac mini in the cluster?

I also wonder where my images should be located? Today it's several thousand of high resolution images and it will increase fast. Should I use a separate external harddrive for all Mac minis with the same images or should I have a single NAS that all Mac minis in the cluster can access?

Top
  • Login or register to post comments
Sun, 12/16/2012 - 15:17
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello

The short answer is No you do not need an HA Proxy in front of Couchbase (between your application and Couchbase)

So when using Couchbase from your PHP application you are using the Client SDK ( http://www.couchbase.com/develop/php/current ). This Client Library (and it is true in other languages too) is "cluster aware", so when you do operations (inserting/getting data) from your application it always go to the correct node of your cluster.

When something change in the cluster (new nodes added, failover, ...) the client library is automatically alerted of this change.

What is important to understand is that Couchbase supports "auto-sharding" based on the key you are using to store the document/data. The client API put the data on 1 single node (selected using a hash function of the key), and the server is responsible to create replicas (from 1 to 3 on the different node). But "all the data" are not on "all nodes" (when you have more nodes that your number of replicas)

You can find interesting information here:
- http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-introductio...
- http://horicky.blogspot.com/2012/07/couchbase-architecture.html from a community member

As you can see in the architecture, each node of the cluster has a subset of the data (and replicas) so each node has it owns storage. (this is the way you can scale out easily)

Regards
Tug

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Mon, 12/17/2012 - 06:23
Peter Karlsson
Offline
Joined: 12/16/2012
Groups: None

Thanks for you answer. I think I was not completely clear in my question. I don't mean between my application and Couchbase. I mean before my application. So I think the right question is, do I need HAProxy before my application? To make my question even clearer I will tell you what I want to do, please tell me if I am on the right way.

First I want to have a Mac mini with HAProxy installed. HAProxy keep track of my 4 other Mac minis with my PHP application (and Couchbase). Let's pretend that I need to upgrade ram memory in one of the 4 Mac minis. I will shutdown, upgrade and start it and HAProxy will keep track of when it is offline/online. Like this image but with 4 Mac minis.

http://www.igvita.com/posts/08/haproxy-setup.png

Am I thinking in the right direction?

Top
  • Login or register to post comments
Mon, 12/17/2012 - 12:51
jabberfest
Offline
Joined: 12/12/2012
Groups: None

I think you are asking about a web server cluster to load balance across your 4 Macs.

In that case, you essentially deploy the same code on all 4 machines.

Top
  • Login or register to post comments
Tue, 12/18/2012 - 05:44
Peter Karlsson
Offline
Joined: 12/16/2012
Groups: None

So if I understand this right I can install HAProxy on one Mac mini as the frontend and install my PHP application + Couchbase on four identical Mac minis and I will have a web server cluster and a Couchbase cluster at the same time?

I can also connect one external hard drive to each of my four Mac minis to store all my highres images?

Top
  • Login or register to post comments
Tue, 12/18/2012 - 12:52
jabberfest
Offline
Joined: 12/12/2012
Groups: None

It all depends on how you configure it.

You can have one couchbase instance running that all four web servers talk to. Or you can have all web servers talk to a cluster of couchbase servers.

Unless you are on a small development environment I advice against running the database on the same server as the web server. If the webserver goes down, so does your database.

The point of using HAProxy is to offer load balancing as well as fail over.

This is more of a HAProxy forum question.

In theory you can run use those 4 computers to both run your web server and clustered DB, but that's just asking for trouble when one of those servers go down. You want to try to go with a de-coupled architecture.

Top
  • Login or register to post comments
Wed, 12/19/2012 - 12:19
Peter Karlsson
Offline
Joined: 12/16/2012
Groups: None

By de-coupled architecture, do you mean for example 4 web servers with HAProxy as the front end (round robin) and another 4 with couchbase running as a cluster?

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