The invention discloses a Redis clustering method based on twemproxy, which relates to the field of buffer establishment. Including the following: the business party requests the connection through the redis client to send the data; Lvs does four layers of load, receives the client request and load to a Lvs host; after the Lvs receives the request, the data is sent to a twemproxy host according to the load rule; after the Twemproxy accepts the request, it is found according to the fragmentation rule configuration rules of the client. To a redis host, sending data; after receiving the request, the Redis host stores data and synchronize to the slave and returns. Based on the redis cluster scheme of twemproxy, a new redis cluster solution is proposed. The initial testing of the online environment is stable, it has a certain disaster tolerance, reduces the risk of server downtime, and is suitable for a distributed environment with heavy redis dependence.
【技术实现步骤摘要】
一种基于twemproxy的Redis集群方法
本专利技术的实施方式涉及缓存组建领域,更具体地,本专利技术的实施方式涉及一种基于twemproxy的Redis集群方法。
技术介绍
随着移动互联网技术的爆发式增长,大数据、人工智能快速发展,多终端开发的日益流行,业务复杂度的不断提高,服务端的实时性要求也越来越高,传统的单机服务越来越无法满足市场需求,谷歌的“三篇论文”开启了大数据行业的浪潮,提出了用普通单机服务器组成的分布式集群解决爆发式数据增长的压力,缓存成为其中一个不可缺少的组建。目前缓存组建有redis、memcached、ehcache等,其实redis因效率高使用灵活最受欢迎,但redis开发早期并没有提出分布式思想,所以以单线程方式存在。目前比较流行的redis集群方案有客户端分片、twemproxy、redis官方集群、twemproxy集群。1、客户端分片客户端分片是把分片的逻辑放在Redis客户端实现,通过Redis客户端预先定义好的路由规则,把对Key的访问转发到不同的Redis实例中,最后把返回结果汇集。客户端分片模式的优点是所有逻辑都是可控的,不依赖第三方逻辑,但缺点是这种分片是一种静态分片,需要在客户端手工操作,极大提高了开发难度,而且当redis集群扩容时要调整分片策略才行。2、twemproxyTwemproxy是由Twitter开源的Redis代理,其基本原理是:Redis客户端把请求发送到Twemproxy,Twemproxy根据路由规则发送到正确的Redis实例,最后Twemproxy把结果汇集返回给客户端。Twempro ...
【技术保护点】
1.一种基于twemproxy的Redis集群方法,其特征在于,包括以下内容:业务方通过redis客户端请求连接,发送数据;Lvs做四层负载,收到客户端请求后负载至一台Lvs主机;Lvs接收到请求后,根据负载规则,发送数据至一台twemproxy主机;Twemproxy接受到请求后根据客户配置的分片规则找到一个redis主机,发送数据;Redis主机接收到请求后,存储数据,并且同步到从机,返回。
【技术特征摘要】
1.一种基于twemproxy的Redis集群方法,其特征在于,包括以下内容:业务方通过redis客户端请求连接,发送数据;Lvs做四层负载,收到客户端请求后负载至一台Lvs主机;Lvs接收到请求后,根据负载规则,发送数据至一台twemproxy主机;Twemproxy接受到请求后根据客户配置的分片规则找到一个redis主机,发送数据;Redis主机接收到请求后,存储数据,并且同步到从机,返回。2.根据权利要求1所述的一种基于twemproxy的Redis集群方法,其特征在于,当redis主机宕机后,zookeeper客户端检测到redis主机宕机,发送数据至ZK服务器;哨兵机器发现主机宕机之后主动触发从机为主机;...
【专利技术属性】
技术研发人员:慕瑞华,胡一枭,吴博,
申请(专利权)人:四川长虹电器股份有限公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。