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

AI Hentai Generator
Generate AI Hentai for free.

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

The rapid development of blockchain technology has brought about the need for reliable and efficient analytical tools. These tools are essential to extract valuable insights from blockchain transactions in order to better understand and capitalize on their potential. This article will explore some of the leading blockchain data analysis tools on the market, including their capabilities, advantages and limitations. By understanding these tools, users can gain the necessary insights to maximize the possibilities of blockchain technology.

Have you installed cameras in your home? In recent years, home camera products have suddenly become a hit. I asked my friends around me, and boy, every house has one, and some even have more than one. However, with the popularity of the product, it has also brought some complaints during use. For example, you can only see one place at the same time, and if you want to see other places, you have to adjust the pan/tilt and rotate the camera back and forth. There is a certain blind spot and time difference when viewing the picture; or when you want to take a closer look at a certain location in your home, you find that the picture is blurry and you cannot see it at all. Clarity; etc... The experience is greatly compromised. Honor Select and Xiaopai Technology jointly launched the Honor Select Xiaopai Smart Camera Pro featuring "three lenses and dual images". Provides new solutions to industry and user pain points

In today's thousand-yuan phone market, battery life and appearance have become the focus of many consumers. After all, for most people, a mobile phone must not only meet the basic needs of daily use, but also have long-lasting power to cope with long-term use. At the same time, having a pleasing appearance design can add points to the use experience. few. The vivo Y37Pro is such a thousand-yuan phone that performs well in terms of battery life and appearance. Appearance vivoY37Pro has a simple and stylish appearance. Back panel: Special process treatment, not easy to leave fingerprints. Middle frame: full of metal texture. Color: apricot sea, dark night, city in the sky. Layout of the rear camera module: the upper left corner of the back panel. SIM card slot: left side of the fuselage. Volume buttons and power button: right side of the fuselage. interface

According to news on August 22, as the release of Samsung’s new generation flagship mobile phone S25 Ultra approaches, more and more details are beginning to emerge. The well-known blogger @ibinguniverse revealed more specifications of the S25 Ultra on Weibo today. The most eye-catching one is that its body width is the same as the Apple iPhone 16 Pro Max, both 77.6mm. 1. Thanks to Samsung’s further optimization of the frame design, the screen size of the S25 Ultra has been increased to 6.86 inches while maintaining the same width as the iPhone 16 Pro Max, providing users with a more immersive visual experience. The blogger further pointed out in the comment area that the black edges of the S25 Ultra are better than those of the iPhone 16 Pro Max&

Zero Zero Technology, the pioneer of flying cameras, announced the launch of the Harvard flying cameras X1PRO and X1PROMAX, and launched crowdfunding on Indiegogo in the early morning of August 27, Beijing time. Within 145 minutes of being online, the crowdfunding amount exceeded one million US dollars, creating the first flying camera. New record. As the world's first and most advanced flying action cameras, these two products redefine the flying shooting experience and are especially suitable for sports enthusiasts and professional content creators. Hafu flying cameras X1PRO and X1PROMAX are portable and foldable, eliminating the need for a remote control interactive experience. X1PROMAX: 1/1.3-inch CMOS sensor, customized 7-layer lens. 8K video, 14 stops of dynamic range, 107° wide-angle field of view. Customizable ND filters. X

DeepSeek, a comprehensive search engine that provides a wide range of results from academic databases, news websites and social media. Visit DeepSeek's official website https://www.deepseek.com/, register an account and log in, and then you can start searching. Use specific keywords, precise phrases, or advanced search options to narrow your search and get the most relevant results.

The Bitget Exchange offers a variety of login methods, including email, mobile phone number and social media accounts. This article details the latest entrances and steps for each login method, including accessing the official website, selecting the login method, entering the login credentials, and completing the login. Users should pay attention to using the official website when logging in and properly keep the login credentials.

This cryptocurrency does not really have monetary value, and its value depends entirely on community support. Investors must carefully investigate before investing, because it lacks practical uses and attractive token economic models. Since the token was issued last month, investors can currently only purchase through decentralized exchanges. The real-time price of MRI coin is $0.000045≈¥0.00033MRI coin historical price As of 13:51 on February 24, 2025, the price of MRI coin is $0.000045. The following figure shows the price trend of the token from February 2022 to June 2024. MRI Coin Investment Risk Assessment Currently, MRI Coin has not been listed on any exchange and its price has been reset to zero and cannot be purchased again. Even if the project
