当前位置:网站首页>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
边栏推荐
- Shell 脚本循环遍历日志文件中的值进行求和并计算平均值,最大值和最小值
- C language _ structure pointer array function voting system
- 聚簇索引和非聚簇索引到底有什么区别
- Unity界面总体介绍
- My first understanding of MySql, and the basic syntax of DDL and DML and DQL in sql statements
- 【flask入门系列】Flask-SQLAlchemy的使用
- MySQL stored procedure
- 来自一位女测试工程师的内心独白...
- 934. The Shortest Bridge
- pc端判断当前使用浏览器类型
猜你喜欢

太阳能板最大面积 od js

Fiddler抓包模拟弱网络环境测试

Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?

Arbitrum 专访 | L2 Summer, 脱颖而出的 Arbitrum 为开发者带来了什么?

二层广播风暴(产生原因+判断+解决)

类似 MS Project 的项目管理工具有哪些

What are the project management tools like MS Project

pycharm重命名后无法运行(报错: can‘t open file......No such file or directory)

leetcode-1161: Maximum in-layer element sum

Can an inexperienced college graduate switch to software testing?my real case
随机推荐
聚簇索引和非聚簇索引到底有什么区别
怎样做好一个创业公司CTO?
Are you still working hard on the limit of MySQL paging?
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
手把手教你配置Jenkins自动化邮件通知
打印任务排序 js od华为
coldfusion文件读取漏洞(CVE-2010-2861)
C language _ structure pointer array function voting system
VSCode插件:嵌套注释
一个无经验的大学毕业生,可以转行做软件测试吗?我的真实案例
力扣刷题之爬楼梯(7/30)
太阳能板最大面积 od js
PDF 拆分/合并
Drools Rule Properties, Advanced Syntax
C语言小程序 -- 常见经典练习题
Force buckled brush the stairs (7/30)
静态路由解析(最长掩码匹配原则+主备路由)
After reading "MySQL Database Advanced Practice" (SQL Xiao Xuzhu)
Programmer's debriefing report/summary