In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how the background development framework UDPServer works. The editor thought it was very practical, so I shared it with you to learn. The following information is about the introduction and working principle of UDPServer.
The first contact is called udpserver. As the name implies, it is a service framework that only supports udp. Because our department makes audio and video products, audio and video data requires high real-time performance, so udp is commonly used to transmit data. Udp server is a synchronous multi-process model that consists of 1 Interface process and multiple Worker processes.
The Iterface process is responsible for receiving requests from the outside, doing some legitimacy checksum format conversion, and forwarding them to the back-end Worker process. The Worker process listens to different ports to receive packets and handles business logic. The return packet of the Worker process is sent directly to the client.
There are several points worth paying attention to here:
First, the Worker process listens on different ports.
It is obviously more common to listen on the same port, and it is important to note that the listening port socket must be inherited from the parent process rather than the socket created by Worker itself. Because the former kernel can guarantee the scheduling uniformity, while the latter has no such effect, the kernel will only throw the request packet to the same Worker.
The reason why we use the scheme of listening on different ports is to ensure the controllability of scheduling. The Worker to which the request packet is sent is expected, a more personalized scheduling strategy can be made, and the problem location is much more convenient. Udp server is scheduled by polling by default.
The second point is that the Worker process returns packets directly to the client.
Another common practice is to return packets through the Interface process, but the disadvantage is that Interface becomes a bottleneck. The disadvantage of Worker returning packets directly is that it exposes Worker to the outside world, but this problem is not very serious. In contrast, we prefer to achieve a performance improvement. In order to return a packet to the client, Interface encapsulates the client's ip and port into a request packet and sends it to Worker.
Although the framework is simple, but the performance is very excellent, as an echosvr performance can reach 30w + QPS. However, this framework does not support TCP, so it can only be used as an internal service framework.
After reading the above, do you have any further understanding of UDPServer? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.