telegram-bot-api icon indicating copy to clipboard operation
telegram-bot-api copied to clipboard

It takes a long time to restore work after a restart.

Open catthecreator opened this issue 5 months ago • 4 comments

Hi

When my instance restarts, a full reverse startup can take up to 40 minutes.

I do not know how it works under the hood, but it feels like it syncs each chat in turn.

How can I speed it up?

Usage statistics 27 minutes after restart:

uptime	1620.229083
bot_count	29395
active_bot_count	732
rss	10616MB
vm	10866MB
rss_peak	10620MB
vm_peak	10872MB
total_cpu	33.039327%	35.317502%	43.457948%	33.039327%
user_cpu	18.329060%	20.085783%	25.171571%	18.329060%
system_cpu	14.710267%	15.231719%	18.286377%	14.710267%
buffer_memory	266MB
active_webhook_connections	52
active_requests	0
active_network_queries	4
request_count	4.713815	2.396212	4.468096	4.713815
request_bytes	8551.267151	3724.991406	5269.924625	8551.267154
request_file_count	0.014191	0.159747	0.170755	0.014191
request_files_bytes	12302.732819	22845.165580	169136.212312	12302.732823
request_max_bytes	3223152	143008	3223152	3223152
response_count	4.713815	2.715707	6.706887	4.713815
response_count_ok	4.528101	2.715707	6.678428	4.528101
response_count_error	0.185714	0.000000	0.028459	0.185714
response_bytes	9126.561134	3921.960031	6293.118582	9126.561137
update_count	1.757192	0.958485	2.305196	1.757192

Usage statistics 45 minutes after restart:

DURATION	inf	5sec	1min	1hour
uptime	2846.146004
bot_count	29396
active_bot_count	967
rss	10637MB
vm	10891MB
rss_peak	10638MB
vm_peak	10892MB
total_cpu	26.100857%	17.629669%	17.316870%	26.100857%
user_cpu	14.774137%	11.466452%	10.594639%	14.774137%
system_cpu	11.326720%	6.163218%	6.722231%	11.326720%
buffer_memory	265MB
active_webhook_connections	56
active_requests	0
active_network_queries	8
request_count	4.067890	4.403739	3.390110	4.067890
request_bytes	7236.412724	8300.195804	6586.507426	7236.412725
request_file_count	0.022834	0.000000	0.000000	0.022834
request_files_bytes	29906.854965	0.000000	0.000000	29906.854969
request_max_bytes	36747844	0	0	36747844
response_count	4.067890	5.966356	3.553668	4.067890
response_count_ok	3.829718	5.824300	3.509061	3.829718
response_count_error	0.238172	0.142056	0.044607	0.238172
response_bytes	7461.859532	9464.771703	7035.221162	7461.859534
update_count	1.787694	2.414954	2.379024	1.787694

catthecreator avatar Jun 05 '25 07:06 catthecreator

What do you mean by "full reverse startup"? With 30000 bots it should take at most a few dozens seconds. The provided statistics shows no difference between 27th and 45th minutes. All bots already work for a long time on the 27th minute.

levlam avatar Jun 05 '25 07:06 levlam

I see a difference in the active_bot_count parameter.

By full launch, I mean when the bots start receiving messages, and messages come from the bots.

After restarting, the accounts are put into operation slowly, after 5 minutes one bot starts responding, after 15 minutes the second one starts responding.

I see the following messages in my application's log Operation timed out after 4005 milliseconds with 0 bytes received

that is, he tried to send a request, but within 4 seconds he did not receive a response, then he was killed by timeout.

catthecreator avatar Jun 05 '25 08:06 catthecreator

What do you mean by "full reverse startup"?

PS: I mean rebooting the docker container

catthecreator avatar Jun 05 '25 08:06 catthecreator

active_bot_count is the number of bots that sent requests in the last 24 hours. It is expected to increase gradually in the first 24 hours.

If you would send full Bot API server log with verbosity level 2 after restart to https://t.me/tdlib_bot, then I can tell you exact start up time and what has happened during this time.

levlam avatar Jun 05 '25 09:06 levlam

Sorry for the late reply. I’ve sent a message to the bot. Thanks!

catthecreator avatar Jul 08 '25 23:07 catthecreator