{"id":28762,"date":"2026-11-30T19:40:14","date_gmt":"2026-11-30T19:40:14","guid":{"rendered":"https:\/\/capskip.com\/?p=28762"},"modified":"2026-11-30T19:40:14","modified_gmt":"2026-11-30T19:40:14","slug":"php-parallel-captcha","status":"publish","type":"post","link":"https:\/\/capskip.com\/zh\/php-parallel-captcha\/","title":{"rendered":"Windows \u4e0a\u7684 PHP \u5e76\u884c\u9a8c\u8bc1\u7801\u8bc6\u522b\uff1a\u4e09\u79cd\u65b9\u5f0f\u7684\u5b9e\u6d4b"},"content":{"rendered":"<p>PHP parallel captcha solving takes one of two shapes with the CapSkip SDK 1.8.0. Either one process keeps every task in flight with send() and getResult(), or several worker processes each block on one solve. The package is synchronous, so a plain loop adds the solve times up: eight tasks of 3 seconds took 30.5 seconds. One process with send() took 3.8 seconds, and eight workers started by symfony\/process took 4.2 seconds (mock numbers, PHP 8.4.15). None of them gets past the Max. Threads setting of CapSkip, which caps how many tasks are solved at once.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">What you need<\/h2>\n<ul>\n<li>CapSkip on a Windows PC. Local mode answers on 127.0.0.1 for that PC alone. Server mode makes it listen on your network address or a public IP instead, and the <a href=\"https:\/\/capskip.com\/setup-guide\/#connection-settings\">connection settings in the setup guide<\/a> cover both modes.<\/li>\n<li>PHP 8.0 or newer with the curl and json extensions, and Composer. The SDK declares PHP 8.0. Composer picked symfony\/process 5.4.54 on PHP 8.0 up to 8.1.10 on 8.4 and 8.5, so that package raises no floor. The amphp way needs PHP 8.1, which amphp\/parallel 2.4.0 requires.<\/li>\n<li>capskip\/capskip 1.8.0 and symfony\/process, installed with the command below. The amphp way adds amphp\/parallel and 17 more packages.<\/li>\n<\/ul>\n<div data-no-translation>\n<pre data-enlighter-language=\"bash\" class=\"EnlighterJSRAW\"># In PowerShell, in the folder that will hold worker.php\ncomposer require capskip\/capskip symfony\/process<\/pre>\n<\/div>\n<p>Every number comes from two small servers I wrote on my own ports, one standing in for CapSkip and one for a site&#8217;s form, so each is a mock number with its setup: PHP 8.4.15 (a thread safe build), Windows 10.0.26200.9711, an Intel Core Ultra 9 275HX with 24 logical cores. In the mock a task takes 3 seconds once it holds a slot, and a slot limit stands in for Max. Threads. Those rules are mine, not the app&#8217;s. No run touched the real app.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">Way 1: one process, every task in flight<\/h2>\n<p>First the baseline. The SDK submits a task and sleeps between reads, at 0.25, 0.75, 1.75, 3.75 and 7.75 seconds after the submit and then every 5, so one 3 second task came back after 3.8 seconds and eight in a row took 30.4 and 30.5 seconds (two runs). The SDK tutorial suggests worker processes, but its manual workflow needs none. send() submits a task and returns its id at once. getResult() asks about it a single time and throws NetworkException while the answer is not ready. So the block submits all the tasks first, then asks about each in turn until none is left or the budget is gone.<\/p>\n<div data-no-translation>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">&lt;?php\n\/\/ poll_all.php: one process, JOBS tasks in flight. send() returns at once,\n\/\/ then getResult() is asked about each task in turn.\n\/\/ Usage: php poll_all.php JOBS BUDGET_SECONDS\ndeclare(strict_types=1);\n\nrequire __DIR__ . '\/vendor\/autoload.php';\n\nuse CapSkip\\CapSkip;\nuse CapSkip\\Exceptions\\ApiException;\nuse CapSkip\\Exceptions\\NetworkException;\n\nconst SITEKEY = 'YOUR_SITEKEY';\nconst PAGE_URL = 'https:\/\/example.com\/signup';\n\nset_error_handler(static fn (int $no, string $msg): bool =&gt; str_contains($msg, 'curl_close()'), E_DEPRECATED);\n\n$jobs = (int) ($argv[1] ?? 8);\n$budget = (int) ($argv[2] ?? 60);\n$solver = new CapSkip(['host' =&gt; '127.0.0.1', 'port' =&gt; 8080]);\n\n$began = microtime(true);\n$pending = [];  \/\/ task id =&gt; job number\n$tokens = [];\n$failed = [];\nforeach (range(1, $jobs) as $job) {\n    try {\n        \/\/ The same fields recaptcha() sends: googlekey and pageurl.\n        $id = $solver-&gt;send(['method' =&gt; 'userrecaptcha', 'googlekey' =&gt; SITEKEY, 'pageurl' =&gt; PAGE_URL]);\n    } catch (ApiException $e) {\n        $failed[$job] = $e-&gt;getMessage();  \/\/ for example a full queue\n        continue;\n    }\n    $pending[$id] = $job;\n}\n$deadline = $began + $budget;  \/\/ one budget for the whole batch\n\nwhile ($pending &amp;&amp; microtime(true) &lt; $deadline) {\n    foreach ($pending as $id =&gt; $job) {\n        try {\n            $tokens[$job] = $solver-&gt;getResult((string) $id);  \/\/ a plain string\n            unset($pending[$id]);\n        } catch (NetworkException) {\n            \/\/ Not ready yet. This also hides a CapSkip that has stopped.\n        } catch (ApiException $e) {\n            $failed[$job] = $e-&gt;getMessage();\n            unset($pending[$id]);\n        }\n    }\n    usleep(500000);  \/\/ half a second between rounds\n}\n\nprintf(&quot;%d tokens, %d failed, %d still waiting after %.1f s\\n&quot;, count($tokens), count($failed), count($pending), microtime(true) - $began);\nforeach ($failed as $job =&gt; $message) {\n    echo &quot;job $job: $message\\n&quot;;\n}\nexit($pending || $failed ? 1 : 0);<\/pre>\n<\/div>\n<p>Eight tasks took 3.7 to 4.0 seconds (five runs, mock). A full queue changes this. Per the CapSkip changelog a full reCAPTCHA queue refuses new tasks (ERROR_NO_SLOT_AVAILABLE in the app source), so send() can throw midway. My mock refuses beyond a backlog as deep as its limit: with a limit of 2, eight jobs gave 4 tokens and 4 failures, while a version without the try around send() died on the fifth submit and left four tasks unread. Three more details matter. send() takes the in.php names, googlekey and pageurl, and checks them like recaptcha() does: an invented option raised ValidationException. NetworkException also covers a CapSkip that has stopped, so a dead app looks like a slow task until the budget ends, as it does inside the SDK. And typed methods post-process the answer after the poll, such as splitting a GeeTest v4 answer into five fields, which send() skips. This way suits single token answers, and each token is single use, so send its form at once.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">Way 2: a worker process per job with symfony\/process<\/h2>\n<p>A worker keeps the typed methods, isolates failures and can be killed from outside. Save the next PHP block as worker.php. It solves one task, posts one form and prints one JSON line. Change the sitekey, the page address and the form fields first: example.com answers 404.<\/p>\n<div data-no-translation>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">&lt;?php\n\/\/ worker.php: solves one reCAPTCHA v2 task, posts one form, prints one\n\/\/ JSON line. Usage: php worker.php JOB BUDGET_SECONDS\ndeclare(strict_types=1);\n\nrequire __DIR__ . '\/vendor\/autoload.php';\n\nuse CapSkip\\CapSkip;\nuse CapSkip\\Exceptions\\ApiException;\nuse CapSkip\\Exceptions\\NetworkException;\nuse CapSkip\\Exceptions\\TimeoutException;\nuse CapSkip\\Exceptions\\ValidationException;\n\nconst SITEKEY = 'YOUR_SITEKEY';\nconst PAGE_URL = 'https:\/\/example.com\/signup';  \/\/ shows the widget, takes the form\n\n\/\/ PHP 8.5 deprecates curl_close(), which SDK 1.8.0 still calls per request.\nset_error_handler(static fn (int $no, string $msg): bool =&gt; str_contains($msg, 'curl_close()'), E_DEPRECATED);\n\n\/\/ One result line on stdout, then the exit code the launcher reads.\nfunction finish(string $job, string $status, int $code, array $more = []): void\n{\n    echo json_encode(['job' =&gt; $job, 'status' =&gt; $status] + $more), &quot;\\n&quot;;\n    exit($code);\n}\n\n$job = $argv[1] ?? '';\n$budget = (int) ($argv[2] ?? 60);\nif ($job === '' || $budget &lt; 1) {\n    fwrite(STDERR, &quot;usage: php worker.php JOB BUDGET_SECONDS\\n&quot;);\n    exit(2);\n}\n\n$solver = new CapSkip(['host' =&gt; '127.0.0.1', 'port' =&gt; 8080]);\n$began = microtime(true);\ntry {\n    \/\/ timeout is the SDK's own deadline, checked when the next poll is due.\n    $result = $solver-&gt;recaptcha(SITEKEY, PAGE_URL, ['timeout' =&gt; $budget]);\n} catch (TimeoutException) {\n    finish($job, 'timeout', 3);\n} catch (NetworkException) {\n    finish($job, 'capskip unreachable', 5);\n} catch (ValidationException) {\n    finish($job, 'refused by the SDK', 2);\n} catch (ApiException $e) {\n    finish($job, 'capskip: ' . $e-&gt;getMessage(), 4);\n}\n$solved = round(microtime(true) - $began, 2);\n\n\/\/ The token is single use, so post it now. Change the field names to yours.\n$ch = curl_init(PAGE_URL);\ncurl_setopt_array($ch, [\n    CURLOPT_POST =&gt; true,\n    CURLOPT_POSTFIELDS =&gt; http_build_query(['email' =&gt; &quot;job$job@example.com&quot;, 'g-recaptcha-response' =&gt; $result['code']]),\n    CURLOPT_REFERER =&gt; PAGE_URL,\n    CURLOPT_RETURNTRANSFER =&gt; true,\n    CURLOPT_TIMEOUT =&gt; 20,\n]);\n$body = curl_exec($ch);\n$status = $body === false ? 0 : (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE);\nif ($status === 0) {\n    finish($job, 'site unreachable', 7, ['solved' =&gt; $solved]);\n}\nif ($status &gt;= 400) {\n    finish($job, &quot;site refused, HTTP $status&quot;, 6, ['solved' =&gt; $solved]);\n}\nfinish($job, 'ok', 0, ['solved' =&gt; $solved]);<\/pre>\n<\/div>\n<p>The exit code is the report. These are the codes of that script, each produced against the mock (PHP 8.4.15):<\/p>\n<table>\n<thead>\n<tr>\n<th>Exit code<\/th>\n<th>Meaning<\/th>\n<th>Case I ran<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>0<\/td>\n<td>Solved and the form accepted the token<\/td>\n<td>One task, 1 s mock solve<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>No arguments, or the SDK refused an option<\/td>\n<td>No arguments, then an unknown option<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>The SDK budget ran out<\/td>\n<td>Budget 3, a task that never finishes: 3.8 s<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>CapSkip answered with an error<\/td>\n<td>ERROR_CAPTCHA_UNSOLVABLE, a refused key and a full queue (ERROR_NO_SLOT_AVAILABLE)<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>CapSkip did not answer<\/td>\n<td>A closed port, after 2.1 s<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>The site refused the form<\/td>\n<td>A mock that answered 403<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>The site did not answer<\/td>\n<td>A closed port, after 2.9 s<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Now the launcher. It starts at most CAP workers, polls them every 50 milliseconds and gives each one a wall clock limit of the budget plus 10 seconds. start() in Symfony never checks that limit itself, so the loop calls checkTimeout().<\/p>\n<div data-no-translation>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">&lt;?php\n\/\/ run_pool.php: runs worker.php for JOBS jobs, at most CAP at a time.\n\/\/ Usage: php run_pool.php JOBS CAP BUDGET_SECONDS\ndeclare(strict_types=1);\n\nrequire __DIR__ . '\/vendor\/autoload.php';\n\nuse Symfony\\Component\\Process\\Exception\\ProcessTimedOutException;\nuse Symfony\\Component\\Process\\Process;\n\n$jobs = (int) ($argv[1] ?? 8);\n$cap = max(1, (int) ($argv[2] ?? 8));\n$budget = (int) ($argv[3] ?? 60);\n\n$queue = range(1, $jobs);\n$running = [];\n$lines = [];\n$began = microtime(true);\n$php = PHP_BINARY;  \/\/ the php.exe that runs this launcher\n\nwhile ($queue || $running) {\n    while ($queue &amp;&amp; count($running) &lt; $cap) {\n        $job = array_shift($queue);\n        $process = new Process([$php, __DIR__ . '\/worker.php', (string) $job, (string) $budget]);\n        $process-&gt;setTimeout($budget + 10);  \/\/ a wall-clock kill the worker cannot dodge\n        $process-&gt;start();\n        $running[$job] = $process;\n    }\n    foreach ($running as $job =&gt; $process) {\n        try {\n            $process-&gt;checkTimeout();  \/\/ start() does not check it for you\n        } catch (ProcessTimedOutException) {\n            $lines[$job] = sprintf('job %d killed after %d s, exit code %s', $job, $budget + 10, $process-&gt;getExitCode());\n            unset($running[$job]);\n            continue;\n        }\n        if (!$process-&gt;isRunning()) {\n            $out = trim($process-&gt;getOutput()) ?: trim($process-&gt;getErrorOutput());\n            $lines[$job] = sprintf('job %d exit %d %s', $job, $process-&gt;getExitCode(), $out);\n            unset($running[$job]);\n        }\n    }\n    usleep(50000);\n}\n\nksort($lines);\necho implode(&quot;\\n&quot;, $lines), &quot;\\n&quot;;\n$ok = count(array_filter($lines, static fn (string $l): bool =&gt; str_contains($l, ' exit 0 ')));\nprintf(&quot;%d of %d ok in %.1f s\\n&quot;, $ok, $jobs, microtime(true) - $began);\nexit($ok === $jobs ? 0 : 1);<\/pre>\n<\/div>\n<div data-no-translation>\n<pre data-enlighter-language=\"bash\" class=\"EnlighterJSRAW\"># Eight jobs with eight workers at once, then the same jobs two at a time\nphp run_pool.php 8 8 60\nphp run_pool.php 8 2 60<\/pre>\n<\/div>\n<p>Eight workers took 4.1 to 4.4 seconds for eight 3 second tasks (five runs), against 3.8 for the single process. The extra time is the SDK poll schedule inside each worker plus the process start. With a php.ini of four extensions (curl, openssl, mbstring and fileinfo), a bare PHP process took a median of 33 milliseconds (30 runs, range 30 to 41), loading the Composer autoloader and the SDK class 39 milliseconds, and a whole worker with an instant mock solve 63 milliseconds (43 to 109). With instant solves, 8 workers took 0.3 seconds, 32 workers 0.6 and 32 jobs at 8 a time 0.9. Memory is the real cost. Each Windows worker is a cmd.exe wrapper around php.exe: with 32 workers on 8 second tasks the process list showed php.exe at a median of 20.3 MB and cmd.exe at 8.0 MB, 905 MB of working set in all.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">Way 3: the same pool with amphp\/parallel<\/h2>\n<p>amphp\/parallel gives you a worker pool and hands back values instead of exit codes. It needs PHP 8.1: on 8.0 Composer installed its 1.4.4 line and my version 2 script died with a fatal error. The task class has to be autoloadable, because each worker loads it by name. With the class inside the launcher file, every job failed with an error saying so. So the class goes into its own file, with an autoload entry. Merge the JSON entry into composer.json, run the two commands, then save the two PHP blocks as src\/SolveTask.php and amp_pool.php.<\/p>\n<div data-no-translation>\n<pre data-enlighter-language=\"json\" class=\"EnlighterJSRAW\">&quot;autoload&quot;: {\n    &quot;psr-4&quot;: { &quot;App\\\\&quot;: &quot;src\/&quot; }\n}<\/pre>\n<\/div>\n<div data-no-translation>\n<pre data-enlighter-language=\"bash\" class=\"EnlighterJSRAW\"># In PowerShell: add amphp, put SolveTask.php in src, then refresh the autoloader\ncomposer require amphp\/parallel\ncomposer dump-autoload<\/pre>\n<\/div>\n<div data-no-translation>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">&lt;?php\n\/\/ src\/SolveTask.php: amphp loads this class inside each worker process, so\n\/\/ Composer's autoloader has to find it (see the autoload entry in composer.json).\ndeclare(strict_types=1);\n\nnamespace App;\n\nuse Amp\\Cancellation;\nuse Amp\\Parallel\\Worker\\Task;\nuse Amp\\Sync\\Channel;\nuse CapSkip\\CapSkip;\n\nfinal class SolveTask implements Task\n{\n    public function __construct(private int $job, private int $budget)\n    {\n    }\n\n    public function run(Channel $channel, Cancellation $cancellation): array\n    {\n        set_error_handler(static fn (int $no, string $msg): bool =&gt; str_contains($msg, 'curl_close()'), E_DEPRECATED);\n        $solver = new CapSkip(['host' =&gt; '127.0.0.1', 'port' =&gt; 8080]);\n        $began = microtime(true);\n        $result = $solver-&gt;recaptcha('YOUR_SITEKEY', 'https:\/\/example.com\/signup', ['timeout' =&gt; $this-&gt;budget]);\n\n        return ['job' =&gt; $this-&gt;job, 'seconds' =&gt; round(microtime(true) - $began, 2), 'length' =&gt; strlen($result['code'])];\n    }\n}<\/pre>\n<\/div>\n<div data-no-translation>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">&lt;?php\n\/\/ amp_pool.php: the same jobs through amphp\/parallel 2.x (PHP 8.1 or later).\n\/\/ Usage: php amp_pool.php JOBS CAP BUDGET_SECONDS\ndeclare(strict_types=1);\n\nrequire __DIR__ . '\/vendor\/autoload.php';\n\nuse Amp\\Parallel\\Worker\\ContextWorkerPool;\nuse App\\SolveTask;\n\nuse function Amp\\Future\\awaitAll;\nuse function Amp\\Parallel\\Worker\\submit;\nuse function Amp\\Parallel\\Worker\\workerPool;\n\n$jobs = (int) ($argv[1] ?? 8);\n$cap = max(1, (int) ($argv[2] ?? 8));\n$budget = (int) ($argv[3] ?? 60);\n$pool = workerPool(new ContextWorkerPool($cap));  \/\/ the default limit is 32 workers\n\n$began = microtime(true);\n$futures = [];\nforeach (range(1, $jobs) as $job) {\n    $futures[$job] = submit(new SolveTask($job, $budget))-&gt;getFuture();\n}\n[$errors, $values] = awaitAll($futures);\n\nforeach ($errors as $job =&gt; $error) {\n    echo &quot;job $job failed: &quot;, get_class($error), ' ', $error-&gt;getMessage(), &quot;\\n&quot;;\n}\nprintf(&quot;%d of %d ok in %.1f s\\n&quot;, count($values), $jobs, microtime(true) - $began);\n$pool-&gt;shutdown();  \/\/ without it PHP waited several seconds for the workers\nexit($errors ? 1 : 0);<\/pre>\n<\/div>\n<p>Eight tasks took 4.3 to 5.3 seconds as the script counted it, and 5.4 to 6.9 for the whole process (three runs, PHP 8.4.15). The pool limit defaults to 32 workers, and the sample sets it to CAP. Without the final shutdown() call my first version printed 4.3 to 4.9 seconds and then kept the process alive for about 13 to 19 seconds in total, depending on machine load, because PHP waited for its workers on exit. You gain values returned to the launcher, and you pay 18 more packages and an autoloadable class.<\/p>\n<h3 style=\"font-size:1.3rem;line-height:1.4;\">Threads: what I could not test<\/h3>\n<p>In all six builds function_exists() reported pcntl_fork as false, so child processes are what stock PHP on Windows offers. All six builds are thread safe, so ext-parallel could load, and amphp\/parallel would then use threads. It is a separate DLL outside Composer and I did not install it, so there is no thread number here.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">The ceiling none of them moves: Max. Threads<\/h2>\n<p>Per the setup guide, Max. Threads is set for each CAPTCHA type and says how many tasks of that type CapSkip solves at the same time, and the Monitor tab shows the threads in use and the queue. More PHP workers than that only queue, and the changelog says a full reCAPTCHA queue refuses new tasks. My mock never refuses in this table, and these are the wall times for eight 3 second tasks (PHP 8.4.15, three to five runs each, the loop two):<\/p>\n<table>\n<thead>\n<tr>\n<th>Mock slot limit<\/th>\n<th>Plain loop<\/th>\n<th>One process<\/th>\n<th>8 workers<\/th>\n<th>amphp, 8 workers<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>None<\/td>\n<td>30.4 to 30.5 s<\/td>\n<td>3.8 s<\/td>\n<td>4.1 to 4.4 s<\/td>\n<td>5.4 to 6.9 s<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>30.5 s<\/td>\n<td>6.5 to 7.0 s<\/td>\n<td>8.0 to 8.1 s<\/td>\n<td>9.4 s<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>30.5 to 30.6 s<\/td>\n<td>12.6 to 12.7 s<\/td>\n<td>13.0 to 13.1 s<\/td>\n<td>14.4 to 14.5 s<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The amphp column is the whole process with shutdown(). A limit of 2 made the last task wait 9 seconds in the mock queue. The setup guide gives no default, so read your own value in Settings.<\/p>\n<p>The waiting has a price when the time budget includes it. With a limit of 2 and a budget of 6 seconds, eight workers started at once ended with 2 solved and 6 timeouts, though the mock had finished 4 of the tasks. The two tasks of the second wave were ready at 6.0 seconds, but the SDK next looks at 7.75 and by then its deadline had passed, so it threw TimeoutException instead of reading them, and the results were never read. With at most 2 workers at once all eight finished, in 15.8 seconds. One process with a batch budget of 6 held 2 or 3 tokens and the rest waiting after about 6 seconds. So set CAP to the Max. Threads value, so tasks queue in PHP before any budget runs.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">A time budget for every job<\/h2>\n<p>Three clocks can end a job. I ran each against the mock on PHP 8.4.15.<\/p>\n<table>\n<thead>\n<tr>\n<th>Clock<\/th>\n<th>What it did<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>SDK timeout option<\/td>\n<td>Checked only when the next read is due. A budget of 5 ended the worker after 7.9 s and a budget of 20 after 22.9 s.<\/td>\n<\/tr>\n<tr>\n<td>Symfony process timeout<\/td>\n<td>Exact, because the parent kills the worker. Against a CapSkip that never answered a read, a budget of 5 with a limit of 15 ended the job at 15.6 s, with exit code 1 from the kill.<\/td>\n<\/tr>\n<tr>\n<td>max_execution_time<\/td>\n<td>The command line reads 0 even with 7 in php.ini, and a -d option works. A busy loop stopped at 3.05 s with a limit of 3, but a sleep of 8 seconds only died when it woke, at 8.1 s. With 5 and a 12 second mock task the worker died inside the SDK&#8217;s sleep after 7.8 s, with exit code 255.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>One read of res.php can wait for up to 120 seconds, per the SDK&#8217;s curl options. With a mock that held every read for 400 seconds, a budget of 5 gave TimeoutException only after 120.3 seconds, and a max_execution_time of 10 ended the worker after 120.1 seconds, inside curl. The <a href=\"https:\/\/www.php.net\/manual\/en\/function.set-time-limit.php\" rel=\"noopener nofollow\" target=\"_blank\">PHP manual for set_time_limit<\/a> says the measured time is real time on Windows. Here the limit could not interrupt a blocked call; only the parent&#8217;s kill did. So give every worker the SDK timeout for the normal case and a Process timeout as the hard stop. A killed worker leaves its task behind: the mock task carried on and finished, and whether the real app frees the slot I could not check.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">Running the workers on another PC<\/h2>\n<p>The launcher and its workers can sit on a second Windows PC while CapSkip stays where it is; I tested no second machine. Turn Server mode on in the connection settings of the CapSkip PC and put its address in the host entry of each constructor. Server mode accepts any address and its firewall rule allows them all, so an allow rule restricts nothing: add a Windows Firewall block rule for unexpected addresses, and with API Key Validation on, pass apiKey to each constructor.<\/p>\n<h2 style=\"font-size:1.6rem;line-height:1.35;\">FAQ<\/h2>\n<details style=\"border:1px solid #e2e5ee;border-radius:10px;padding:14px 18px;margin:0 0 12px;\">\n<summary style=\"cursor:pointer;\">\n<h3 style=\"font-size:1.15rem;line-height:1.4;display:inline;margin:0;\">Which PHP versions did you run?<\/h3>\n<\/summary>\n<p style=\"margin:12px 0 0;\">Every row above ran on PHP 8.4.15. The three ways, with eight 3 second tasks and no limit, also ran on 8.0.30, 8.1.33, 8.2.29, 8.3.28 and 8.5.0. One process took 3.7 to 3.9 seconds on all six versions and eight workers 4.1 to 4.3. The amphp script took 4.5 to 5.0 seconds on 8.1 to 8.5 and failed on 8.0.30 with an undefined workerPool() function. PHP 8.5 deprecates curl_close(), which SDK 1.8.0 still calls, and the error handler at the top of each script keeps that notice out of the output. I searched every log for other warnings and deprecations and found none.<\/p>\n<\/details>\n<details style=\"border:1px solid #e2e5ee;border-radius:10px;padding:14px 18px;margin:0 0 12px;\">\n<summary style=\"cursor:pointer;\">\n<h3 style=\"font-size:1.15rem;line-height:1.4;display:inline;margin:0;\">Is AsyncCapSkip a parallel client in PHP?<\/h3>\n<\/summary>\n<p style=\"margin:12px 0 0;\">No. Per the SDK source it is an alias of CapSkip with the same blocking methods. The real async client is the Python one, in the <a href=\"https:\/\/capskip.com\/solve-captchas-parallel-python\/\">Python parallel guide<\/a>.<\/p>\n<\/details>\n<details style=\"border:1px solid #e2e5ee;border-radius:10px;padding:14px 18px;margin:0 0 12px;\">\n<summary style=\"cursor:pointer;\">\n<h3 style=\"font-size:1.15rem;line-height:1.4;display:inline;margin:0;\">How many workers should I start?<\/h3>\n<\/summary>\n<p style=\"margin:12px 0 0;\">As many as Max. Threads for that CAPTCHA type, fewer if memory is tight (about 28 MB each here, with the cmd.exe wrapper). More only fills the queue until tasks are refused.<\/p>\n<\/details>\n<details style=\"border:1px solid #e2e5ee;border-radius:10px;padding:14px 18px;margin:0 0 12px;\">\n<summary style=\"cursor:pointer;\">\n<h3 style=\"font-size:1.15rem;line-height:1.4;display:inline;margin:0;\">Does this belong in a web request?<\/h3>\n<\/summary>\n<p style=\"margin:12px 0 0;\">No, because a request waits for the slowest solve. Put the work in a queue, as the <a href=\"https:\/\/capskip.com\/laravel-queue-captcha\/\">Laravel queue guide<\/a> does with a job class and the <a href=\"https:\/\/capskip.com\/symfony-messenger-captcha\/\">Symfony Messenger guide<\/a> does with a message handler.<\/p>\n<\/details>\n<p>PHP parallel captcha solving comes down to one process with send(), or a capped set of workers, with a budget that starts after the queue. CapSkip runs on your own PC as an <a href=\"https:\/\/capskip.com\/\">unlimited captcha solver<\/a> with no fee per solve, so a worker that times out costs you only its time. The <a href=\"https:\/\/capskip.com\/php-captcha-solver\/\">PHP CAPTCHA solver<\/a> page lists the types this guide did not use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP SDK \u5728\u6bcf\u6b21\u8bc6\u522b\u4e0a\u90fd\u4f1a\u963b\u585e\uff0c\u6240\u4ee5\u5faa\u73af\u4f1a\u628a\u65f6\u95f4\u52a0\u8d77\u6765\u3002\u8fd9\u91cc\u6709\u4e09\u79cd\u5728 Windows \u4e0a\u8ba9\u591a\u4e2a\u4efb\u52a1\u540c\u65f6\u8fdb\u884c\u7684\u65b9\u5f0f\uff0c\u9488\u5bf9\u6a21\u62df\u670d\u52a1\u6d4b\u5f97\uff0c\u53e6\u6709 Max. Threads \u4e0a\u9650\u548c\u6bcf\u4e2a\u4f5c\u4e1a\u7684\u65f6\u95f4\u9884\u7b97\u3002<\/p>","protected":false},"author":1,"featured_media":28761,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"PHP Parallel Captcha Solving: Three Ways Measured | CapSkip","rank_math_description":"PHP parallel captcha solving with the CapSkip SDK: send() in one process, symfony\/process workers or amphp, timed on Windows. Copy the code and run it.","rank_math_focus_keyword":"php parallel captcha solving","footnotes":""},"categories":[70],"tags":[],"class_list":["post-28762","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-captcha"],"_links":{"self":[{"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/posts\/28762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/comments?post=28762"}],"version-history":[{"count":1,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/posts\/28762\/revisions"}],"predecessor-version":[{"id":28780,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/posts\/28762\/revisions\/28780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/media\/28761"}],"wp:attachment":[{"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/media?parent=28762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/categories?post=28762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/capskip.com\/zh\/wp-json\/wp\/v2\/tags?post=28762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}