Closed foremtehan closed 1 year ago
邮件已收到 谢谢!
I started with a simple web server from example 01-basic. Here is what I saw:
docker-swoole deminy$ ./bin/example.sh start 01
docker-swoole deminy$ docker stats --no-stream
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
cc7b39ac51ff 01-basic-app-1 0.02% 23.7MiB / 7.773GiB 0.30% 3kB / 714B 0B / 12.3kB 3
As shown, the Docker container used 23.7MiB memory. Of course, it should take more memory to run Octane applications.
I adjusted your Dockerfile a little, mainly to consolidate RUN commands and remove Composer caches (please ignore other changes like working directory and port number):
FROM phpswoole/swoole:php8.1
RUN \
set -ex && \
rm -rf * && \
composer create-project laravel/laravel . && \
mv ./.env.example .env && \
./artisan key:generate && \
composer require laravel/octane && \
composer clearcache && \
./artisan octane:install --server=swoole
ENTRYPOINT ["/bin/bash", "-c", "./artisan octane:start --server=swoole --host=0.0.0.0 --port=9501 --max-requests=1500"]
Here are the stats after making one HTTP call to the Octane server:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
1487ba5bffa4 octane 0.18% 181.8MiB / 7.773GiB 2.28% 3.64kB / 19.5kB 0B / 36.9kB 15
As shown, the Docker container used 181.8MiB memory.
I did another test using your Dockerfile, and it used 182.4MiB memory, almost the same as the one from my previous comment.
There are other optimizations to make the container (slightly) faster, e.g., exclude dev packages from Composer, use the Alpine image instead, etc. However, I doubt there could be many improvements.
With this dockerfile:
docker build -t octane .
docker run -d -p 9000:9000 --name=dump octane
then
docker stats
and you will see:As you can see when the server started with laravel octane it allocated 300 mb of ram, What cause this ? Or is it normal ?