Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

Some concepts about NoSQL database-Redis

Par Jingwei BAI Publié le 06/01/2019 à 06:32:36 Noter cet article:
(0 votes)
Avis favorable du comité de lecture

1.1 What is Redis ?

1.1.1 What is NoSQL ?

1.1.2 Why use NoSQL ?

1.1.3 NoSQL features

1.2 Why use the Redis ?

1.2.1 Concept

1.2.2 Redis Advantages

1.2.3 Redis is single-process single-threaded.

1.2.4 Why does Redis need to put all the data into memory ?

1.2.5 Data types supported by Redis

1.3 Redis recycle strategy

1.4Conclusion

1.5 Bibliography

1.1 What is Redis ?

Redis is an open source, Key-Value database written in C that supports network interaction and can be persisted based on memory.

Redis's official website address, very easy to remember, is the www.redis.io. (Intentionally checked, the domain name suffix -io belongs to the national domain name, which is the British Indian Ocean territory, that is, the British Indian Ocean Territory)

Currently, VMware is funding the development and maintenance of the redis project.

1.1.1 What is Nosql ?

NoSQL (NoSQL=Not Only SQL), meaning "not just SQL", refers to a non-relational database.

About relational databases and NoSQL databases: A relational database is a relational table-based database that eventually persists data to disk, while a NoSQL database is based on a special structure and stores data in a memory database.

In terms of performance, NoSQL database is better than relational database. From the perspective of security, relational database is better than NoSQL database.

Therefore, in actual development, NoSQL and relational database will be used together in one project to achieve performance and performance. Double guarantee of security.

1.1.2 Why use NoSQL ?

With the rise of the Internet web2.0 website. The traditional off-system database has been unable to cope with the ultra-large-scale and high-concurrency SNS type web2.0 pure dynamic website.

  • High performance - high concurrent read and write requirements for the database :

  • The web2.0 website needs to generate dynamic pages and provide dynamic information in real time according to the user's personalized information, so the dynamic page static technology cannot be basically used. Therefore, the database concurrent load is very high, and often tens of thousands of read and write requests per second are required. The relational database is still barely able to withstand tens of thousands of SQL queries, but with tens of thousands of SQL write data requests, hard disk IO can no longer afford. In fact, for ordinary BBS websites, there is often a need for high concurrent write requests, such as real-time statistics on the online user status of the website, recording the number of clicks on popular posts, voting counts, etc., so this is a fairly common demand.

  • Large scale Storage - the need for efficient storage and access to massive amounts of data :

  • Similar to the SNS website like Facebook, users generate massive user dynamics every day. For relational databases, SQL queries in a table of 250 million records are extremely inefficient and unbearable.

  • High Scalability && High Availability - High scalability and high availability requirements for databases:

  • In the web-based architecture, the database is the most difficult to scale horizontally. When the number of users and accesses of an application system increases day by day, your database has no way to add more as simple as web server and APP server. Hardware and service nodes to extend performance and load capacity. For many websites that need to provide 24 hours of uninterrupted service, upgrading and expanding the database system is very painful. It often requires downtime maintenance and data migration. Why can't the database be extended by continuously adding server nodes ?

1.1.3 NoSQL features.

  • Easy to expand

  • Flexible data model

  • Large amount of data, high performance

  • High availability

  • High-performance key-value pair database, supported key-value data types: string type, list type, ordered collection type, hash type, collection type.

1.2 Why use redis ?

1.2.1 concept

Redis is essentially a Key-Value type of in-memory database, much like memcached. The entire database is loaded into memory for operation. Periodically, the database data is flushed to the hard disk for storage. Because it is a pure memory operation, Redis has excellent performance and can handle more than 100,000 read and write operations per second. It is the fastest known Key-Value DB.

1.2.2 Advantages of using Redis

  • Single-threaded, using redis queue technology and turning access into serial access, eliminating the overhead of traditional database serial control

  • redis has fast and persistent features that are fast because data is stored in memory.

  • Support transactions, operations are atomic, the so-called atomicity is to change the data or all of them, or not all.

  • Can be used for caching, messages, set expiration time by key, automatically delete after expiration

  • Support rich data types

  • Distributed read and write separation mode

1.2.3 Redis is single-process single-threaded

Redis uses queue technology to turn concurrent access into serial access, eliminating the overhead of traditional database serial control.

1.2.4 Why does Redis need to put all the data into memory ?

  • Redis reads data into memory for the fastest read and write speeds and writes the data to disk asynchronously. So Redis has the characteristics of fast and data persistence. If you do not put data in memory, disk I/O speed can seriously affect the performance of Redis. Today, Redis will become more and more popular as memory becomes more and more cheaper.

  • If the maximum used memory is set, the new value cannot be inserted after the data has reached the memory limit.

1.2.5 Data types supported by Redis

Redis is distinguished by the unique value of Key-Value. The following are supported types:

  • Strings

  • Lists

  • Hashes

1.3 Redis recycle strategy

Eliminate data that will expire due to phase-out from least recently used data.

  • Volatile-lru : pick the least recently used data from the data set (server.db[i].expires) with the expiration time set

  • Volatile-ttl : Select data to be expired from the data set (server.db[i].expires) with the expiration time set

  • Volatile-random : arbitrarily select data from the data set (server.db[i].expires) with the expiration time set

  • Allkeys-lru : pick the least recently used data from the dataset (server.db[i].dict)

  • Allkeys-random : arbitrarily select data from the data set (server.db[i].dict)

  • No-enviction : prohibit eviction data

1.4 Conclusion

Through reading this article, you will have a preliminary understanding of Redis, the essence of Redis, the core concept of redis, the recycling mechanism of Redis, and the working principle of Redis, etc., you will have a comprehensive understanding.

1.5 Bibliography

https://www.tutorialspoint.com/redis/

https://www.javatpoint.com/redis-tutorial

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels