Redis application scenarios

Source: Internet
Author: User

1. MySql + Memcached architecture Problems

MySQL is suitable for storing massive data. Many companies have used this architecture to load hotspot data to the cache through Memcached to accelerate access. However, as the business data volume increases, and the continuous growth of access traffic, we have encountered many problems:

1. MySQL needs to constantly split databases and tables, and Memcached also needs to be scaled up. resizing and maintenance take a lot of development time.

2. Data Consistency between Memcached and MySQL databases.

3. The Memcached data hit rate is low or goes down, and a large number of accesses directly penetrate into the database, which is not supported by MySQL.

4. cache synchronization across data centers.

How to choose a large number of NoSQL Databases

In recent years, many NoSQL products have emerged in the industry, so how can we properly use these products and maximize their strengths is a problem that we need to study and think deeply, in the final analysis, the most important thing is to understand the positioning of these products, as well as the tradeoffs of each product. In practice, these NoSQL products are used to solve the following problems.

1. A small amount of data is stored for high-speed read/write access. This type of product ensures high-speed access through all the data in-momery and provides the data landing function. This is the main application scenario of Redis.

2. Massive Data Storage, distributed system support, data consistency assurance, and convenient addition/deletion of cluster nodes.

3. The most representative of this is the ideas described in dynamo and bigtable. The former is a completely decentralized design, and cluster information is transmitted between nodes through the gossip method to ensure data consistency. The latter is a centralized solution design, similar to a distributed lock service to ensure strong consistency, data is written to the memory and redo log first, and then compat is periodically merged to the disk to optimize random write to sequential write, improving write performance.

4. Schema free and auto-sharding. For example, some common document databases currently support schema-free, directly store json data, and support auto-sharding and other functions, such as mongodb.

In the face of these different types of NoSQL products, we need to select the most appropriate product based on our business scenarios.

Redis is most suitable for all data in-momory scenarios. Although Redis also provides persistence functions, it is actually a disk-backed function, there is a big difference from the persistence in the traditional sense, so you may be wondering, it seems that Redis is more like an enhanced version of Memcached, so when Will Memcached be used and when will Redis be used?

If we simply compare the difference between Redis and Memcached, most people will get the following points:

1. Redis not only supports Simple k/v data, but also provides storage of data structures such as list, set, zset, and hash.

2. Redis supports data backup, that is, data backup in master-slave mode.

3. apsaradb for Redis supports data persistence. Data in the memory can be stored on the disk, and can be loaded and used again upon restart.

2. Common Redis Data Types

Redis has the following common data types:

String

Hash

List

Set

Sorted set

Pub/sub

Transactions

Before describing these data types, let's take a look at how Redis's internal memory management describes these different data types:

Redis uses a redisObject object to represent all keys and values. The primary information of redisObject is shown in:

Type indicates the specific data type of a value object,

Encoding is a storage method for different data types in redis,

For example, if type = string indicates that value is stored as a normal string, the corresponding encoding can be raw or int, if it is an int, it indicates that the actual redis instance stores and represents the string by numeric type. Of course, the premise is that the string itself can be represented by numerical values, for example: "123" "456.

Note the vm field here. This field is actually allocated only when the Redis virtual memory function is enabled. This function is disabled by default, this function will be described later. Redis uses redisObject to indicate that all key/value data is a waste of memory, of course, these memory management costs are mainly paid to provide a unified management interface for different Redis data types. The actual author also provides a variety of methods to help us minimize memory usage, we will discuss it in detail later.

Recommended reading:

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page

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.