- Couchbase Server is a distributed document database that stores data as JSON documents and provides an advanced caching layer. It distributes data and replicates across nodes for high performance and resilience.
- Documents are accessed by unique keys and stored in memory for fast retrieval. Operations include add, get, update, delete. Views and secondary indexes allow querying.
- The demo showed key-based CRUD operations as well as querying documents using views and the new N1QL query language.
2. @DavidOstrovsky
Senior Consultant @ Sela
Co-author of:
“Pro Couchbase Server” – Apress
Media 2014
“Essentials of Developing Windows
Store Apps Using C#”
“Advanced Windows Store App
Development Using C#”
CodeHardBlog.azurewebsites.net
3. Agenda
What is Couchbase Server?
Why should I care?
What is this “document” stuff?
How do I use it?
Where are my documents?
What else can I do with it?
4. A little history…
Couchbase Server is the progeny of two
products:
Membase - a distributed in-memory cache
Apache CouchDB – a document database
In 2011, the companies behind the two
products merged to form Couchbase Inc. and
created Couchbase Server.
5. So, what does it do?
Couchbase Server is a document database with
an advanced memory caching layer.
Stores “documents” in JSON format
Indexes the contents of documents
Couchbase automatically distributes (“shards”)
data across the cluster.
Data is replicated multiple times for resilience.
6. And how does it work?
A Couchbase cluster is made up from multiple
similar nodes.
Nodes are simply installations of Couchbase Server
No special head or configuration nodes
Client applications use an SDK to connect to the
cluster and exchange data.
Official support for: Java, .NET, C, PHP, Python, Ruby
and Node.js
Community support for many more
8. Documents – what’s up with that?
UserId Name Age CityId
01 John 35 002
02 Dave 18 003
{
"name": "John",
"age": 35,
"address": {
"city": "New York",
"street": "…"
}
}
9. When should I use it?
High performance requirements
Millions of operations per second
Very large-scale systems
Sub-millisecond reads
Serving ads, storing user profiles, etc.
Developer friendliness
Flexible schema
Seamless upgrade of application versions
Simple CRUD
Straightforward administration
10. Working with documents
Documents are accessed by their key (aka. ID)
Key-based operations are very fast.
On a dedicated cluster, you can expect sub-
millisecond responses.
Items are stored in memory, then written to disk
asynchronously.
Items are retrieved from the memory cache.
11. CRUD
All operations are exposed by the Couchbase
client object instance.
Add/Set store a document in the database.
Get retrieves a document by key.
Replace updates an existing document.
Bulk versions of operations – depends on SDK.
13. What database only has one user?
Couchbase supports concurrency through
Check-and-Set operations.
Every item’s metadata has a CAS value, which
gets updated with every change.
Optimistic concurrency works by comparing
client and server CAS values.
Pessimistic concurrency works by locking the
key exclusively for a specific session.
14. Dude, where is my document?
In addition to keys (primary index), Couchbase
supports secondary indexes, called Views.
Unlike key-based operations, which are served
from memory, vies are served from disk.
File system caches disk reads.
15. MapReduce in 60 seconds
Views are defined as a MapReduce function.
Map function runs for each document and extracts
the data for the index.
Reduce is optional and can be used for
aggregations, such as grouping by value.
17. N1QL – How do you pronounce that?
N1QL (aka “Nickel”) is an SQL-like query
language for Couchbase.
Expanded SQL syntax to account for nested
documents, arrays, and cross-bucket joins.
Currently in developer preview, coming in a
future version.
19. Great, what else you got?
Cross-Datacenter Replication (XDCR)
Couchbase Mobile
A NoSQL database for mobile apps.
Can be stand-alone or synchronized with Couchbase
Server.
ElasticSearch Integration
Uses ES for querying and Couchbase for retrieval.
Hadoop Connector
Uses sqoop to move data between CB and Hadoop.