Combination of couchbase db and membase two different company and technologies getting merged together.
use http to communicate with client
cluster base with no sql i.e. document base data
document has key – value pair. value can be binary or json
records with similar key-value can be sorted logically using bucket concept.
For physical clustering and movement of record, we have vbucket
https://docs.couchbase.com/server/current/learn/buckets-memory-and-storage/vbuckets.html
when ever a bucket is created we create default 1024 vbuckets
bucket are like database/table, we cannot access bucket directly we need to create a view similar to view in oracle and then we access view. We can have multiple view on a buckets
We can have max 30 buckets in a cluster
IT is different from mongodb – TVMD- It has trigger,View, dashboard, can be use in mobile device also but mongodb did not give this to us.
Bucket can be quires using view and n1sql languages similar to sql language.
It is schema free, high performance, easy to scale, persistent, fault tolerant, flexible, Open source, replicated, distributed
Three type of bucket -MEC.
1- Couchbase buckets: These store data persistently, as well as in memory. They allow data to be automatically replicated for high availability, using the Database Change Protocol (DCP); and dynamically scaled across multiple clusters, by means of Cross Datacenter Replication (XDCR).
Value-only: Only key-values are removed., Full: All data — including keys, key-values, and metadata — is removed.
2- Ephemeral buckets: These are an alternative to Couchbase buckets, to be used whenever persistence is not required:
Resident data-items remain in RAM., Resident data-items are ejected from RAM, to make way for new data.
3- Memcached buckets: These are now deprecated. Memcached buckets are designed to be used alongside other database platforms, such as ones employing relational database technology.
Memcached buckets are not persistent on disk:
index() :- There are total 5 type of index available in couchbase they are
Let's try to take an example of JSON data- Document to understand all this index.
Let's say we have following json record or document
customer
Key:- String Id: 1
value :
{
String Name: siddhu
String Surname:- D
Array Addres: [Address1, Address2]
}
1- Primary Key Index:- This index work on Key of the above customer record
2- Secondary Key Index:- This index work on any attribute of value of the above customer record i.e. name or surname
3- Composite Secondary key Index:- This index work on combination of any attribute of value of the above customer record i.e. name and surname
4- Array Index :- This index work on Array element of the above customer record i.e address
5- Full text index:- This index work on any value of the customer record, i.e. searching on ‘ddhu’ from name siddhu etc.
views : this is similar to the view concept of RDBMS. we can access the record from bucket using VIEWS.
N1QL :- This is similar to the querry language that we use in SQL.
Limitation :- Current limitation are as follows
‘- Maximum we can have 30 bucket in a cluster
‘- Value size can be 20 MB
‘- Key size max can be 250 bytes.
‘- Recommandate node in the cluster is 3.
trigger :- We can write the trigger in couchbase nosql db. The concept is similar to the trigger of RDBMS.
expiration (TTL) :- This is the time that is set for any record to be marked as soft delete. When we delete or mark any record as delete it’s deletion flag is set to true and then auto purge service which is executed at definite interval of time delete the record automatically and if the user delete the record then it is soft delete i.e. record is not available for the user but still present on RAM when the user asked for this record it is marked as deleted.
save/get process :- During save option data is first save on the RAM and immediately informed the user about the success of saving operation. Lets say the RAM is full in that case the oldest or less used record is removed from the RAM and is compressed (if not in RAM) and stored in persistent disk. For getting the record data is first searched in RAM if it is present the data is provided to the requester if it is not then the data is searched in the disk and moved first to RAM and decompressed and finally provided to the user.
Different process in architecture :- If we see the architecture Couchbase work in cluster env. Means we have many nodes in the production to create a cluster. Each node has the following process that is started. It is not mandate to have all the process in the node to start we can choose the process that we want to start. But when we duplicate the node b default it will have all the node from the parent node. Below are the list of the process (SAD-IQ)
1- Query Service:- This is used when the user uses the N1QL language
2- Search Service :- This is used for searching the text.
3- Index Service :- This used for indexing purpose i.e. primary key index, secondary key index, composite secondary key index, Array index, Full text index.
4-Data Service :- this is used to save or fetch the data from RAM or DISK.
5- Analytical service. :- This is use for complex join queries.
Compression :- As we know, Couchbase is Memory first DB that means data is stored on RAM first and then by using auto Async process it is moved to permanent storage i.e disc. We have the ability to store the data either in compress or non compress form in RAM but not in Disc DB. By default, all the data that is going to be persisted in Disc from RAM is going to be compressed.
No comments:
Post a Comment