Redis theory Knowledge

Source: Internet
Author: User
Tags redis cluster

Redis theory

Redis and memcached are basically similar, but redis can synchronize data to disk

Redis is an open source, memory-stored data structure server that can be used as a database, cache, and Message Queuing agent.

Cloud Database RDS is a stable and reliable. Scalable online data Service library service. support Mysql SQL Server PPAS ( compatible with orical) based on flying distributed system and full SSD disk High performance storage

Redis is a high-performance key-value database. The advent of Redis has largely compensated for key memcached such as:the lack of value storage , In some cases can be a good complement to the relational database. It provides a Java,c,c++,perl,javascript,python,ruby,erlang,phpwait client , very convenient to use.

Redis Same as the memcached . All data is stored in memory , The difference is Redisasynchronously saved to disk on an asynchronous basis ( This is called "semi-persistent mode"); You can also write every data change to a Append   (

Redis supports master-slave synchronization, data can be synchronized from master to any number of slave ,slave can be associated with other slave 's master.

Benefits of Redis

1.Redis supports not only simple key-values types of data, but also the storage of data types such as list set Zset hash .

2.Redis support data backup , master-slave mode data backup

3.Redis support data persistence, can save in-memory data on disk, restart can be loaded again using

Redisonly caches all theKeyinformation, ifRedisfound that the use of memory exceeds a certain threshold, will triggerSwapthe operation, based on the calculation of whichKeycorresponding to theValuesneed toSwapto disk, and is purged in memory at the same time. This feature can makeRediskeep data larger than the memory size of its machine itself. Of course, the memory of the machine itself must be able to keep all theKeythat this data is not going to beSwapoperation. Also, because the data in memory isSwapto the disk, the main thread of the service is provided and theSwapThe child threads of the operation share this portion of memory, so if an update is required, it will block the operation untilSwapmodifications are not made until the operation is complete.

when reading data from Redis, if you need to load the corresponding data from the swap and return it to the requester, there is an IO thread pool problem. By default,redis is blocked, that is , the swap load is completed before it responds. Therefore, the size of the appropriate IO thread pool is set, and the read request to load data from the swap is processed concurrently, reducing the blocking time.

Redis Sentinel provides highly available

Redis Cluster provides automatic partitioning

Gearman

using Gearman to implement redis cache MySQL

Gearman is a distributed task-distribution framework that supports :

The Gearman Job server:gearman Core program needs to be compiled and installed and run in the background as a daemon. Daemon , maintaining a queue.

Gearman Client: can be understood as a requester of a task.

Span style= "font-family: ' founder of the book Song _gbk '; > In general, you need to write your own logic and run the gearman Client

Approximate process : The following MySQL trigger to write is equivalent to the Gearman client. To modify a table , inserting a table is equivalent to sending a task directly. Then through the lib_mysqludf_json UDF (User defined functions) JSON format Span style= "font-family: ' founder of the book Song _gbk '; > and then in through gearman-mysql-udf plug-ins add tasks to the gearman finally through redis_worker.ph P(worker.php asynchronously replicates MySQL data to redis) , which is the worker side of Gearman to complete The update of the Redis database.

the best way for MySQL to interoperate with external programs is through the MySQL UDF (user defined functions) . In order for MySQL to be able to pass data into the gearman , it uses the Lib_mysqludf_json UDF Library function maps relational data to JSON format (Gearman only accepts strings as entry parameters) , and then Add the task to the gearman task Queue via the GEARMAN-MYSQL-UDF plugin.


This article from the "11841085" blog, reproduced please contact the author!

Redis theory Knowledge

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.