当前位置:网站首页>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
边栏推荐
猜你喜欢

Mongodb cluster

「 每日一练,快乐水题 」1108. IP 地址无效化

CTF_ Web:php weak type bypass and MD5 collision

GBASE 8s 索引B+树

Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)

Join() in JSZ

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

LabVIEW development gas regulator

CTF_ Web:8-bit controllable character getshell

Bingbing's learning notes: implementation of circular queue
随机推荐
Web3 DApp用户体验最佳实践
Cnpm: unable to load file c:\users\administrator\appdata\roaming\npm\cnpm PS1 because running scripts is prohibited on this system.
What is persistence? What are RDB and AOF in redis persistence?
Simple text analysis of malicious samples - Introduction
2021.8.29 notes: register, bit operation, pointer, structure
js的arguments
多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...
Gbase 8s index R tree
Upgrade PHP to php7 The impact of X (2), the obsolescence of mcrypt decryption
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
JS' sort() function
JS arguments
Xiaobai learns MySQL - Statistical 'opportunism'
Value transfer between parent and child components of wechat applet
小白学习MySQL - 统计的'投机取巧'
三角形类(构造与析构)
Data view for gbase 8s
js的call()和apply()
GBASE 8s的包
The solution of wechat applet switchtab unable to take parameters