当前位置:网站首页>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
边栏推荐
猜你喜欢
VSCode插件:嵌套注释
leetcode-1161: Maximum in-layer element sum
pycharm cannot run after renaming (error: can't open file...No such file or directory)
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
case语句的综合结果,你究竟会了吗?【Verilog高级教程】
Can an inexperienced college graduate switch to software testing?my real case
Fiddler captures packets to simulate weak network environment testing
真正的CTO,是一个懂产品的技术人
GCC Rust获批将被纳入主线代码库,或将于GCC 13中与大家见面
静态路由+PAT+静态NAT(讲解+实验)
随机推荐
The PC side determines the type of browser currently in use
Between two orderly array of additive and Topk problem
系统需求多变如何设计
Gateway routing configuration
Shell script to loop through values in log file to sum and calculate average, max and min
Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things
程序员转正述职报告/总结
手把手教你配置Jenkins自动化邮件通知
PDF 拆分/合并
Basic introduction to ShardingJDBC
What is the ideal college life?
rpm安装postgresql12
内网渗透——提权
pc端判断当前使用浏览器类型
Software Testing Defect Reporting - Definition, Composition, Defect Lifecycle, Defect Tracking Post-Production Process, Defect Tracking Process, Purpose of Defect Tracking, Defect Management Tools
leetcode-399:除法求值
观察者(observer)模式(一)
link与@import的区别
Kyushu cloud as cloud computing standardization excellent member unit
【微信小程序】一文带你了解数据绑定、事件绑定以及事件传参、数据同步