Introduction to Redis(1) NoSQL Database and Introduction to Redis from Scratch

content

1. Introduction to NoSQL database:

1. An overview of NoSQL databases

2. Reasons for the development of NoSQL technology

3. NoSQL applicable scenarios/inapplicable scenarios

5. Several representatives of NoSQL databases:

6. Which companies are using NoSQL databases?

 2. Introduction to Redis

 1. Get to know Redis

2. Advantages of Redis

 3. How is Redis different from other key-value stores?

4. Redis application scenarios:

 5. Redis Fun Fact: Where does port 6379 come from?


1. Introduction to NoSQL database:

Before introducing redis, let's first understand the NoSQL database.

1. An overview of NoSQL databases

NoSQL (NoSQL = Not Only SQL ), which means "not only SQL", generally refers to non-relational databases .

NoSQL does not rely on business logic to store, but is stored in a simple key-value mode. Therefore, the scalability of the database is greatly increased.

A huge amount of data is generated on the Internet every day on modern computing systems.

A large portion of this data is handled by relational database management systems (RDBMS). In 1970 EF Codd's paper "A relational model of data for large shared data banks" proposed a relational model, which made data modeling and application programming easier.

It has been proved by application practice that the relational model is very suitable for client-server programming, far beyond the expected benefits, and today it is the dominant technology for structured data storage in network and business applications.

NoSQL is a brand-new database revolutionary movement. It was proposed in the early days, and the trend is getting higher and higher in 2009. Advocates of NoSQL advocate the use of non-relational data storage. Compared with the overwhelming use of relational databases, this concept is undoubtedly an injection of new thinking.

summary:

  • Does not follow the SQL standard.

  • ACID is not supported.

  • Far beyond the performance of SQL

2. Reasons for the development of NoSQL technology

1) Web1.0 era

In the era of Web 1.0, the amount of data access is very limited, and most problems can be solved with a high-performance single-point server.

2) Web2.0 era

With the advent of the era of Web 2.0, the number of user visits has increased significantly, and a large amount of user data has been generated at the same time. Coupled with the subsequent popularity of smart mobile devices, all Internet platforms face huge performance challenges.

 

3) Solutions:

1. Solve IO pressure:

 2. Solve CPU and memory pressure

3. NoSQL applicable scenarios/inapplicable scenarios

1) Applicable scenarios:

  • - Read and write data with high concurrency

  • -Read and write massive data

  • - High scalability for data

2) Not applicable scenarios:

  • - Transaction support required

  • - SQL-based structured query storage to handle complex relationships that require ad-hoc queries.

  • - (If you don't need sql and you can't use sql, please consider using NoSql)

4. Advantages/disadvantages of NoSQL

advantage:

  • - High scalability

  • - Distributed Computing

  • - low cost

  • - Schema flexibility, semi-structured data

  • - No complicated relationships

shortcoming:

  • - not standardized

  • - Limited query functionality (so far)

  • - Eventual consistency is an unintuitive procedure

5. Several representatives of NoSQL databases:

1)Memcache

 2)Redis  

 3)MongoDB

6. Which companies are using NoSQL databases?

There are already many companies using NoSQL:

  • - Google
  • - Facebook
  • - Mozilla
  • - Adobe
  • - Foursquare
  • - LinkedIn
  • - Digg
  • - McGraw-Hill Education
  • - Vermont Public Radio

 2. Introduction to Redis

 1. Get to know Redis

Redis is completely open source, complies with the BSD protocol, and is a high-performance key-value database.

Redis and other key-value caching products have the following three characteristics:

  • - Redis supports data persistence, which can save data in memory on disk, and can be loaded again for use when restarted.
  • - Redis not only supports simple key-value type data, but also provides storage of data structures such as list, set, zset, and hash.
  • - Redis supports data backup, that is, data backup in master-slave mode.

2. Advantages of Redis

  • - Extremely high performance - Redis can read 110,000 times/s and write 81,000 times/s.
  • - Rich data types – Redis supports Strings, Lists, Hashes, Sets and Ordered Sets data type operations for binary cases.
  • - Atomic – All operations in Redis are atomic, meaning that they either succeed or fail at all. A single operation is atomic. Transactions are also supported for multiple operations, i.e. atomicity, wrapped by MULTI and EXEC instructions.
  • - Rich features – Redis also supports publish/subscribe, notifications, key expiration and more.

 3. How is Redis different from other key-value stores?

- Redis has more complex data structures and provides atomic operations on them, which is an evolutionary path different from other databases. Redis data types are based on basic data structures and are transparent to programmers without additional abstraction.
- Redis runs in memory but can be persisted to disk, so you need to trade off memory when reading and writing different datasets at high speed, because the amount of data cannot be larger than hardware memory. Another advantage in terms of in-memory databases is that it is very simple to operate in memory compared to the same complex data structures on disk, so Redis can do a lot of things with a lot of internal complexity. At the same time, they are compact in terms of on-disk format and are generated appending because they do not require random access.

4. Redis application scenarios:

1) Cache with relational database

This is the most commonly used scenario for Redis, so Redis often calls it middleware

High-frequency, popularly accessed data, reducing database IO

Distributed architecture for session sharing

2) Various data structures store persistent data

The classic spike project has been particularly prominent in large-scale events such as Double 11 in recent years, which is one of the reasons why major manufacturers love to test Redis.

 

 5. Redis Fun Fact: Where does port 6379 come from?

Using a picture to translate it, 6379 means this:

 

 6379 happens to be Merz, and Merz's full name is Alessia Merz, an Italian actor. MERZ has long been synonymous with stupidity by Redis author antirez and his friends. Later, the author of Redis chose this port when developing Redis.

Guess you like

Origin blog.csdn.net/OMGcome/article/details/123774901