当前位置:网站首页>分布式websocket搭建方案
分布式websocket搭建方案
2022-06-25 04:01:00 【于万丈深渊】
一、背景
- 公司目前websocket架构为单体应用,需要更改为集群。
二、改造方案
2.1方案一:
利用mq发布订阅特性实现:
优点:实现简单
缺点:需要mq支持广播模式,消息要在接收方做去重,每台机器都会接收到消息。
暂时无法在文档外展示此内容
2.2方案二:
1.利用redis存储用户和机器之间的关系(userid,topic标识)
2.mq用来做服务之间消息通信,每个服务制定自己专属队列
优点:不需要mq广播模式,减少消息重复发送
缺点:
1.每台机器需要一个topic,扩容需要提前申请topic或者也可以代码随机创建
2.一个topic对应一个sender,需要在旧机器上动态创建新机器上对应topic的sender
3.k8s启动需要为每个服务单独配置环境变量决定每台机器对应的topic
4.机器hostname需要固定,用来对应和topic之间的关系
暂时无法在文档外展示此内容
2.3方案三:
一致性哈希环
优点:解耦,扩容方便,动态缩容扩容只影响部分用户,减少组件依赖
缺点:实现复杂,耗时较长,改动较大
暂时无法在文档外展示此内容
2.3.1 方案三落地步骤:
步骤:
- 搭建网关模块项目工程 :
1.1 集成zk/nacos,监听机器节点变化信息
1.2 集成mq,接收业务系统请求
1.3 集成一致性hash算法,真实虚拟节点规划,动态路由,动态更新ha
边栏推荐
- Office macro virus bounce shell experiment
- GBase 8s 锁的分类
- LabVIEW development gas regulator
- CTF_ Web: advanced problem WP (5-8) of attack and defense world expert zone
- LabVIEW开发气体调节器
- 马斯克发布人形机器人,AI对马斯克为什么意义重大?
- kenlm
- 什么是数据持久化?
- Value transfer between parent and child components of wechat applet
- Laravel document sorting 9. Blade template
猜你喜欢

GBASE 8s 总体架构

CTF_ Web: Advanced questions of attack and defense world expert zone WP (1-4)

Can Navicat directly operate the Android database SQLite

A detailed summary of TCP connection triple handshake

Read lsd-slam: large scale direct monolithic slam

简单的恶意样本行文分析-入门篇

NFT insider 63: the sandbox reached a cooperation with Time magazine, and YGG established Spain's subdao

unity Quad剔除背面并剔除透明部分的shader

GBASE 8s 索引R树
![LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路](/img/ad/69fce7cf064479a0ddd477fb935de2.png)
LeetCode 劍指Offer II 091 粉刷房子[動態規劃] HERODING的LeetCode之路
随机推荐
PHP extracts and analyzes table contents, and collects bidding information
【esp32学习之路6——flash加密】
Intel 13th generation core showed its true colors for the first time: 68mb cache improved significantly
Classification of gbase 8s locks
BSC smart contract dividend mainstream currency | including marketing wallet | deflation | reflow | dividend free token | available for direct deployment
GBASE 8s存储过程语法结构
Cascading deletion of gbase 8s
Laravel document sorting 1. Installation and Preliminary Configuration
关于TCP连接四次握手(或者叫四次挥手)的详细总结
Should I use on or where for the left join
GBASE 8s存储过程流程控制
【无标题】
Use of deferred environment variable in gbase 8s
CTF_ Web: Advanced questions of attack and defense world expert zone WP (15-18)
EasyRecovery15非常好用的电脑数据恢复软件
Finereport displays and hides column data according to conditions
GBASE 8s的隔离级别介绍
cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
PostgreSQL数据库WAL——RM_HEAP_ID日志记录动作
Laravel document sorting 8. Middleware