I
I
Islamfon2015-09-23 17:54:24
PHP
Islamfon, 2015-09-23 17:54:24

How to properly handle Telegram Bot API requests?

Users write to the bot, the bot responds to requests by sending text from the database and a file via CurlFile .
Due to numerous requests to the bot handler at the same time, the bot stops responding to any requests, sometimes it is buggy.
I solved the problem as follows:
For each request I create a separate process in the console
exec('php ./bot.php &> /dev/null &');
I'm afraid that the server will soon fall down from numerous console calls via exec ()
Is this true? Does this function have a big load?
If yes, how else can this problem be solved?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2015-09-23
@DmitriyEntelis

Strange problem.
See what starts to fail in the handler. If it is written by direct hands - everything should work fine.
Of course, you can also cut some kind of queue, but this is really useful only if you have some kind of wild peak highload, and a lot of resources are required for the answer.
UPD , just in case, I’ll clarify: you shouldn’t write bot handlers based on any heavy frameworks

D
Defman21, 2015-09-23
@Defman21

In your case, it is better to implement a web-hook in the telegram API if you need to use PHP. PHP is not very suitable for an endlessly running program. (which is what a bot is).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question