Handling asynchronous server-side operations
<p>I need to implement a system for running asynchronous operations in server side, and after pondering many options I am not sure which would be the best and more scalable, or what is normally used in this scenarios. I must be missing something since none of the solutions completely solve the problem.</p>

<p><strong>Context:</strong> For some context, I have a mobile application where users send a request to other users in order to start an activity. This operations are handled server side, and if the request doesn't have a response from the other user, it will expire and be closed in 15 minutes. So I create a record with the starting time of this operation in the database and I need to update its status 15 minutes later, hence the asynchronous operation. It needs to be exactly 15 minutes in order to notify the waiting user properly.</p>

<p><strong>Possible Solutions:</strong></p>

<ul>
<li><p>I am using laravel, and the solution I am pondering is pushing delayed jobs to a queue. Although at the beginning I thought it would be the perfect solution, I think it may not be scalable since the frequency of this requests can become too high and too many jobs would be queued. Also, queue jobs are not guaranteed to be executed exactly after the delay is reached, and may be resolved too late.</p></li>
<li><p>Another solution I thought about was handling all of this in a cron job running every minute, but it also has the same problem when the volume of requests is high. Performance-wise it may be overkill to do this every minute, especially at times where activity is infrequent.</p></li>
</ul>

<p>So basically, these are small operations which would be relatively fast to resolve, but the cost of managing a high amount of pending operations may be worst than the operations themselves. Is there any other pattern (not even reduced to laravel nor php) to delay the execution of a task to a future time?</p>