PHPackages                             clue/mq-react - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. clue/mq-react

ActiveLibrary[Queues &amp; Workers](/categories/queues)

clue/mq-react
=============

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of ReactPHP

v1.7.0(12mo ago)144691.7k↓17.5%12[3 issues](https://github.com/clue/reactphp-mq/issues)4MITPHPPHP &gt;=5.3CI passing

Since Feb 26Pushed 12mo ago9 watchersCompare

[ Source](https://github.com/clue/reactphp-mq)[ Packagist](https://packagist.org/packages/clue/mq-react)[ Docs](https://github.com/clue/reactphp-mq)[ Fund](https://clue.engineering/support)[ GitHub Sponsors](https://github.com/clue)[ RSS](/packages/clue-mq-react/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (9)Used By (4)

clue/reactphp-mq
================

[](#cluereactphp-mq)

[![CI status](https://github.com/clue/reactphp-mq/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-mq/actions)[![code coverage](https://camo.githubusercontent.com/2d45ae33b28ed0c5f14fdba645e579072cf437770a215524795c9eb258581b1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6465253230636f7665726167652d3130302532352d73756363657373)](#tests)[![installs on Packagist](https://camo.githubusercontent.com/ef4c227c8b109ce49ffc47670709f7e8bcfabe96fde05b74e32d1ec3c2c8d5fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c75652f6d712d72656163743f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374)](https://packagist.org/packages/clue/mq-react)

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of [ReactPHP](https://reactphp.org/).

Let's say you crawl a page and find that you need to send 100 HTTP requests to following pages which each takes `0.2s`. You can either send them all sequentially (taking around `20s`) or you can use [ReactPHP](https://reactphp.org/) to concurrently request all your pages at the same time. This works perfectly fine for a small number of operations, but sending an excessive number of requests can either take up all resources on your side or may get you banned by the remote side as it sees an unreasonable number of requests from your side. Instead, you can use this library to effectively rate limit your operations and queue excessives ones so that not too many operations are processed at once. This library provides a simple API that is easy to use in order to manage any kind of async operation without having to mess with most of the low-level details. You can use this to throttle multiple HTTP requests, database queries or pretty much any API that already uses Promises.

- **Async execution of operations** - Process any number of async operations and choose how many should be handled concurrently and how many operations can be queued in-memory. Process their results as soon as responses come in. The Promise-based design provides a *sane* interface to working with out of order results.
- **Lightweight, SOLID design** - Provides a thin abstraction that is [*just good enough*](https://en.wikipedia.org/wiki/Principle_of_good_enough)and does not get in your way. Builds on top of well-tested components and well-established concepts instead of reinventing the wheel.
- **Good test coverage** - Comes with an automated tests suite and is regularly tested in the *real world*.

**Table of contents**

- [Support us](#support-us)
- [Quickstart example](#quickstart-example)
- [Usage](#usage)
    - [Queue](#queue)
        - [Promises](#promises)
        - [Cancellation](#cancellation)
        - [Timeout](#timeout)
        - [all()](#all)
        - [any()](#any)
        - [Blocking](#blocking)
- [Install](#install)
- [Tests](#tests)
- [License](#license)

Support us
----------

[](#support-us)

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by [becoming a sponsor on GitHub](https://github.com/sponsors/clue). Sponsors get numerous benefits in return, see our [sponsoring page](https://github.com/sponsors/clue)for details.

Let's take these projects to the next level together! 🚀

Quickstart example
------------------

[](#quickstart-example)

Once [installed](#install), you can use the following code to access an HTTP webserver and send a large number of HTTP GET requests:

```
