Sergii Nester
Sergii Nester

Reputation: 474

How to figure out, what slows down docker?

My problem is the following - I have Docker on OSX with containers containing Redis, NginX, PHP 7 and Unison. Mapped to php-container I have volume with Symfony 3.1.7.

Everything works, but Symfony's "Welcome" page taked ~1.5 second loading time on average. At the same time same setup without docker gives me 0.2 second loading time. Same difference I got for Symfony's console commands, so, I guess, it's not the problem with NginX, and Unison should've negated all issues related to Docker files sync on OSX problem.

Right now I've ran out of ideas what can I do to speed things up and how to figure out what creates that 1.5s delay.

I have same issue on my second MBP, but such thing does not happen on colleagues laptop, which is similar to the one I have, but we were unable to find any difference between two setups.

Everything is running on my MBP with 2.5 GHz i5, 8 Gb RAM and SSD.

Docker 1.12.3, OSX 10.12.1 (Sierra)

docker-compose.yml:

mydockerbox-redis:
  image: phpdockerio/redis:latest
  container_name: mydockerbox-redis

mydockerbox-webserver:
  image: phpdockerio/nginx:latest
  container_name: mydockerbox-webserver
  volumes:
      - ..:/var/www/mydockerbox
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  ports:
   - "80:80"
  links:
   - mydockerbox-php-fpm

unison:  
  image: leighmcculloch/unison:latest  
  environment:  
    - UNISON_WORKING_DIR=/unison  
  volumes:
    - ../mydockerbox:/var/www/mydockerbox
  ports:  
    - "5000:5000"

mydockerbox-php-fpm:
  build: .
  dockerfile: php-fpm/Dockerfile
  container_name: mydockerbox-php-fpm
  volumes_from:  
    - unison  
  volumes:
    - ./php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-overrides.ini
  links:
    - mydockerbox-redis

UPD And here is Dockerfile for php-fpm container:

FROM phpdockerio/php7-fpm:latest

# Install selected extensions and other stuff
RUN apt-get update \
    && apt-get -y --no-install-recommends install  php7.0-mongodb php7.0-redis php7.0-igbinary \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*


WORKDIR "/var/www/mydockerbox"

Upvotes: 8

Views: 2783

Answers (2)

Greendrake
Greendrake

Reputation: 3734

First, benchmark PHP performance inside your php-fpm container (using this for example) and compare it with your colleague's container.

If you find that performance is the same/comparable, then use PHP performance profiling tools to find out what Symfony does in every bit of those ~1.5 seconds while generating "Welcome" page. That will likely identify the bottleneck (could be filesystem, network communication with Redis container, DNS lookups etc).

If the benchmark shows that PHP itself in your container runs slower (which I think is unlikely), then run the benchmark on the host machine. In case there is big difference between the host machine's and the php-fpm contaner's results — that will mean docker engine is throttling resources and needs a deep tweak or reinstall.

Upvotes: 0

Matteo
Matteo

Reputation: 39390

I suggest you to use the docker-machine-driver-xhyve:

docker-machine/libmachine driver plugin for xhyve/hyperkit (native macOS hypervisor.framework)

You can simply install with brew (I hope you have already installed docker&Co with brew also, otherwise unlink and install them with brew!):

brew install docker-machine-driver-xhyve
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

Then you can create a docker machine as:

docker-machine create --driver xhyve --xhyve-experimental-nfs-share my-xhyve-docker-machine

and use it for run your container

Upvotes: 1

Related Questions