Difference Mongdb, MySQL, Redis of

Difference Mongdb, MySQL, Redis of
Mongdb advantages: 1, fast! Amount of memory has Mongdb level performance is very fast, it will heat the data stored in physical memory (rather than just a small part of the data and index), so that the write data becomes hot very quickly, thereby improving overall speed and efficiency.
2, high scalability! Mongdb high availability and cluster architecture has a very efficient scalability by increasing physical machines, as well as the increase sharding, Mongdb expansion will reach a very alarming proportions.
3, its Failover! Replica set configuration Mongdb's, when the main library has encountered a problem and can not continue to provide services, a copy of the set will elect a new main library to continue to provide services.
4, Json storage format! Mongdb and Bson storage format is ideal for storing and querying document formats.
MongoDB disadvantage: does not support transactional operations (major weakness), MongoDB space is too large, MongoDB mature as a maintenance tool such as MySQL.
Redis: memory database, persistent way: Redis databases are all in memory, and persistent way is to use RDB or AOF way.

Comparing the amount of data and performance:

When enough of the physical memory, Redis> MongoDB> MySQL
when physical memory is not enough, Redis and MongoDB will use virtual memory.
In fact, if you want to start Redis virtual memory, it is clear that either add memory, you should either change the database.
However, MongoDB not the same, as long as the read and write operations to ensure that the ratio of hot and cold data, so that the heat exchange mmap less data in physical memory, MongoDB or guaranteed performance. Some people use MongoDB stores data on T's.
MySQL, MySQL do not need to worry about the amount of data under the relationship with memory. However, the relationship between the amount of memory with thermal data will greatly affect performance.
When physical memory and virtual memory is not enough, it is estimated in addition to MySQL nothing you have chosen.
In fact, from the data storage principle point of view, I prefer the MongoDB database classified as hard, but uses mmap as a means of accelerating it.
MongoDB and MySQL command contrast
traditional relational databases in general by the database (database), table (table), record (record) concept consisting of three levels, MongoDB is a database (database), collection (collection), the document object (document) three levels composition. MongoDB for relational database tables, but set no columns, rows, and the concept of relationship, which reflects the free mode features.
MongoDB (document database): provides scalable high performance data storage
1, based on the distributed file storage
2, add more nodes under heavy load conditions, the performance can be guaranteed server
3, the data is stored as a document
MongoDB comparison with MySQL
1, stability
2, the index, the index in memory, it is possible to enhance the performance of random access. If the index is not entirely in memory, once a relatively high random read and write times appear, it will be frequent disk swapping, MongoDB performance drops precipitously
3, occupied a large space, because it is a typical space for time principle Types of. Then its disk space than ordinary database will waste some, but so far it has not achieved online compress function,
frequent additions and deletions to the data when, if the record has changed, such as the size of the data has changed in MongoDB easy this time produce some data fragmentation, fragmentation results lead to the emergence of a index will be performance issues, the other one is after a certain period of time, less space will inexplicably increases, so do the database regularly to repair, periodic re indexing, it will enhance the stability and efficiency of MongoDB. In the latest version, it has been online for compression, is estimated to be around 2.0, should be able to achieve online compression, you can now perform some operations repair DataBase in the background. If so, it solved a big problem currently plaguing us.
4, MongoDB transaction data support the relationship between the weak
5, convenient operation and maintenance
MongoDB relative advantage of MySQL's

  1. For those who demand model for database-specific data format is not clear or database data formats change frequently, but the developer is very friendly.
    2. comes with a distributed file system that can be easily deployed to the server cluster.
    MongoDB has a notion of a Shard, it is easy to use server slice. Each additional insert performance Shard, MongoDB will be close to a multiple of the growth mode, disk capacity is also very easy to expand.
  2. It comes with support for map-reduce framework of the operation, which is very convenient for statistical data. Similar to the group by.
    MongoDB and Redis difference:

    MongoDB is more similar to MySQL, support field index, cursor operations, its advantage is more powerful search function, good query JSON data, can store huge amounts of data, but does not support transactions.
    MySQL is reduced significantly when a large amount of data, MongoDB more often as an alternative to a relational database.
    Memory management mechanism
    Redis data exists all memory, disk write on a regular basis, when the memory is not enough, you can select a specific LRU algorithm to delete data.
    MongoDB data in memory, the linux mmap implementation system, when the memory is not enough, only the hot data into memory, and other data stored on the disk.
    Support data structures
    rich support for Redis data structures, including hash, set, list and so on.
    MongoDB data structure is relatively simple, but expressed support for rich data, index, similar to most relational database query language supported by very rich.
    Cluster: MongoDB cluster technology is more mature, Redis from 3.0 started to support clusters. Both can support persistence.
    NA scenario: 1, requires a complex operation sql; (2) transactional systems;
    Difference Mongdb, MySQL, Redis of

    MySQL and Redis difference:

    MySQL is the persistent storage, stored on disk inside, retrieved, which will involve some IO, in order to solve this bottleneck, so there is a cache, such as is now the most used memcached (referred to as mc). First, the user access mc, if not hit, went to visit MySQL, after like memory and hard drive as part of the copied data to mc. Redis and mc are cached, and run all reside in memory, which greatly improves access speed web access high amount of data. However it mc only provides a simple data structure, such as string storage; the Redis has provided a large amount of data structures, such as string, list, set, hashset, sorted set of these, which makes it convenient to a lot of users, after a layer of encapsulating practical function, while achieving the same effect, of course, with Redis slowly abandon mc.
    The relationship between memory and hard disk, hard disk to place the main data for persistent storage, and memory is that part of the data currently running, CPU access memory instead of disk, which greatly enhance the speed of operation, of course, this is based on localized program access principle.
     Reasoning to Redis + MySQL, it is a relationship of disk memory + map, MySQL on the disk, Redis in memory, in this case, web applications access a time Redis, if the desired data is not found, before going to visit MySQL.
     However, the use Redis + MySQL + disk and memory are preferably different.
    The former is a memory database, data is stored in memory, of course, fast.
    The latter is a relational database, powerful data access will slow.
    Like memcache, MongoDB, Redis, belong to No SQL series.
    Not a type of thing, scenarios are not the same, will depend on your needs to decide.

Guess you like

Origin blog.51cto.com/14128387/2401206