Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Problems running Swoole via a docker container in swarm mode #1961
Please answer these questions before submitting your issue. Thanks!
I am project lead on zend-expressive-swoole, where we are providing a turn-key solution for deploying Expressive-based applications using Swoole.
I'm attempting to test how Swoole works in production, and specifically trying to deploy a Docker container based on php:7.2-cli in which I've built and enabled the Swoole extension:
# DOCKER-VERSION 1.3.2 FROM php:7.2-cli # System dependencies RUN apt-get update && \ apt-get install -y git libbz2-dev libicu-dev libtidy-dev libxslt1-dev zlib1g-dev libc6-dev && \ rm -rf /var/lib/apt/lists/* # Install Swoole RUN pecl install swoole-4.1.1 && docker-php-ext-enable swoole # Swoole configuration COPY swoole.ini /usr/local/etc/php/conf.d/000-swoole.ini # Install composer COPY getcomposer.sh /usr/local/bin/ RUN /usr/local/bin/getcomposer.sh # Project files RUN mkdir -p /var/www/public COPY index.php /var/www/public/ COPY entrypoint /usr/local/bin/ EXPOSE 9000 ENTRYPOINT ["entrypoint"]
The entrypoint is a PHP script that runs a Swoole HTTP Server.
I expect to see Swoole running, and to be able to access the website via a browser.
When I use this container via
I've tried a number of different memory_limit settings, from disabling it (
The docker host reports: Linux 4.4.0-134-generic #160-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
The container is using the same kernel and architecture, and gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
$server->set(['max_conn' => 1000]);
I did a few experiments.
First, I created a new DO droplet, and discovered that my Swoole container would run fine in it!
However, once I deployed something non-trivial and started hitting it more often, I found I was getting errors of the following sort:
At that point, I tried your suggestion above. I first fired up the container using
The results: it is stable. In fact, I ran
I'm going to try upping the value to find a good threshold; in the meantime, thank you for the pointer, and the wonderful work on Swoole!