K
K
klinch212021-01-14 04:14:44
client-server
klinch21, 2021-01-14 04:14:44

How does Telegram deliver data to the client?

Good night, could someone tell me exactly how messenger servers, such as Telegram, communicate with clients?
All that is of interest is how the PC client of the cart (windows / linux) receives a new portion of data from the server (messages, posts in cart channels, etc.).

As I can assume, the telegram client opens a tcp / udp connection through which data is transmitted, all this is seasoned with different security protocols, of course the data is encrypted and so on. But in fact, keeping hundreds of thousands of keep-alive connections is quite expensive, especially when there is no new data coming in and there is nothing to deliver.
Or another option works, when the client itself forwards ports through the router (like upnp) and starts listening to the desired port at the OS level, the server itself initiates a tcp / udp connection to the client when there is new data for delivery, which is essentially much more profitable.

In general, I would be very grateful if smart people explained how this works using the example of Telegram.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-01-14
@klinch21

Namely, keeping sockets open is not expensive, even a web socket connection (and they are a little more complicated) one machine can hold millions of .
In the general case, a telegram has many servers, plus there are proxy servers, they all hold connections (client -> server) and the server decides who to report what to.
For mobile systems, operating systems are made so that they wake up at the signal of the server, instead of developing their infrastructure (which will give an extra load on mobile phones and their batteries), they use a push system from Apple or Google, by the way, during the blocking of the telegram by Roskomnadhor, this was used as service message delivery tool, since blocking it would completely block the operation of all mobile phones in the country.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question