当前位置:网站首页>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
边栏推荐
- Fiddler captures packets to simulate weak network environment testing
- Gateway routing configuration
- 1782. Count the number of point pairs Double pointer
- 系统需求多变如何设计
- Manchester City confuses fans with smart scarf that detects emotions
- Verify the integer input
- MySQL的存储过程
- uniapp uses 3rd party fonts
- 怎样做好一个创业公司CTO?
- 简易表白小页面
猜你喜欢
软件测试基础接口测试-入门Jmeter,你要注意这些事
静态路由+PAT+静态NAT(讲解+实验)
Shell 脚本循环遍历日志文件中的值进行求和并计算平均值,最大值和最小值
Nacos
加密生活,Web3 项目合伙人的一天
Word/Excel 固定表格大小,填写内容时,表格不随单元格内容变化
软件测试报告有哪些内容?
第一学年课程期末考试
怎样做好一个创业公司CTO?
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
随机推荐
最大路径和
What is the ideal college life?
第一学年课程期末考试
关于Redis相关内容的基础学习
最高月薪20K?平均薪资近万...在华为子公司工作是什么体验?
聚簇索引和非聚簇索引到底有什么区别
link与@import的区别
After reading "MySQL Database Advanced Practice" (SQL Xiao Xuzhu)
[WeChat applet] This article takes you to understand data binding, event binding, event parameter transfer, and data synchronization
case语句的综合结果,你究竟会了吗?【Verilog高级教程】
My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
Manchester City confuses fans with smart scarf that detects emotions
leetcode-1161:最大层内元素和
coldfusion文件读取漏洞(CVE-2010-2861)
用户交互+格式化输出
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
力扣刷题之爬楼梯(7/30)
221. 最大正方形
观察者(observer)模式(一)