Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

599
Visualizações
PHP Docker - Is it possible to set ulimit at runtime?

On a project I'm working on, xdebug takes approximately 1 hour to generate coverage. I've experimented with phpdbg, but I encounter the following error in my test suite:

stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
It is set to 1024, but you have descriptors numbered at least as high as 7228.
 --enable-fd-setsize=8192 is recommended, but you may want to set it
to equal the maximum number of open files supported by your system,
in order to avoid seeing this error again at a later date.

I'm using php:7.0.33-fpm (yes, I know, we're working on upgrading PHP versions :))

Using ulimit in the command line or relying on docker-compose to set it, the output still thinks it's set to 1024. Actually, the current output of ulimit -n within my container is actually over 1 million if I don't try to set it via another mechanism.

Is there any mechanism where this can be set via runtime without having to compile our own php container from scratch?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This warning can be triggered with the following PHP snippet:

<?php

$fds = [];
for ($i = 0; $i < PHP_FD_SETSIZE; $i++) { // PHP_FD_SETSIZE how FD_SETSIZE is exposed to userland
    $fds[] = fopen(__FILE__, 'r');
}

$read = $fds;
$write = [];
$except = [];

echo sprintf("FD_SETSIZE=%d", PHP_FD_SETSIZE) . "\n";

stream_select($read, $write, $except, 0);
/*
 * Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
 * It is set to 1024, but you have descriptors numbered at least as high as 1027.
 *   --enable-fd-setsize=2048 is recommended, but you may want to set it
 * to equal the maximum number of open files supported by your system,
 * in order to avoid seeing this error again at a later date. in /in/ZfBsg on line 14
 */

FD_SETSIZE is a constant defined by POSIX (see the select(2) manpage). While the warning leads you to believe that this warning can be mitigated by recompiling php with --enable-fd-setsize=[some-larger-value], this is not true. FD_SETSIZE cannot be changed at runtime, since its value is determined while compiling the kernel.

I looked at the PHP source code for a bit and I'm not sure why --enable-fd-setsize exists at all, since it does not seem to do anything (although I did not test this on Windows).

The only solutions to this problem seem to be:

  • avoid stream_select
  • avoid opening many files
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda