What are the nosql databases
What are the nosql databases? Do not know the partners to see what I share today!
I. Common nosql databases are Redis, Memcache, MongoDb.
II. Features of Redis, Memcache, MongoDb:
1. Supports a variety of data structures, such as string (string ), list (bi-directional chained table), dict (hash table), set (set), zset (sorted set), hyperloglog (base estimation)
2. Supports persistence operations, you can aof and rdb data persistence to disk, so that data backup or data recovery operations, a better means of preventing data loss.
3. Support for data replication through Replication, through the master-slave mechanism, you can synchronize the replication of data in real time, support for multi-level replication and incremental replication, master-slave mechanism is an important means of Redis HA.
4. Single-threaded requests, all commands are executed serially, and there is no need to consider data consistency issues in concurrent cases.
5. Support pub/sub message subscription mechanism can be used for message subscription and notification.
6. Support for simple transaction requirements , but the industry use scenarios are rare and not mature.
1. Redis can only use a single thread, the performance is limited by the CPU performance, so a single instance of the CPU may reach a maximum of 5-6wQPS per second (depending on the data structure, data size and server hardware performance, the peak of the QPS of the day-to-day environment in the peak of about 1-2w or so).
2. Support for simple transactional requirements, but the industry is very little use of the scene is not mature, both advantages and disadvantages.
3. Redis will consume more memory on string type, you can use dict (hash table) to compress the storage to reduce memory
1. Memcached can take advantage of multi-core, single instance throughput is very high, can reach hundreds of thousands of QPS (depending on the key, value of the byte size as well as the performance of the server hardware, the peak of the QPS in the daily environment is about 4-6w or so). It is suitable for carrying the maximum amount.
2. Support directly configured as sessionhandle.
1 only supports simple key/value data structure, unlike Redis can support rich data types.
2. Can not be persistent, the data can not be backed up, can only be used for caching purposes, and restart after all the data is lost.
3. Can not be synchronized, can not migrate the data in the MC to other MC instances.
4. Memcached memory allocation using the SlabAllocation mechanism to manage memory, value size distribution of large differences in memory utilization will cause a reduction in memory utilization, and triggered by low utilization still appear kicked out and other issues. Users need to focus on value design.
1. higher write load, MongoDB has a higher insertion speed.
2. Handles very large scale single tables, can easily split tables when the data table is too large.
3. High availability, set M-S is not only easy and fast, MongoDB can also be fast, safe and automated node (data center) failover.
4. fast queries, MongoDB supports two-dimensional spatial indexes, such as pipelines, so you can quickly and accurately fetch data from a given location. mongoDB will load the data from the database into memory as a file map after startup. If memory is reasonably abundant, this can dramatically increase the speed of database queries.
5. Explosive growth of unstructured data, adding columns can in some cases lock up the entire database or increase the load which can lead to performance degradation, due to MongoDB’s weak data structure model, adding 1 new field will not have any impact on the old table and the whole process will be very fast.
1. Does not support transactions.
2. MongoDB takes up too much space.
3. MongoDB does not have a mature maintenance tool.
Three, Redis, Memcache and MongoDB difference:
The performance of the three are relatively high, in general: Memcache and Redis is about the same, to be higher than MongoDB.
memcache data structure is single.
Memcache has a single data structure.
redis rich some, data manipulation, redis better, less network IO times.
mongodb supports rich data expression, indexing, most similar to relational databases, support for query language is very rich.
3, storage space
redis in version 2.0 after the addition of their own VM features, breakthrough physical memory limitations; you can set the keyvalue expiration time (similar to memcache).
memcache can modify the maximum available memory, using the LRU algorithm.
mongoDB is suitable for large amounts of data storage, rely on the operating system VM to do memory management, eat memory is also more powerful, the service should not be together with other services.
redis, dependent on the client to achieve distributed read and write; master-slave replication, each time the slave node reconnected to the master node to rely on the entire snapshot, no incremental replication, due to performance and efficiency issues, so a single point of the problem is more complex; does not support automatic sharding, you need to
depends on the program to set a consistent hash mechanism. An alternative is not to use redis itself replication mechanism, using their own active replication (multiple storage), or change to incremental replication (need to realize), consistency issues and performance
Memcache itself does not have a data redundancy mechanism, and there is no need; for failure prevention, the use of algorithms that rely on mature hash or ring, to solve the jitter problem caused by a single point of failure.
mongoDB supports master-slave, replicaset (internal paxos election algorithm, automatic failure recovery), autosharding mechanism, the client shielded from failover and cutover mechanism.
redis support (snapshots, AOF): rely on snapshots for persistence, AOF enhances the reliability at the same time, there is an impact on performance.
memcache does not support, usually used to do the cache, improve performance.
MongoDB has used binlog since version 1.8 to support the reliability of persistence.
Memcache in concurrent scenarios, using cas to ensure consistency.
redis transaction support is relatively weak, can only guarantee that each operation in the transaction is executed consecutively.
mongoDB does not support transactions.
7. Data analysis
mongoDB built-in data analysis features (maprece), the other two do not support.
8. Application Scenarios
redis: smaller data volumes on the more performance operations and computing.
memcache: used in the dynamic system to reduce the database load, improve performance; do cache, improve performance (suitable for reading more write less, for a larger amount of data, you can use sharding).
MongoDB: mainly to solve the problem of access efficiency of massive data.
Four types of nosql databases
NoSQL databases are generally categorized into four main types: key-value (Key-Value) storage databases, column storage databases, document-based databases, and graph (Graph) databases. Their data model, advantages and disadvantages, typical application scenarios.
Key-value (Key-Value) storage database Key to Value key-value pairs, usually with a hash table to achieve a fast lookup data unstructured (usually only treated as a string or binary data) content caching, mainly used to deal with a large amount of data, high access load, but also used in some logging systems.
Column storage database, to the column cluster storage, will be the same column of data exists together to find fast, scalable, easier to carry out distributed expansion function is relatively limited to distributed file system.
Document-based database, Key-Value corresponds to the key-value pairs, Value for the structured data, data structure requirements are not strict, the table structure is variable (not like relational databases need to pre-define the table structure), query performance is not high, and the lack of a unified query syntax, Web applications.
Graph (Graph) database, graph structure, the use of graph structure related algorithms (such as shortest path addressing, N-degree relationship lookup, etc.), many times you need to do the calculation of the entire graph in order to derive the required information, and this structure is not very good to do a distributed cluster program, social networks, recommender systems.
Which belongs to NoSQL databases
1, Key-Value (Key-Value) storage databases
This category of databases will mainly use a hash table, which has a specific key and a pointer to a specific piece of data.Key/value model has the advantage of simplicity and ease of deployment for IT systems.
But Key/value is inefficient if the database administrator (DBA) is querying or updating only some of the values. Examples include TokyoCabinet/Tyrant, Redis, Voldemort, OracleBDB.
2. Columnar storage databases
This part of the database is usually used to cope with massive amounts of data in distributed storage. Keys still exist, but they are characterized by pointing to multiple columns. These columns are organized by column families. For example: Cassandra, HBase, Riak.
3, document database
Document database is inspired by LotusNotes office software, and it is similar to the first type of key-value storage. The type of data model is a version of the document, semi-structured document stored in a particular format, such as JSON.
Document-based database can be seen as an upgraded version of the key-value database, allowing nested key values between the processing of complex data such as web pages, document-based database than the traditional key-value database query more efficient. For example: CouchDB, MongoDb, there is also a document-based database SequoiaDB, has been open source.
4, graphics (Graph) database
Graph structure of the database with other rows and columns as well as rigid structure of the SQL database is different, it is the use of flexible graphical model, and can be extended to multiple servers.
NoSQL databases do not have a standard query language (SQL), so database queries require a data model. Many NoSQL databases have REST-style data interfaces or query APIs. e.g., Neo4J, InfoGrid, InfiniteGraph.
Which of the column options belongs to nosql database?
NoSQL databases are non-relational databases that are not forced to follow a fixed schema or relationship. Compared to traditional relational databases, NoSQL databases are more suitable for handling large-scale unstructured or semi-structured data. Common NoSQL databases include MongoDB, Cassandra, Redis, etc., and different types of NoSQL databases have their own advantages and disadvantages in different scenarios. For example, MongoDB is suitable for storing large amounts of document data, while Redis is suitable for storing key-value data, and Cassandra is suitable for supporting high concurrency and distributed storage of large-capacity data.
nosql database what
Category I: key-value database
Redis,Voldemort,OracleBDB, the domestic ssdb
Category II: Columnar storage database
Category III: document-based database
Category IV: Graph (Graph) database