Aykut Aras
Aykut Aras

Reputation: 51

Couchbase Bucket vs Memcached Bucket for SessionProvider

I learned that Asp.Net's default sessionprovider is not a good practice for distributed applications. So i decided to change asp.net's sessionprovider to couchbase. But i am not sure which to use when i try to select a data bucket. I know that Couchbase is a persistent no-sql db and memcached is a cache server.

What is the advantages and disadvantages of using couchbase bucket instead of memcached bucket or vise versa?

I am using couchbase 2.0 and https://github.com/couchbaselabs/couchbase-aspnet library for converting couchbase to a sessionprovider.

Upvotes: 3

Views: 5503

Answers (2)

John Zablocki
John Zablocki

Reputation: 1592

Whether using a Couchbase bucket or Memcached bucket, you'll experience similar advantages. Even when using a Couchbase bucket, documents are stored in RAM. Documents also are written to RAM first and then asynchronously written to disk. So performance should be similar. Compared to other out of process session state solutions (e.g., SQL Server) Couchbase should perform significantly better.

Beyond performance, (as @DB_Chick noted) you'll have the advantage of being able to recreate sessions in the event of a node failure, since the data doesn't die with the server (assuming replication is enabled).

If you use a Couchbase bucket with Couchbase Server 2.0, you'll have the additional advantage of being able to write map/reduce views against your session data (easiest if you store JSON data structures). With views, you could easily ask "How many active sessions do I have?"

Finally, your session data will still expire with Couchbase buckets. When you set an expiry on the session data, Couchbase flags that item for deletion either during a regularly scheduled background cleanup job or when the item is retrieved after expiration.

Upvotes: 8

DB_chick
DB_chick

Reputation: 71

Couchbase buckets support the full range of Couchbase-specific functionality, including online rebalancing (for scaling your cluster), persistence and replication and failover. This is the recommended bucket type.

The memcached buckets are designed to support only the core memcached protocol as an in-memory cache. The support and functionality is therefore limited to the same functionality as within a standalone memcached implementation.

More information here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-introduction-architecture-buckets.html

Upvotes: 5

Related Questions