Redis Tutorial (i): Redis profile _redis

Source: Internet
Author: User
Tags data structures hash memcached mongodb redis redis server redis tutorial


First, Introduction:



In the past few years, NoSQL database has become a high concurrency, a large number of data storage solutions synonymous with the corresponding products also appear to be springing up the vitality. However, there are only a handful of products that can stand out, such as Redis, MongoDB, BerkeleyDB and Couchdb. Because each product has different characteristics, so there are some differences in their application scenarios, the following only gives a simple explanation:



1. BerkeleyDB is an extremely popular open source embedded database that can be used in more cases for storage engines, such as the storage engine used by BerkeleyDB as MySQL before it was acquired by Oracle, and it can be foreseen that the product has excellent concurrency scalability, Support for transactions and nested transactions, massive data storage and other important features, in the storage of real-time data has a very high value of available. It should be noted, however, that the licence of the product is the GPL, which means that it is not used for free in all cases.



2. The definition of MongoDB is oriented-document database server, unlike BerkeleyDB, the database can run independently and provide related data services as other relational database servers. From the official documentation of the product, we can learn that MongoDB is mainly applicable to high concurrent forums or blog sites, which are characterized by high concurrent traffic, less reading and writing, large amount of data, simple logical relationships, and document data as the primary data source. Like BerkeleyDB, the license of the product is the same as the GPL.



3. Redis, a typical NoSQL database server, can run on its own server host as a service program, compared to BerkeleyDB. In many cases, people simply regard Redis as a Key/value database server, but this is not the case, and in the current version, Redis supports the list, Hash, set, and ordered set data structures in addition to key/value. So it's more broadly used. Regarding this kind of misunderstanding, Redis official website also has carried on the corresponding clarification. Unlike the above two products, Redis's License is Apache License, and for now it is completely free.



4). memcached, data caching server. Why do you give an explanation of the product here? It's very simple, because I think it's the most similar to Redis in terms of usage. After all, this is a series of technical blogs about Redis, in view of this, we will briefly compare these two products. First of all, the biggest difference between them, memcached only provides data caching services, once the server down, the memory before the cached data will all disappear, so you can see that memcached does not provide any form of data persistence, and Redis provides such functionality. Another is that Redis provides richer data storage structures, such as hash and set. As for their similarities, there are mainly two, one is completely free, and then there is the form of order that they provide is very close.

second, the advantages of Redis:



1. Compared with other NoSQL products, Redis is very easy to use, so for developers with similar product experience, a day or two or even a few hours later can use Redis to build their own platform.
2. In the solution of a lot of universal problems, but also for some personalized issues related to the solution, such as indexing engine, statistics ranking, Message Queuing services.



Third, the current version of the Redis existing problems:



1. There is no support for the Windows platform in the official version, and the published version only supports Unix-like and MACOSX platforms.
2. There is no cluster support, but according to the official website, this feature is expected to be included in version 2.6.
3. Publication/subscription functionality, slave cannot be automatically promoted to master if Master is down.

fourth. comparison with relational databases:



      in the Redis of the current version (2.4.7) provides support for five different data types, with only one type, which can be considered as a key-value structure. Other data types have applications that apply to their respective features, and we will explain the details in the blogs that follow the series.
      compared to relational databases, because of their relatively simple storage structure, Redis does not provide good support for complex logical relationships, but in scenarios that apply to Redis, We can thus achieve a significant increase in efficiency. Even so, Redis provides us with some basic concepts that a database should have, such as: You can choose to open a different database in the same connection, but the database in Redis is named by number, and the database opened by default is 0. If the program is going to switch the database while it is running, you can use the Redis Select command to open other databases, such as Select 1, and if you want to switch back to the default database later, simply perform select 0.
      in data storage, Redis follows the mainstream idea of the existing NoSQL database, that is, key as the unique identification of data retrieval, we can simply understand it as the key of the index in the relational database, Value is the main object of data storage, where each value has a key associated with it, which is like the location of the physical data stored in the data table in the index. In Redis, value will be treated as a binary byte stream to store data in any format, such as JSON, XML, and byte streams of serialized objects, so we can also think of it as a blob type field in Rdb. Thus, in the data query, we can only be based on key as our query conditions, of course, we can also apply some of the techniques provided in the Redis value as the key to other data, which we will be introduced in the blog later.
   
fifth. How to persist memory data:



      By default, Redis will refer to the number of data being modified in the current database, and the snapshot of the database will be stored on disk after a certain threshold is reached, which we can set by the configuration file. In general, we can also set the Redis as a timed save. If more than 1000 key data is modified, Redis will perform data persistence every 60 seconds. The default setting is that if 9 or 9 of the following data modifications are available, Redis will be persisted every 15 minutes.
      as can be seen from the scenario mentioned above, if this is the case, the run-time efficiency of the redis will be very efficient, and when new data modifications occur, only the cached data in memory changes, This change will not be immediately persisted to disk, thus avoiding the occurrence of disk IO in most of the modification operations. However, there are always two sides to the matter, in which we do get an increase in efficiency, but lose the reliability of data. If the server on which the Redis resides is down before the memory snapshot is persisted to disk, the modified data that is not written to disk will be lost. In order to ensure the high reliability of data, Redis also provides another kind of data persistence mechanism--append mode. If the Redis server is configured to do so, it will be immediately persisted to disk whenever data modifications occur.
   


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.