You can make the task async by using a queuing system as @Nimrod007 suggested.
You can integrate the Symfony Messenger and your tasks will be handled in the background. Just send it an object and write the logic in the handler.