当前位置:网站首页>Construction scheme of distributed websocket
Construction scheme of distributed websocket
2022-06-25 04:42:00 【Over the abyss】
One 、 background
- The company is websocket The architecture is a single application , It needs to be changed to cluster .
Two 、 Retrofit scheme
2.1 Scheme 1 :
utilize mq The publish subscribe feature implements :
advantage : Implement a simple
shortcoming : need mq Support broadcast mode , The message should be de duplicated at the receiver , Every machine receives messages .
This content cannot be displayed outside the document for the time being
2.2 Option two :
1. utilize redis Store the relationship between the user and the machine (userid,topic identification )
2.mq Used for message communication between services , Each service has its own queue
advantage : Unwanted mq Broadcast mode , Reduce repeated message sending
shortcoming :
1. One for each machine topic, Expansion needs to be applied in advance topic Or it can be created randomly by code
2. One topic Corresponding to one sender, You need to dynamically create a new machine on the old machine topic Of sender
3.k8s To start, you need to configure environment variables separately for each service to determine the corresponding environment variables for each machine topic
4. machine hostname It needs to be fixed , Used to correspond to and topic The relationship between
This content cannot be displayed outside the document for the time being
2.3 Option three :
Consistent hash ring
advantage : decoupling , The expansion is convenient , Dynamic capacity reduction and expansion only affect some users , Reduce component dependencies
shortcoming : The implementation is complex , Longer time consuming , Big changes
This content cannot be displayed outside the document for the time being
2.3.1 Implementation steps of scheme III :
step :
- Build the gateway module project :
1.1 Integrate zk/nacos, Listen for machine node change information
1.2 Integrate mq, Receive business system requests
1.3 Integration consistency hash Algorithm , Real virtual node planning , Dynamic routing , Dynamic update ha
边栏推荐
猜你喜欢
JS arguments
cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
Record small knowledge points
30岁了开始自学编程,家里比较困难还来得及吗?
JS' sort() function
GBASE 8s 索引B+树
【FLink】access closed classloader classloader.check-leaked-classloader
CTF_ Web: deserialization of learning notes (II) CTF classic test questions from shallow to deep
Simple text analysis of malicious samples - Introduction
Unit test coverage
随机推荐
Use of deferred environment variable in gbase 8s
[untitled]
OOP栈类模板(模板+DS)
js的call()和apply()
Cannot import name 'escape' from 'jinja2' [solved successfully]
Package for gbase 8s
WPF 使用 MAUI 的自绘制逻辑
写shell脚本报错总结
GBASE 8s存儲過程語法結構
A detailed summary of four handshakes (or four waves) over TCP connections
Cascading deletion of gbase 8s
2.0springmvc uses restful
What is data persistence?
CTF_ Web: Learn flask template injection (SSTI) from 0
Solution of gbase 8s livelock and deadlock
i. Max development board learning record
GBASE 8s存储过程流程控制
515. 在每个树行中找最大值 / 剑指 Offer II 095. 最长公共子序列
大话云原生数据库中的存算分离
论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)