You’ve just launched your new web application, and by happy accident, it’s gone viral and your usage has exploded from the few thousand users you originally expected to hundreds of thousands. If you are lucky, it will expand to millions within a few days.

If you are lucky, you designed your application with flexibility and expandability in mind. Depending on what environment you’ve chosen, you may have had to plan for a replication environment, using masters and slaves, or an application environment that allowed you to write to a central database, while reading from one of the replicated servers to aid performance.

With a little further planning, you may have decided to employ some kind of caching layer that allows you to store information in the RAM of your servers so that you don’t have to make so many queries to the database for information that hasn’t changed.

Surely there’s an easier way?

Couchbase Server addresses many of these problems. It has a caching layer built in, and a built-in distribution system that doesn’t require changes to your application. You can also expand your database system on the fly, without taking your application down, changing the configuration, or restarting it.

In this book, we’ve tried to distill down the key elements you need to get going with Couchbase. You’ll get to know the internal architecture and how this affects the way you build and deploy your database system. I’ll also show you how to perform key admin tasks, such as expanding your cluster and creating backups.

I’ve also provided a quick guide to building applications using the core protocol and document-based architecture of Couchbase Server.

Combined, all of these different sections should tell you everything you need to know to use Couchbase Server, from sizing and constructing your cluster, to deploying and expanding it. This way, when your application goes viral, you’ll know what to do. Good luck!

Where to Get Help on Couchbase Server

The information provided in this book is designed as a basic guide to using Couchbase Server 1.8.

For more detailed information on Couchbase Server, you can read the full manual at For more general information about Couchbase Server, read the website

Information on the client libraries used to build applications against Couchbase Server, see

For a list of all the available documentation for Couchbase Server, including the upcoming Couchbase Server 2.0, see

To get involved with the Couchbase community, there are Forums available at, and a mailing list at

To get in touch with the author, please contact me at

Conventions Used in This Book

The following typographical conventions are used in this book:


Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.


This icon signifies a tip, suggestion, or general note.


This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Getting Started with Couchbase Server by MC Brown (O’Reilly). Copyright 2012 Couchbase, Inc., 978-1-449-33106-1.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online


Safari Books Online ( is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:

To comment or ask technical questions about this book, send email to:

For more information about our books, courses, conferences, and news, see our website at

Find us on Facebook:

Follow us on Twitter:

Watch us on YouTube:


Writing this book would have been impossible without the stunning work by the entire Couchbase development team. They continue to put effort into new features and functionality, not to mention having designed and built the original product.

Perry Krug has given me so much input and support while producing this book, by making sure the content is correct and up to date. Without him, this book would be far less useful, not to mention inaccurate. Thanks as well to the rest of the product management team who helped to review and comment on the content.

At O’Reilly, thanks to Meghan Blanchette, my incredibly understanding and supportive editor, and Mike Loukides, who supported the inception of the book and its content.

Get Getting Started with Couchbase Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.