Execute callback after REST API request completes + Response is sent

You can look into queues e.g. create a custom database table, and write to it within the rest_post_dispatch or rest_pre_serve_request filter just before it is dispatched.

Then you can bulk process the queue (first record in is the first record out) via e.g. wp-cron and the user will not be affected by that potentially heavy processing. A custom column for the processing status might be useful as well.

With a real cron (not wp-cron) you could better control the timing/frequency of the processing.