Forums

Does the number of workers affect the speed of the telegram bot under high load?

I have a bot that writes a lot of things to json files very often. There are a lot of Json files, there are also a lot of requests. The bot works at a relatively good speed! However, one of these days a large influx of new audience is expected, and it is necessary that the bot cope with "writing" data into json! What can be done to speed up its work?

Thank you in advance for your response!

Writing to files under high load may not be the best idea. Particularly if 2 users can write to the same file. You could end up with inconsistent data. Increasing workers may help assuming that none of the files are shared. You can use this help page to work out how many workers you may need: https://help.pythonanywhere.com/pages/HowManyHitsCanMySiteHandle/

I have a json file that saves data for each user. Before each new write to the file, the bot reads the file and updates the data for a particular user. In this case, can increasing the number of workers help the bot process requests better in case of increased load?

Maybe consider database? The filesystem could be the bottleneck.