I’m not sure why they have a limit, I’m sure there is a good performance reason.
I think you are expected to mix documents in buckets to an extent. With 2.0 you aren’t expected to only look up documents by ID (KEY). You can look them up on indexed fields.
You use the map function to handle different documents in a given bucket. So in map.js for the view you handle the different documents appropriately.
Our product uses json schemas that are defined in another layer and we separate different types of json documents into different buckets. As a result, we have 20 or so buckets, most very very small, and a couple larger ones.
However, as of the 2.0 release, we are getting this message:
"Maximum Bucket Count Reached
Maximum number of buckets has been reached.
For optimal performance, no more than 10 buckets are allowed."
a. Is this configurable?
b. Can we make this configurable if not?
c. What is the recommended practice around the buckets? We don’t store the type of the document within the document itself.
Normally, you should try to put all information that belongs to a - say - application into one bucket. This also comes into play with the SDKs, because they can only connect to one bucket at a time. There should be no problem in putting then in one bucket and analyze them through views (since you have them in JSON format already)!
You dont need to have a type field, you can invent your own schema as well. It has just proven to be very useful to have it in there. If you need any specific help on modeling your schema, I’m sure we can help out here.
I guess the performance of memcached buckets is not affected when limit is increased. So you can use this command to increase bucket limit:
curl -X POST -u user:pass -d maxBucketCount=15 http://localhost:8091/internalSettings
Considering you have to set a RAM quota per bucket it would be highly inefficient to have document types in different buckets. If one type has a low volume, and you have 150 Mb allocated to that bucket most of that RAM will be unused. You’ll have better RAM utilization if you mix items in the same bucket.
Also if you fill up your RAM Couchbase can’t remove old stuff from one bucket to use in another, i.e. you’ll have many unnecessary cache-misses.
Use one bucket per application, and differentiate between your objects either with a type in the JSON, or how you generate your ID’s (e.g. ‘user78657823’ for users and ‘product6748323’ for products), or both.