PHPackages                             vend/chunky - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. vend/chunky

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

vend/chunky
===========

A constant-time, variable-workload chunking tool with Doctrine2 integration

1.1.0(11y ago)489.8k1GPL3PHPPHP &gt;=5.4.0

Since Jul 22Pushed 11y agoCompare

[ Source](https://github.com/vend/chunky)[ Packagist](https://packagist.org/packages/vend/chunky)[ RSS](/packages/vend-chunky/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (7)Used By (1)

Chunky
======

[](#chunky)

[![Build Status](https://camo.githubusercontent.com/89aa68d0e5a4ba34a481a2ab72aff3c3c2cc3ba7864d5fa5f9d6c780e50009f8/68747470733a2f2f7472617669732d63692e6f72672f76656e642f6368756e6b792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vend/chunky)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b4c80a998f6fe2489a98811eb246b6a985ec60868c43cfac977e876c2e580692/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76656e642f6368756e6b792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vend/chunky/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/60174d6fcca3764358ed46097d5d1f457ed1de6e5bf554cb8c3ffdc92d9ee580/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76656e642f6368756e6b792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vend/chunky/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/7921ca11d8e3e3315c77b97834de54e7b3c9f0f5a9a43457b65f8df10169ad3e/68747470733a2f2f706f7365722e707567782e6f72672f76656e642f6368756e6b792f762f737461626c652e737667)](https://packagist.org/packages/vend/chunky)[![License](https://camo.githubusercontent.com/3594fe6d501ac0c3122db6b6a3293f16ef6fc844579653252c59fca8ffc1d18c/68747470733a2f2f706f7365722e707567782e6f72672f76656e642f6368756e6b792f6c6963656e73652e737667)](https://packagist.org/packages/vend/chunky)

A small library for dynamic chunking of large operations against an external system, like a database.

A 'chunk' is a unit of work with a target execution time. If each chunk in an iteration begins to take more time than the target to process, the size of future chunks is reduced.

This library also includes utilities for monitoring slave lag on a set of Doctrine2 connections, and can pause chunk processing to wait for replication to catch up. This sort of strategy is taken by tools like pt-online-schema-change in order to complete a process as fast as possible, but without impacting systems under production load.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Chunky\Chunk;

$options = [];

$chunk = new Chunk(
    500,     // Initial chunk size
    0.2,     // Target wallclock execution time in seconds
    $options
);

for (/* ... */) {
    $size = $chunk->getEstimatedSize();

    $chunk->begin();
    // Process $size records
    $chunk->end();
}
```

#### Options

[](#options)

- int `min`: The minimum chunk size to ever return (default 2 \* initial estimate)
- int `max`: The maximum estimated size to ever return (default 0.01 \* initial estimate)
- float `smoothing`: The exponential smoothing factor, 0 &lt; s &lt; 1 (default 0.3)

### Monitoring Replication Lag

[](#monitoring-replication-lag)

A Chunk class is provided for monitoring MySQL slave lag on a set of slave database servers: `ReplicatedChunk`. This class is MySQL-specific (because getting the current slave lag is not implemented for other drivers).

```
use Chunky\ReplicatedChunk;

/* @var Doctrine\DBAL\Connection $conn */
/* @var Doctrine\DBAL\Connection $conn2 */

$chunk = new ReplicatedChunk(500, 0.2, $options);
$chunk->setSlaves([$conn, $conn2]);
```

#### Options

[](#options-1)

- int `max_lag`: When replication lag reaches this many seconds, the slave is considered lagged
- int `pause`: The number of microseconds to pause for when slave lag is detected (before rechecking lag)
- int `max_pause`: The total number of microseconds the chunk will pause for before continuing or throwing an exception
- boolean `continue`: Whether to continue if `max_pause` is reached; default is to throw an exception and not continue

Installation
------------

[](#installation)

This library can be loaded yourself with PSR4, but you'd usually just install it with Composer. The package name is `vend/chunky`.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity62

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

6

Last Release

4345d ago

Major Versions

0.0.2 → 1.0.02014-08-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe0e32939757c85ef7a924309394e302896dbb32e18ac2f4b9b0b1c4793b8339?d=identicon)[edsrzf](/maintainers/edsrzf)

---

Tags

doctrine2chunk

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/vend-chunky/health.svg)

```
[![Health](https://phpackages.com/badges/vend-chunky/health.svg)](https://phpackages.com/packages/vend-chunky)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514139.2M692](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k53](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M208](/packages/illuminate-broadcasting)[logiscape/mcp-sdk-php

Model Context Protocol SDK for PHP

368116.8k12](/packages/logiscape-mcp-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
