Search code examples
phptask-queue

Implement QUEUE using PHP


I am implementing Bulk SMS in my application with the help of HTTP API's. Since HTTP urls have limit in number of characters to be sent at a time, i cannot request API along with all the numbers at once. So following is the logic i am using

Input

Number of Phone Number : 10000
Number of Phone Numbers per Single HTTP API request : 100

Requirement

A Queue to send 100 request and process 100 response. I am expecting something like "Tornado Queues" (http://www.tornadoweb.org/en/stable/queues.html)


Solution

  • You have a couple of options. Build your own queue using PHP but it will need some sort of DB backing like MySQL or Redis. I like Redis a lot because it is fast and doesn't cause additional load on my main DB. This is a good implementation of a queue using PHP. You will need the pcntl extension installed if you are going to directly use this example.

    Otherwise you can use a 3rd party service that manages the queue and that you communicate with via webhooks.

    This is a good resource for queue options in general and should extend your general knowledge.

    Of the top of my head Beanstalkd, RabitMQ and IronMQ are popular solutions.