简介 twemproxy,也叫nutcracker,是twtter开源的redis和memcache代理服务器。 功能 Fast. Lightweight. Maintains persistent server connections. Keeps connection count on the backend caching servers low. Enables pipelining of requests and respon
<span style="font-family: Arial, Verdana, sans-serif;">简介</span>
twemproxy,也叫nutcracker,是twtter开源的redis和memcache代理服务器。
从官网下载安装包编译并安装:distribution tarball:
[root@~/software/nutcracker-0.3.0]# ./configure --prefix=/usr/local/nutcracker-0.3.0 [root@~/software/nutcracker-0.3.0]# make [root@~/software/nutcracker-0.3.0]# make install [root@~/software/nutcracker-0.3.0]# cp -R conf /usr/local/nutcracker-0.3.0 [root@~/software/nutcracker-0.3.0]# ln -s /usr/local/nutcracker-0.3.0 /usr/local/nutcracker [root@~/software/nutcracker-0.3.0]# ln -s /usr/local/nutcracker/sbin/nutcracker /usr/local/bin/nutcracker
twemproxy支持通过YAML语法配置,其支持的指令集如下:
listen: The listening address and port (name:port or ip:port) for this server pool.以本文为例,配置一个Redis代理和一个Memcache代理服务如下:
[root@~/software/nutcracker-0.3.0]# cat /usr/local/nutcracker/conf/nutcracker.yml
alpha:
listen: 127.0.0.1:22121
hash: fnv1a_64
hash_tag: "{}"
distribution: ketama
auto_eject_hosts: false
timeout: 400
redis: true
servers:
- 127.0.0.1:6379:1
beta:
listen: 127.0.0.1:22122
hash: fnv1a_64
distribution: ketama
timeout: 400
backlog: 1024
preconnect: true
auto_eject_hosts: true
server_retry_timeout: 2000
server_failure_limit: 3
servers:
- 127.0.0.1:11211:1
- 127.0.0.1:11212:1
其中,Redis实例 127.0.0.1:6379 和 Memcache实例 127.0.0.1:11211 127.0.0.1:11212 请预先启动好。
/etc/init.d/redis_6379 start /usr/local/memcached-1.4.20/bin/memcached -d -m 64 -l 127.0.0.1 -p 11211 -u root /usr/local/memcached-1.4.20/bin/memcached -d -m 64 -l 127.0.0.1 -p 11212 -u root
https://github.com/billfeller/billfeller.github.io/blob/master/code/twenproxyTest.php
启动服务:
[root@/usr/local/nutcracker/conf]# nutcracker -c nutcracker.yml [Sun Dec 14 20:59:04 2014] nc.c:187 nutcracker-0.3.0 built for Linux 2.6.32-431.23.3.el6.x86_64 x86_64 started on pid 14359 [Sun Dec 14 20:59:04 2014] nc.c:192 run, rabbit run / dig that hole, forget the sun / and when at last the work is done / don't sit down / it's time to dig another one
执行测试脚本:
[root@~/wade/git/billfeller.github.io/code]# /usr/local/php/bin/php twenproxyTest.php bool(true) string(1) "1" int(1) bool(false) bool(true) int(2) bool(true) int(3) bool(true) bool(false)
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号