The invention discloses a performance optimization method for distributed cache server cluster, which includes the following steps: s1. Generating virtual cache servers for physical cache servers in the cluster; s2. Mapping a characteristic value of virtual cache servers to a point on the ring structure through hash function H1, and then mapping cached data objects to rings through the same hash function H1. Another point in structure: s3. Starting from the location of the data object mapping, searching clockwise, the first virtual cache server encountered is the corresponding virtual cache server for the data object; s4. Mapping the data object to the physical cache server through the hash function H2 of the virtual cache server to the physical cache server for caching; s5. When in the cluster, the data object is mapped to the physical cache server for caching. When adding or reducing physical cache servers, the virtual cache servers make corresponding adjustments. The invention solves the load balancing problem of the cache server cluster, and improves the overall performance of the cache server cluster.
【技术实现步骤摘要】
一种分布式缓存服务器集群的性能优化方法
本专利技术属于分布式缓存
,尤其涉及一种分布式缓存服务器集群的性能优化方法。
技术介绍
随着大数据时代的到来,分布式缓存技术在各个领域的应用越来越广泛,它具有读写速度快,扩展速度快,支持并发和快速响应等优势。分布式缓存系统的代表Memcached具有高性能、分布式等特点,它通过在内存中缓存数据和对象来减少读取数据库的次数,提高缓存的访问速度。Memcached的主要特征是它的分布式结构,可以通过在多台服务器上安装Memcached来搭建一个缓存服务器集群,然后通过一致性哈希算法来分散存储。一致性哈希算法(ConsistentHash)最早由DavidKarger等人提出,当时主要是为了应对互联网中的热点(HotPot)而设计,一致性哈希解决了简单哈希算法在分布式哈希表(DistributedHashTable,DHT)中存在的动态伸缩等问题。然而,传统的一致性哈希算法在分布式缓存系统Memcached服务器集群上的应用存在一些缺点:1.当物理缓存服务器的数量较少时,在缓存数据的过程中会普遍造成缓存服务器负载失衡的问题,进而也会影响整个服务器集群的性能发挥。2.当物理缓存服务器宕机时,该物理缓存服务器上缓存的数据将无法提供给各客户端进行查找访问,同时还影响服务器集群里的其他服务器,从而影响了整体服务器的性能,加大了对数据库的访问压力。
技术实现思路
本专利技术的目的在于提出一种分布式缓存服务器集群的性能优化方法,以解决分布式缓存服务器集群的负载均衡问题,同时提高分布式缓存服务器集群的整体性能。本专利技术为了实现上述目 ...
【技术保护点】
1.一种分布式缓存服务器集群的性能优化方法,其特征在于,包括如下步骤:s1.为分布式缓存服务器集群中的物理缓存服务器生成虚拟缓存服务器;s2.将虚拟缓存服务器的某一特征值通过哈希函数H1映射到环结构上的某一点上,再将缓存的数据对象通过相同的哈希函数H1映射到环结构上的另一点上;s3.在所述环结构上从数据对象映射的位置开始,沿顺时针方向查找,所遇到的第一个虚拟缓存服务器,即为该数据对象所对应的虚拟缓存服务器;s4.定义虚拟缓存服务器到物理缓存服务器的哈希函数为H2,通过哈希函数H2将所述步骤s3中的数据对象映射到物理缓存服务器上进行缓存;s5.当分布式缓存服务器集群中增加或减少物理缓存服务器时,虚拟缓存服务器做出相应调整,虚拟缓存服务器的具体调整过程如下:当物理缓存服务器增加时,修改虚拟缓存服务器到物理缓存服务器的哈希函数H2,将一部分虚拟缓存服务器映射到新增的物理缓存服务器上;当物理缓存服务器减少时,修改虚拟缓存服务器到物理缓存服务器的哈希函数H2,将原来映射到被删除物理缓存服务器上的虚拟缓存服务器重新映射到删除后的其他物理缓存服务器上。
【技术特征摘要】
1.一种分布式缓存服务器集群的性能优化方法,其特征在于,包括如下步骤:s1.为分布式缓存服务器集群中的物理缓存服务器生成虚拟缓存服务器;s2.将虚拟缓存服务器的某一特征值通过哈希函数H1映射到环结构上的某一点上,再将缓存的数据对象通过相同的哈希函数H1映射到环结构上的另一点上;s3.在所述环结构上从数据对象映射的位置开始,沿顺时针方向查找,所遇到的第一个虚拟缓存服务器,即为该数据对象所对应的虚拟缓存服务器;s4.定义虚拟缓存服务器到物理缓存服务器的哈希函数为H2,通过哈希函数H2将所述步骤s3中的数据对象映射到物理缓存服务器上进行缓存;s5.当分布式缓存服务器集群中增加或减少物理缓存服务器时,虚拟缓存服务器做出相应调整,虚拟缓存服务器的具体调整过程如下:当物理缓存服务器增加时,修改虚拟缓存服务器到物理缓存服务器的哈希函数H2,将一部分虚拟缓存服务器映射到新增的物理缓存服务器上;当物理缓存服务器减少时,修改虚拟缓存服务器到物理缓存服务器的哈希函数H2,将原来映射到被删除物理缓存服务器上的虚拟缓存服务器重新映射到删除后的其他物理缓存服务器上。2.根据权利要求1所述的分布式...
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。