In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Redis theory
Redis is basically similar to memcached, except that redis can synchronize data to disk
Redis is an open source, in-memory data structure server that can be used as a database, cache and message queue agent.
Cloud database RDS is stable and reliable. Scalable online data service library service. Based on Feitian distributed system and full SSD disk high performance storage, support Mysql sql server PPAS (compatible with ORICAL)
Redis is a high-performance key-value database. The emergence of redis makes up for the deficiency of key:value storage such as memcached to a great extent, and can play a good complementary role to relational database in some cases. It provides clients such as java,C,C++,perl,JavaScript,Python,Ruby,Erlang,PHP, which is easy to use.
Redis, like memcached, keeps all data in memory, except that redis periodically saves it to disk asynchronously (this is called "semi-persistent mode"); it can also write each data change to an append only file (aof) (this is called "full persistence mode").
Redis supports master-slave synchronization. Data can be synchronized from master to any number of slave. Slave can be the master associated with other slave.
Advantages of Redis
1.redis not only supports simple key-values type data, but also supports storage of data types such as list set zset hash.
2.Redis supports data backup, data backup in master-slave mode
3.Redis supports data persistence. Data in memory can be saved on disk and can be loaded and used again when rebooting.
Redis only caches all key information. If redis finds that the use of memory exceeds a certain threshold, it will trigger the operation of swap, calculate which values corresponding to key needs to swap to disk, and clear it in memory at the same time. This feature allows redis to maintain more data than the memory of its machine itself. Of course, the machine's own memory must be able to maintain all the key, this data will not be swap operations. At the same time, when the data in memory is swap to disk, the main thread providing the service and the sub-thread performing the swap operation will share this part of the memory, so if an update is needed, the operation will be blocked until the swap completes the operation.
When reading data from redis, if you need to load the corresponding data from swap and return it to the requester, there is a problem of IO thread pool. By default, the redis will block, that is, it will not respond until the swap load is complete. Therefore, the appropriate size of the IO thread pool is set, and the read requests loading data from the swap are processed concurrently to reduce the blocking time.
Redis Sentinel provides high availability
Redis Cluster provides automatic partitioning
Gearman
Using gearman to realize redis cache mysql
Gearman is a distributed task distribution framework:
The Gearman Job Server:Gearman core program needs to be compiled and installed and run in the background in the form of a daemon. The background daemon maintains a queue.
Gearman Client: can be understood as the requestor of the task.
Gearman Worker: the real executor of a task usually needs to write its own logic and run it through a daemon. When Gearman Worker receives the task content passed by Gearman Client, it will process it sequentially.
General process: the mysql trigger to be written below is equivalent to the client of Gearman. Modifying the table and inserting the table is equivalent to sending tasks directly. Then map the relational data to JSON format through the lib_mysqludf_json UDF (user defined functions) library function, then add the task to the task queue of Gearman through the gearman-mysql-udf plug-in, and finally complete the update of the redis database through redis_worker.php (worker.php copies the mysql data to redis asynchronously), that is, the worker side of Gearman.
The best way for Mysql to communicate with external programs is through mysql UDF (user defined functions). To enable mysql to pass data into gearman, the lib_mysqludf_json UDF library function is used here to map relational data to JSON format (gearman only accepts strings as entry parameters), and then adds tasks to the Gearman task queue through the gearman-mysql-udf plug-in.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.