当前位置:网站首页>Problems that need to be solved by the tcp framework
Problems that need to be solved by the tcp framework
2022-07-31 01:51:00 【wilson_go】
1 Automatically encode, decode data packets, compress and transmit data in the network
Send data frequently to reduce the delay in the network.Encoding and decoding operate at high speed in cpu, and transmission in the network is very slow
tcp is streaming
2. Automatically encapsulate, unpack, and solve the problem of TCP sticky packets
TCP streaming, messages are connected at the end.Solution: Add a header to each packet, at least add length information, and read how long it is.
3. When the connection is established and the connection is disconnected, the callback function is automatically executed
4. The number of client connections is controlled
Long messages, long connections
5. The frequency of client messages is controlled
Send many packets per second
6. Automatically process client messages
According to the type of client message, assign messageID, identify the message according to messageID, bind callback function, and call corresponding function for processing.
7. Automatically start a fixed number of worker goroutines to process messages to avoid wireless expansion of goroutines
Come over and start a goroutine.You can't let goroutine expand infinitely, with a fixed number, to process.Organize, put into message queue.The worker consumes messages from the message queue and processes them.Process the message, use the callback function registered by the user, and finish the process.
8. Efficient timer/ticker that automatically executes callback functions
client—>client handler goroutine—>two goroutines
client reader goroutine
client writer goroutine coding
Unpack the data, the data and the connection are passed into the message processing module as a request to form a request
When the data is processed, it is sent to the message queue, such as sending to the fifth message queue 5 worker5 reads the message, and the worker goes to the apis to find it
If the api needs to write data to the client, a connection message is encapsulated in the request
边栏推荐
猜你喜欢

coldfusion文件读取漏洞(CVE-2010-2861)

Force buckled brush the stairs (7/30)

12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche

"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition

成为比开发硬气的测试人,我都经历了什么?

进程间通信学习笔记

想要写出好的测试用例,先要学会测试设计

力扣刷题之爬楼梯(7/30)

MySQL的存储过程

Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things
随机推荐
蛮力法/邻接矩阵 广度优先 有向带权图 无向带权图
Between two orderly array of additive and Topk problem
Crawler text data cleaning
Simple confession page
程序员转正述职报告/总结
934. The Shortest Bridge
VSCode Plugin: Nested Comments
来自一位女测试工程师的内心独白...
uniapp使用第三方字体
rpm安装postgresql12
基于FPGA的图像实时采集
太阳能板最大面积 od js
力扣刷题之有效的正方形(每日一题7/29)
Charging effect simulation
[Map and Set] LeetCode & Niu Ke exercise
leetcode-399:除法求值
C语言小程序 -- 常见经典练习题
【微信小程序】一文带你了解数据绑定、事件绑定以及事件传参、数据同步
What have I experienced when I won the offer of BAT and TMD technical experts?
[1154]如何将字符串转换为datetime