Hey guys, welcome To Alibaba Zero courses. Today's topic is about the Redis database, we will have an introduction about the radius, what is Redis, and what is deep inside of it. And today is the first topic we will have some basic concept about the Redis database. So let's get started, and the first section about this topic is about what is Redis? Firstly we should know that Redis is not a purely man made word, but aggravation for free remote dictionary server. Basically, you can just understand it is kind of database, but more than that, you can also use it as a catch system or a message broker as well. And secondly, as a little bit system, especially a caste system British can support several kinds of database structures like strings, hashes, lists, sets, sorted sets with the rent queries. And what is more than catching the base Redis also have a building replication, Louis, scripting LRU infection transactions at different levels of un disc persistence applies, okay. And finally taking advantage of Redis, sentinel and the Redis cluster. We can easily make readies as a high availability cluster and distributed partition the deployment mode. So far, all features mentioned above, we will have detailed explanation one by one in the coming courses, so just be patient and then let's move on. Just now we have a brief understanding about what is Redis, so for the next section we will have introduction about what we can do with Redis. So basically, we can say that releases many aiming to catch structure data which is required to be excessive frequently. Like if you have some data which is stored in the physical database, but maybe you want to make the data can be accessed with quite low latency and high throughput, right? And then you can use Redis, okay, and since all the data in the released is stored in memory instead of disk, correct? And when you get the data from memory on one hand you will have a very high performance. And on the other hand, the right pressure on the physical database can be reduced sharply. This is a very big advantage you can get from Redis, and so from the diagram on the right we can see ready and the database are DBMS. Is two separate system when some data is accessed from the first time the data will be fetched from the DBMS, and at the same time the access the data will be Catched in the Redis. So later on when the catch data is accessed again by the application or by other applications,it can be fetched from the reading with much higher performance than the first time it is being accessed. So this is the basic working mechanism for release Catch and then let's move on. So the next section is about why we will use Redis, in this section we will have an introduction about some of the features about the Redis. Okay, so first things first, the biggest benefit that we can get from Redis is high for performance, right? So we can see from the diagram on the right, we can see that when the data size is waiting 1500 bytes, no matter with which method you are connecting the Redis. The through put can be kept in a quite high level, right, and also no matter the data size you get from release is 100 bites or the 1000 bytes. The throughput can be kept in a quite high level as well, so that is because all the data is stored in the memory, so which is more faster than the disk performance. So as long as the data size is smaller than ethnic package size, the Redis performance always be able to keep in a high level. That is truly a big benefit that we can get from memory storage, and one more thing for better performance consideration since ready is single threat worrying mode. So this is suggested that to run multiple Redis instance in one server, if the server is hosted, multi core CPU hardware. So this is the suggestion, how can you make the full usage of the host when you want to run the Redis on some of the servers? Okay, so let's move on to the next part of the Redis, this is about the Redis data structures different from other caste systems like the memo catch. Maybe you heard about it off this, Redis can support multiple data structures for different business scenario. So the first death structure like that I'd like to introduce to you is the string which is also the most basic key value structure. And you can define one key name and one corresponding value, like you can give the key name is name and the value is China or some other name as you like. And the four different structure, there are different comments that you can use to operate the structure, for the string you can use the get comment to fetches the data and the set, comment to set or change the value. And also you can use the DM means the delete comment to delete the value for specified key. And the next structure is List, unlike stream who can only store one key, at the least structure can store multiple values under one key. And also the value stored is ordered in sequence, so you can put new values from the left side or right side of the list. But he cannot put in the middle, and you can also get anyone or range of value from the list, okay. So with features mentioned above, list structure is usually used as message queue in the business. Okay, so let's move on to the next one. The next one is Set, similar with list, Set is used to store multiple values under one key, but what is different is that values in the set must be unique. So normally set is used to eliminate the duplicated object in the business logic. Okay, the next structure is hash for easy understanding hash is just like a table, which you have known in the in some normal RDBDBMS, in one hash key. You can store multiple key value pairs, which is similar as a string structure, so just like the structure showing on the right side. Okay, so let's move on to the next one. This is also the last one structure I'd like to, I'd like to introduce to you. The name is Zset, from the name, we can see that it is another kind of set compared with set every value in the Zset is not a single value. Actually it has one attributes, named, score, each value has one score. So the score can only be floating point numbers and most importantly all the values in the set is ordered by the score value. So this set is normally used in the wrecking business scenario. Okay, so what has been introduced just now is all structures in Redis. So let's move on to the next feature of Redis, in the first light we have introduced that Redis can work in a mode, right? So basically the high availability is based on the replication mechanism of release. So from the diagram on the right side of this light, we can see that in the Redis replication relationship, there will be one master note and the multiple slave node. Even the slave node can be created based on another slave node, recursively, and many there are to benefit you can get from the master and the slave architecture. One is that you can make advantage of the slave node to run the read only request like the data inquiry to share the load of the master note. And another one is that replication from the master to the slave is non blocking mode which means they're normal data changes on the master node will not be impacted by the replication. This is very important, and also the replication can support break point resume caused by the network flash. So you don't have to rethink all the data are due to the short time replication breaking. And finally, there is a small list that if you are using Redis cluster, this kind of recursive replication is not supported. Okay, lets come to the last part of the Redis is about the data persistence of Redis. Since we have known that the Redis is kind of caste system which means the data in the reading is sourced from the RPMS, just like the data in the reading is on our air. Right, but actually Redis itself can also support to make the data persistent in the disk just like the normal RGBMS. So generally there are two options, actually is two different mechanism, you can use to make the Redis data persistent on the disk. The first one is RDB, which is based on the point in time snapshots for the whole Redis, and you can set the specified interval of the snapshot. After each time of the snapshot of the data is in the Redis memory will become consistent with the data on the disk. And the second one is AOF, which is based on the locks for each of the changes made on the Redis. And you can set the log is written on the disk, synchronized lee with the changes or and synchronized Li per second. So obviously, we can see that the UF mode have a higher data protection right, from the data loss compared with the RDB mode. But consequently since the AOF is based on the locks, right? So it required far more storage space than the RDB mode to store all the logs because the logs has occupied a big amount of the storage space. And also it will take more time to recover the Redis than our RGB mode when the Redis system is broken since it will replay all the locks from the beginning. So that is the reason why it will take a long time. Okay, so that's all the things for the Redis basic concept introduction, thank you for watching and see you next time.