Answer the question
In order to leave comments, you need to log in
How to reduce the load on the processor when accessing the database?
There is a bot, it launches 10 tasks (pages are parsed) through asyncio for 1 user, in each 1 task the database is accessed 4-5 times, this loads the processor very much and the bot starts to slow down, how can I reduce the load on the processor?
UPD There are many cores on my server, but for some reason not all of them are used. I
create a connection asyncpg.create_pool()
using
async with self.pool.acquire() as con:
await con.execute(sql)
Answer the question
In order to leave comments, you need to log in
Do tasks on a separate thread using the Threading library
https://docs.python.org/3/library/threading.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question