How to work with pull and push methods?

Asynchronous data processing #

When a request involves some resource-intensive operations, you should consider performing these operations asynchronously, without forcing the user to wait for them to finish.

There are two methods for asynchronous data processing: pull and push.

In the pull method, whenever a request includes some complex operations, you create a task and save it to permanent storage, such as a database. Then in a separate process (such as the cron job) you get this task and process it.

This method is easy to implement, but it has some drawbacks. For example, tasks must be periodically taken from their place of storage. If you do this too rarely, tasks will be processed with a long delay, and if too often, this will create large overheads.

In the push method, you can use message queues (for example, RabbitMQ, ActiveMQ, Amazon SQS, etc.) to manage tasks. Whenever a new task enters the queue, it initiates the processing of this task by the handler.

    1 answer 1

    In the original title - "Processing Data Offline", it seems to me the translation is not entirely correct. I do not assert, but suppose that pull and push are not existing methods in the framework, it is rather the name of the approach to implementation, the generally accepted name of the methods of implementation. And the very implementation you are doing yourself.

    You can choose the push approach - install an extension for RabbitMQ, and according to the documentation from the extension, already work with the queue.

    You can choose a pull approach - implement your turn, store it somewhere, and with the help of a certain tool, periodically take data from the queue and process it.

    PS all letters, personal opinion and may not coincide with the thoughts set forth in the documentation.