Non-relational database NoSQL

Source: Internet
Author: User
Tags memcached

NoSQL (not-only SQL) non-relational database


comparison between relational database and non-relational database :

Common relational databases: MySQL, Oracle, SQL Server

A relational database involves a federated query (join), which slows down the query when the volume of data is large

No relationship between NoSQL data, can be expanded arbitrarily

NoSQL data storage is simple, and can exist in memory, so read and write very fast, even if the amount of data is very large and quickly

NoSQL does not need to create tables, fields and other data, he can store the custom format at any time, and the relational database increment, change the field is very troublesome, especially when the volume of data is very large, it is more troublesome


Ii. What are the common types of nosql?

Key value (Key-value) database products: Redis, memcached, riak,redis/memcached belong to the key value (key-value) database, suitable for storing user information, such as session, configuration file, parameters, shopping cart, etc. This information is usually linked to the ID (key), in which case the key-value database is a good choice


Three Web, user login time any one, login information saved in Redis or memcached, log in web2 again, do not need to verify login, complete session to maintain


Document-oriented (document-oriented) database, Products: MongoDB, CouchDB, RavenDB

MongoDB belongs to the document (document-oriented) database, where the data is stored as documents, and each document is a collection of a series of databases. Each data item has a name and corresponding value, which can be either a file type, such as a string, a number, a date, or a complex type, such as an ordered table and associated object. The smallest unit of data storage is the document.

Columnstore (wide column store/column-family) database product: Cassandra\hbase

Figure (graph-oriented) database products: neo4j, Infinite graph, Orientdb


Iii. introduction of Memcached

Memcached is to improve dynamic Web site performance by caching database query results, reducing database access times, and http://memcached.org/the official site.

Simple protocol based on C/s (server-side client) architecture

Event handling based on the libevent architecture

Autonomic memory storage processing (slab allowcation)

Data expiration methods: Lazy Expiration and LRU


memcached Data Flow

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7C/AB/wKioL1bVjrbAUK7jAACObF1ymbE181.png "title=" Memcached.png "alt=" Wkiol1bvjrbauk7jaacobf1ymbe181.png "/>


The principle of Slab allocation-dividing the allocated memory into fast (chunk) of each size, and dividing the same size into groups (chunk collections), each chunk collection is called Slab

The memory allocation for memcached is one page, the page default value is 1M, and can be specified at startup by the-l parameter.

The slab is made up of multiple page, and the page is cut into multiple chunk by the specified size, and its mechanism is as follows:

The size relationship can be understood like this: Slab>page>chunk

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7C/AD/wKiom1bVj7LSanboAAIrli7s8I8676.jpg "title=" Slab.jpg "alt=" Wkiom1bvj7lsanboaairli7s8i8676.jpg "/>



memcached How data expires

Lazy Expiration

Memcached does not monitor for expiration, but instead looks at the timestamp of the record at get time and checks if the record is out of date. This technique is called lazy (lazy) expiration. As a result, memcached does not consume CPU time on outdated monitoring


Lru

Memcached will prefer to use a record space that has timed out, but even so, there is a situation where the time-space between appending a new record is insufficient, and the space will be allocated using the name least recently used (LRU) mechanism. As the name implies, this is the mechanism for deleting "least recently used" records. Therefore, when space is low (when new space cannot be obtained from the Slab Class), it is searched from records that have not been used recently and allocates its space to new records. From a practical point of view of caching, the model is ideal.

This article comes from "Plum blossom fragrance from bitter cold!" "Blog, be sure to keep this provenance http://daixuan.blog.51cto.com/5426657/1746447

Non-relational database NoSQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.