Traditional Culture Encyclopedia - Weather forecast - How to understand tornado's asynchronous IO and long connection? What are the practical applications of long connections?
How to understand tornado's asynchronous IO and long connection? What are the practical applications of long connections?
Function can solve the problem of device reading and writing, but it is more convenient if there is asynchronous notification. Asynchronous notification means that once the device is ready, it will actively notify the application, so that the application does not need to query the settings at all.
Standby state is very similar to the concept of "interrupt" in hardware, and it is more accurate to say that SIGIO is asynchronous.
Input and output. You can use the signal () function to set the corresponding signal processing function.
Let's talk about long connections first.
Short connection means that when there is data interaction between two communication parties, a connection is established, and after the data transmission is completed, the connection is disconnected, that is, only one service is transmitted at a time.
Long connections are mostly used for point-to-point communication with frequent operations, and the number of connections should not be too large. each
TCP connections require a three-step handshake, which takes time. If each operation is a short connection, the processing speed will be much slower if it is operated again, so it will be opened continuously after each operation, and the data will be sent directly at the next processing.
The package is ok, and there is no need to establish a TCP connection. For example, if the database has a long connection, frequent communication will cause socket errors and frequent sockets.
Creation is also a waste of resources.
However, http services like websites generally use short links, because long links will consume certain resources of the server, while short links will save some resources for frequent connections of thousands or even hundreds of millions of clients like websites. If you use long connections and there are thousands of users at the same time, you can imagine that each user occupies a connection. So the concurrency is large, but each user needs to use short connections and does not need frequent operations.
In short, the choice of long connection and short connection depends on the situation.
- Related articles
- It is planned that two people will climb Mount Tai in mid-August. What do you need to prepare? If you want to climb the mountain at night, when is the best time to go? I'm from Binzhou, thank you! ! !
- The weather temperature in Nanjing in August
- The weather for several months
- Interpretation of He Shunyi and Antonym of Shun Sentence
- Is it cold in Henan in winter? Where is fun in winter in Henan?
- "Fog" must be careful, driving guide in foggy days
- Six high-quality geography teaching plans for eighth grade
Eighth grade geography teaching plan 1
"The Land of Sunrise"-Asia (Lesson 2)
Teaching objectives:
Knowledge target
- Exercise in autumn to prevent weight gain.
- Weather in Qinghe county
- What impact will the subsequent volcanic eruption have?