This is the 16th day of my participation in the August More Text Challenge. For details, see:August is more challenging
【Redis series 】 Redis learning 1, the evolution of database and Nosql preliminary cognition
Nosql
Why use Nosql?
Let’s take a look at the development of the database
1. Standalone MYSQL era
Application access database is application – DAL database access layer – DB database
In the stand-alone MYSQL era, the data is not too big, and the page is static page, the general site page view is small, so the single database is fully enough
On sites like the one above, the bottleneck will be obvious:
- The amount of data has become too large for a machine to handle
- Data index (B+ Tree), a machine can not store the inside how to deal with
- Read and write traffic, a server can not withstand what to do
With the evolution of history, this kind of website will inevitably face the above problems, which must be solved
2, Memecache + MYSQL + vertical split
To solve the above problem, we put more machines than one machine can handle, but how to ensure the consistency of the data?
Hence the idea of read/write separation, specifying that one database is used for writing data, the other databases are used for reading data, and the other databases will synchronize the data in MYSQL that is used for writing data
Gradually, I realized that every request, I had to operate the database, which was time consuming and needed to be changed
Therefore, before accessing the database, the Memcache server is added. When reading the database for the first time, the data in Memcache is read without changing the database for the second time, reducing the pressure on the database
Here’s how it went:
Optimize database structure and index – file cache (IO) – cache server Memcache
3, sub-table + horizontal split + MYSQL cluster
As technology evolves, so does business, which brings more problems
In the beginning, we used MyISAM, the engine used by MYSQL, which is a table lock, which is very inefficient, especially in the case of high concurrency
Then you have MYSQL’s InnoDB engine, which is the row lock, and as the business continues to grow, you have MYSQL cluster
In clusters, each cluster stores a portion of data. If the data volume still increases, add more clusters
4, now
Thanks to modern the amount of data that is really very big, big data era, MYSQL relational database is not enough, now the data amount is much, change quickly, before using MYSQL, design, have to put all of the fields, can use field, all want to know, understand design, for now rapidly changing era, it’s hard to
Now you would expect, for example, to have a file server for storing files, an image server for storing images, and a dedicated database for storing that data, that MYSQL would be a lot less stressed
Now the Internet project looks like this in a nutshell
For Internet projects like this, there is a strong need for Nosql, which can handle the problems mentioned above
What is Nosql?
Nosql
Not only SQL
Generally refers to non-relational database, with the birth of Web2.0 Internet, the traditional relational database is difficult to deal with the Web2.0 era
For example, nowadays, Internet users need to store personal information, location information, social network data, etc., Nosql for these data storage does not need to use a fixed format, and it is easy to scale, such as Map<string,interface{}>, using key value pair control is nice
The characteristics of no
- Easy to scale, because there is no relationship between the data, it is easy to scale
- High performance. For example, Redis can be written 80,000 times and read 110,000 times per second. Nosql is stored at the record level and is a fine-grained cache
- Data types are diverse, and there is no need to design a database beforehand
Let’s compare a traditional relational database (RDBMS) with a Nosql
RDBMS:
- Structured organization
- The SQL statement
- Data and relationships exist in separate tables
- Data Manipulation, Data Definition language
- Strict consistency
- Transaction processing and so on
No:
- It’s not just data
- There is no fixed query language
- Key and value pair stores, column stores, file stores, graph databases such as social relationships, etc
- Final consistency
- The CAP theorem and the BASE principle
- High availability, high performance, high scalability
By the way, let’s share what 3 V and 3 height are:
3 V, mainly used to describe the problem:
- Massive data volume
- Variety of diversity
- Real-time velocity
3 high, mainly used to describe the requirements of the program
- High concurrency
- A high performance
- High extensible
The four categories of Nosql
KV key value pair:
- Redis
C, single-process Nosql, Ali, Tencent, Baidu, byte and other companies are using
Document database:
- Mongdb
Mongdb is a distributed file storage based database, written in C++, mainly used to process a large number of documents
Mongdb is also a product between relational database and non-relational database, he is the most functional non-relational database, the most like a relational database non-relational database
Column storage database:
- HBase
- Distributed file system
Graph relational database:
- Neo4j
- InfoGrid
Instead of storing graphs, graph relational databases store relationships, such as social networks
Let’s compare these four categories:
This picture is from the Internet. This picture has clearly described the KV key value pair, document database, column storage database, graph database case, data model, advantages and disadvantages, now you will have a general understanding of Nosql
Welcome to like, follow and collect
Dear friends, your support and encouragement are the motivation for me to keep sharing and improve the quality
All right, that’s it for this time
Technology is open, our mentality, should be more open. Embrace change, live in the sun, and strive to move forward.
I am nezha, welcome to like the collection, see you next time ~