Twemproxy – Twitter 开源的 Redis proxy
在去年的QCon London2012 大会上,Twitter 发表了题为 《Timelines @ Twitter》的演讲,里面提到以 Redis 作为其timeline的主要存储,目前目测全球范围内,Twitter可能是Redis的最大用户了(或者是新浪微博?)。 而今天我们要说的这个Twemproxy,是 Twitter
在去年的QCon London2012 大会上,Twitter 发表了题为 《Timelines @ Twitter》的演讲,里面提到以Redis作为其timeline的主要存储,目前目测全球范围内,Twitter可能是Redis的最大用户了(或者是新浪微博?)。
而今天我们要说的这个Twemproxy,是 Twitter 开源出来的 Redis 和 Memcached 代理。
功能介绍
我们知道,无论是 Memcached 还是当前的 Redis,其本身都不具备分布式集群特性,当我们有大量 Redis 或 Memcached 的时候,通常只能通过客户端的一些数据分配算法(比如一致性哈希),来实现集群存储的特性。
而 Twemproxy 通过引入一个代理层,可以将其后端的多台 Redis 或 Memcached 实例进行统一管理与分配,使应用程序只需要在 Twemproxy 上进行操作,而不用关心后面具体有多少个真实的 Redis 或 Memcached 存储。
在 Redis 的 Cluster 方案还没有正式推出之前,通过 Proxy 的方式来实现存储集群可能是最好的选择了。更何况 Twemproxy 是通过 Twitter 自身得到了充分检验的产品。
性能
根据 Redis 作者的测试结果,在大多数情况下,Twemproxy 的性能相当不错,直接操作 Redis 相比,最多只有20%的性能损失。这对于它带来的好处来说真的是微不足道了。唯一可能还有待改进的是其 MGET 操作的效率,其性能只有直接操作 Redis 的 50%。
安装与配置
Twemproxy 的安装有点小麻烦,主要命令如下:
apt-get install automake apt-get install libtool git clone git://github.com/twitter/twemproxy.git cd twemproxy autoreconf -fvi ./configure --enable-debug=log make src/nutcracker -h
通过上面的命令就算安装好了,然后是具体的配置,下面是一个典型的配置
redis1: listen: 0.0.0.0:9999 #使用哪个端口启动Twemproxy redis: true #是否是Redis的proxy hash: fnv1a_64 #指定具体的hash函数 distribution: ketama #具体的hash算法 auto_eject_hosts: true #是否在结点无法响应的时候临时摘除结点 timeout: 400 #超时时间(毫秒) server_retry_timeout: 2000 #重试的时间(毫秒) server_failure_limit: 1 #结点故障多少次就算摘除掉 servers: #下面表示所有的Redis节点(IP:端口号:权重) - 127.0.0.1:6379:1 - 127.0.0.1:6380:1 - 127.0.0.1:6381:1 - 127.0.0.1:6382:1 redis2: listen: 0.0.0.0:10000 redis: true hash: fnv1a_64 distribution: ketama auto_eject_hosts: false timeout: 400 servers: - 127.0.0.1:6379:1 - 127.0.0.1:6380:1 - 127.0.0.1:6381:1 - 127.0.0.1:6382:1
你可以同时开启多个 Twemproxy 实例,他们都可以进行读写,这样你的应用程序就可以完全避免所谓的单点故障。
问题与不足
Twemproxy 由于其自身原理限制,有一些不足之处,如:
- 不支持针对多个值的操作,比如取sets的子交并补等(MGET 和 DEL 除外)
- 不支持Redis的事务操作
- 出错提示还不够完善
更多
更多关于Twemproxy的介绍可以看这里:http://antirez.com/news/44
Twemproxy的项目地址:https://github.com/twitter/twemproxy
42区 VPS
42qu.com 云主机 , 卖给创业的你 。 点击这里 , 查看详情

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'embed_rssfooter' not found or invalid function name in /home/b55/htdocs/blog.nosqlfan.com/wp-includes/plugin.php on line 166


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Want to learn the Laravel framework, but suffer from no resources or economic pressure? This article provides you with free learning of Laravel, teaching you how to use resources such as online platforms, documents and community forums to lay a solid foundation for your PHP development journey from getting started to master.

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Laravel 8 provides the following options for performance optimization: Cache configuration: Use Redis to cache drivers, cache facades, cache views, and page snippets. Database optimization: establish indexing, use query scope, and use Eloquent relationships. JavaScript and CSS optimization: Use version control, merge and shrink assets, use CDN. Code optimization: Use Composer installation package, use Laravel helper functions, and follow PSR standards. Monitoring and analysis: Use Laravel Scout, use Telescope, monitor application metrics.

In SpringBoot, use Redis to cache OAuth2Authorization object. In SpringBoot application, use SpringSecurityOAuth2AuthorizationServer...

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.

Cryptocurrency data platforms suitable for beginners include CoinMarketCap and non-small trumpet. 1. CoinMarketCap provides global real-time price, market value, and trading volume rankings for novice and basic analysis needs. 2. The non-small quotation provides a Chinese-friendly interface, suitable for Chinese users to quickly screen low-risk potential projects.

The best cryptocurrency trading and analysis platforms include: 1. OKX: the world's number one in trading volume, supports multiple transactions, provides AI market analysis and on-chain data monitoring. 2. Binance: The world's largest exchange, providing in-depth market conditions and new currency first-time offerings. 3. Sesame Open Door: Known for spot trading and OTC channels, it provides automated trading strategies. 4. CoinMarketCap: an authoritative market data platform, covering 20,000 currencies. 5. CoinGecko: Known for community sentiment analysis, it provides DeFi and NFT trend monitoring. 6. Non-small account: a domestic market platform, providing analysis of linkage between A-shares and currency markets. 7. On-chain Finance: Focus on blockchain news and update in-depth reports every day. 8. Golden Finance: 24 small

This article summarizes the information of the top ten virtual currency trading platform APPs, emphasizes the importance of secure access to the platform through official channels, and provides verification methods. At the same time, the article reminds investors to consider factors such as security, transaction fees, currency selection when choosing an APP, and pay attention to the risks of virtual currency trading.
