编程知识 cdmana.com

Advantages and disadvantages, application scenarios of NoSQL such as mongodb, HBase and redis

NoSQL The four categories of

NoSQL It is self-evident that database plays an important role in the whole database field . In the age of big data , although RDBMS Very good , But in the face of rapid growth of data scale and increasingly complex data model ,RDBMS Gradually, I can't do it , Unable to handle many database processing tasks , At this time NoSQL With ease of expansion 、 Large amount of data, high performance and flexible data model have successfully established a foothold in the field of database .

At present, it is generally agreed that NoSQL Databases are divided into four categories : The key stores the database , Document database , Column storage database and graphic database , Each type of database can solve the problem that relational data can't solve . in application ,NoSQL The classification boundary of database is not so obvious , It's often a combination of many types .


Main stream nosql Detailed explanation of :MongoDB、Hbase、Redis



MongoDB It's a high performance , Open source , A modeless document database , The development language is C++. It can be used in many scenarios to replace the relational database or key of the system / Value storage .

1.MongoDB characteristic

  • The language used :C++

  • characteristic : Retain the SQL Some friendly features ( Inquire about , Indexes ).

  • Permission to use : AGPL( The initiator : Apache)

  • agreement : Custom, binary( BSON)

  • Master/slave Copy ( Support automatic error recovery , Use sets Copy )

  • Built in fragmentation mechanism

  • Support javascript Expression query

  • You can execute any... On the server side javascript function

  • update-in-place Support than CouchDB Better

  • Memory to file mapping is used in data storage

  • The focus on performance exceeds the need for functionality

  • It is suggested that the log function should be turned on ( Parameters --journal)

  • stay 32 Bit operating system , The database size is limited to about 2.5Gb

  • Empty database takes up about 192Mb

  • use GridFS Store big data or metadata ( It's not a real file system )

2.MongoDB advantage :

1) Higher write load ,MongoDB With higher insertion speed .

2) Deal with large scale single tables , When the data table is too large, it can easily split the table .

3) High availability , Set up M-S Not only convenient but also fast ,MongoDB It can also be fast 、 Security and automation implementation node ( Data Center ) Fail over .

4) Quick query ,MongoDB Support 2D spatial index , Like pipes , So you can quickly and accurately from the designated location get data .MongoDB After startup, the data in the database will be loaded into memory in the form of file mapping . If inside If there are abundant resources , This will greatly improve the query speed of the database .

5) The explosion of unstructured data , Adding columns may lock the entire database in some cases , Or increase the load to Performance degradation , because MongoDB The weak data structure pattern of , add to 1 New fields have no effect on the old table , The whole process will be very fast .

3.MongoDB shortcoming :

1) Unsupported transaction .

2)MongoDB Take up too much space .

3)MongoDB There is no mature maintenance tool .

4.MongoDB Application scenarios

1.) For real-time insertion 、 Update and query requirements , And it has the replication and high scalability required for real-time data storage of applications ;

2) It is very suitable for document format storage and query ;

3.) A highly scalable scenario :MongoDB Very suitable for databases composed of dozens or hundreds of servers .

4.) The focus on performance exceeds the need for functionality .


HBase yes Apache Hadoop A sub project in , Belong to bigtable Open source version of , The implemented language is Java( So it depends on Java SDK).HBase Depending on Hadoop Of HDFS( distributed file system ) As the basic storage unit .

1.HBase characteristic :

  • The language used : Java

  • characteristic : Supporting billions of lines X Millions of column

  • Permission to use : Apache

  • agreement :HTTP/REST ( Support Thrift, See note 4)

  • stay BigTable And then modeling

  • Using distributed architecture Map/reduce

  • Optimize real-time queries

  • High performance Thrift gateway

  • By means of server End scan and filter to achieve query operation prediction

  • Support XML, Protobuf, and binary Of HTTP

  • Cascading, hive, and pig source and sink modules

  • be based on Jruby( JIRB) Of shell

  • Configuration changes and minor upgrades are rolled back again

  • No single point of failure

  • Comparable to MySQL Random access performance of

3. HBase advantage

1) Large storage capacity , A table can hold hundreds of millions of rows , Millions of column ;

2.) It can be retrieved by version , Can search the required historical version data ;

3.) When the load is high , We can expand the horizontal segmentation by simply adding machines , Follow Hadoop Seamless integration ensures the data reliability (HDFS) And the high performance of massive data analysis (MapReduce);

4.) In the 3 On the basis of point, it can effectively avoid the occurrence of single point fault .

4.HBase shortcoming

1. be based on Java Language implementation and Hadoop Architecture means that API More applicable to Java project ;

2. node There are many dependencies in the development environment 、 Configuration trouble ( Or do not know how to configure , Such as persistent configuration ), Lack of documentation ;

3. It takes up a lot of memory , And in view of the fact that it is based on the optimization for batch analysis HDFS On , The reading performance is not high ;

4. API Compared with other NoSql It's relatively clumsy .

5.HBase Applicable scenario

1)bigtable Type of data storage ;

2) There are version query requirements for data ;

3) To cope with the requirement of large amount of data, expand the simple demand .


Redis Is an open source use ANSI C Language writing 、 Support network 、 Log type that can be memory based or persistent 、Key-Value database , And provide multilingual API. At present by VMware Lead the development work .

1.Redis characteristic :

  • The language used :C/C++

  • characteristic : It runs abnormally fast

  • Permission to use : BSD

  • agreement : class Telnet

  • Memory database supported by hard disk storage ,

  • But since the 2.0 The data can be exchanged to the hard disk in the future ( Be careful , 2.4 This feature is not supported in future versions !)

  • Master-slave Copy ( See note 3)

  • Although it uses simple data or a hash table indexed by key values , But it also supports complex operations , for example ZREVRANGEBYSCORE.

  • INCR & co ( Suitable for calculating limit values or statistics )

  • Support sets( It also supports union/diff/inter)

  • Support List ( It also supports queues ; Blocking type pop operation )

  • Support hash table ( Objects with multiple domains )

  • Support sorting sets( High score table , For range queries )

  • Redis Support transactions

  • Support to set data as expired data ( It's like a quick buffer design )

  • Pub/Sub Allow users to implement messaging mechanisms

2. Redis advantage

1) Very rich data structure ;

2.)Redis Provides transaction capabilities , Can guarantee a string of The atomicity of command , There will be no interruption of any operation in the middle ;

3.) Data is in memory , Reading and writing are very fast , You can achieve 10w/s The frequency of .

3.Redis shortcoming

1) Redis3.0 After that, the official cluster scheme came out , But there are still some architectural problems ;

2.) The persistence experience is poor —— If the snapshot method is used , You need to write the data of the entire database to disk at regular intervals , The cost is very high ; and aof Methods track only changing data , Be similar to mysql Of binlog Method , But add log Maybe it's too big , At the same time, all operations have to be performed again , Slow recovery ;

3) Because it's an in memory database , therefore , A single machine , The amount of data stored , And the memory size of the machine itself . although redis It has key Expiration strategy , But you still need to estimate and save memory in advance . If memory grows too fast , You need to delete data on a regular basis .

4.Redis Application scenarios :

Best application scenario : It is suitable for data change fast and database size can be met ( Suitable for memory capacity ) Applications for .

for example : Microblogging 、 Data analysis 、 Real time data collection 、 Real time communication, etc .

本文为[osc_ ed2py9ot]所创,转载请带上原文链接,感谢

Scroll to Top