[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
redis一般在企业中做分布式缓存,可以大大的减小高并发的开销
企业中一定不是单机版的 因为如果是单机版的有可能会引起宕机
redis集群:两台为一组,一台主机一台备机 ,平时主机工作,备机不工作 ,备机每隔几秒就会给主机发送一个ping ,主机在正常工作的时候会发送一个peng
给备机 ,如果不返回pang,可能会连续ping三次,都不返回那么备机就会上,备机里有主机的全部内容,这个叫做心跳检测机制(高可用的作用),主从热备
redis中的slot槽值得范围是0-16383,一共是16384个槽值,可以将这些槽值分配给每组机器(目前在国内没有达到这么大集群的)
我们在存入redis数据的时候,使用key,value的键值对存值,那么存储前会将key使用crc16算法进行计算,会得出一个纯数字的值,使用这个数字除以16384取余数,余数落到那个slot槽值得范围内就将这个key,value存到对应的机器上,获取数据的时候也是如此。起到了一个负载均衡的作用,集群数越多越均匀,整体的容量要比单机版的容量要大,也就是扩容。
注:宕机就是redis节点挂掉
redis为什么在线上部署的时候一般不设置密码:
图中可以看出客户在访问网址的时候是先进入域名解析器,域名解析器将网址解析成静态的ip,这个静态的ip其实就是负载均衡器(注:负载均衡器是即可以访问内网也可以访问外网),负载均衡器会根据需求来找到对应的项目模块服务器,再由项目模块的服务器找到对应的mysql集群或者是redis集群,tomcat和集群一般都在内网当中,所以不用将redis设置密码。