SlideShare a Scribd company logo
Radek Baczyński, Warszawa - 22.11.2018
Docker for Mac & local dev
environment optimization
Presentation title · Title of the chapter - 00/2018 2
● Same environment as production server
● Same environment on each dev machine
● Immutable infrastructure
● Easy setup & configuration
● Easy upgrades of services
Why docker on dev machine?
Docker for Mac i optymalizacja środowiska developerskiego
● Opcache settings
○ memory_consumption
○ max_accelerated_files
● PHP settings:
○ realpath_cache_size
○ Realpath_cache_ttl
● Doctrine
○ metadata_cache_driver
○ query_cache_driver
○ result_cache_driver
Basic performance optimization
3
● Docker for Mac
○ edge version
○ .raw disk
○ APFS mac file system
○ Preferences → File sharing
■ Limit to your “project”
dir
● Symfony
○ Log to /dev/stdout
○ Disable profiler?
Docker for Mac i optymalizacja środowiska developerskiego
Mac
Linux VM
Docker
4
osxfs
mounted
volume
📄
index.php
📄
index.php
Docker for Mac i optymalizacja środowiska developerskiego
👍 Same user experience
5
👎 Poor performance
Docker for Mac
Docker for Mac i optymalizacja środowiska developerskiego
● Aggressive opcache
○ opcache.validate_timestamps=0
● RAM disk
● NFS
● PHP 7.4
○ https://wiki.php.net/rfc/preload
Alternative ideas
6
Presentation title · Title of the chapter - 00/2018
Benchmark 1
Default setup
7Presentation title · Title of the chapter - 00/2018
services:
backend:
image: php-7.2
volumes:
- ./:/app
ports:
- 8080:8080
2578ms
Presentation title · Title of the chapter - 00/2018
Benchmark 2
Removed xdebug extension
8Presentation title · Title of the chapter - 00/2018
services:
backend:
image: php-7.2
volumes:
- ./:/app
ports:
- 8080:8080
1058ms
Docker for Mac i optymalizacja środowiska developerskiego
:delegated
:cached
9
Docker for mac half-solution for
performance issue
Presentation title · Title of the chapter - 00/2018
Benchmark 3 Xdebug enabled & Delegated
volume mount
10Presentation title · Title of the chapter - 00/2018
services:
backend:
image: php-7.2
volumes:
- ./:/app:delegated
ports:
- 8080:8080
358ms
Docker for Mac i optymalizacja środowiska developerskiego
● In docker container
run 2 php-fpm processes
○ Port 9000 without xdebug.so
○ Port 9001 with xdebug.so
Xdebug trick
11
Docker for Mac i optymalizacja środowiska developerskiego
2 fpm processes
12
Port:9000, with xdebug.so
Port:9001, without xdebug.so
Docker for Mac i optymalizacja środowiska developerskiego
Nginx config
13
map $cookie_XDEBUG_SESSION $fpm_port {
default 9000;
PHPSTORM 9001;
}
server {
listen 80;
location = / {
rewrite ^/(.*)$ /app_dev.php/$1;
}
location @rewrite {
rewrite ^/(.*)$ /app_dev.php/$1;
autoindex on;
}
location ~ .php {
fastcgi_index app_dev.php;
fastcgi_pass 127.0.0.1:$fpm_port;
#...
}
}
● Map fastcgi port
Presentation title · Title of the chapter - 00/2018
Benchmark 4 Delegated & Removed
xdebug extension
14Presentation title · Title of the chapter - 00/2018
services:
backend:
image: php-7.2
volumes:
- ./:/app:delegated
ports:
- 8080:8080
262ms
Docker for Mac i optymalizacja środowiska developerskiego
Not enough for big
Symfony apps
Real case
15
Presentation title · Title of the chapter - 00/2018
Docplanner Docplanner monolith
● Delegated
● Xdebug trick
● Minor optimizations
16Presentation title · Title of the chapter - 00/2018
2432ms
Docker for Mac i optymalizacja środowiska developerskiego
● Don’t use problematic mounted
volumes
Solution
17
version: '3'
services:
backend:
container_name: symfony_demo
image: php-fpm7.2
volumes:
- ./:/app:delegated
ports:
- 8080:8080
Docker for Mac i optymalizacja środowiska developerskiego
docker-sync
💪 mutagen.io 🔥
Solution
18
Docker for Mac i optymalizacja środowiska developerskiego
● Same idea as docker-sync
● Less problems
● Better performance
● Tight docker integration
● Works with any dockerized app
● Easy to monitor
● Easy to manage
mutagen.io
19
Docker for Mac i optymalizacja środowiska developerskiego
https://asciinema.org/a/KN0Opv0VxsCBNxbGo9ohkb3oX
1. brew install mutagen
2. mutagen daemon start
3. mutagen create PATH_ON_HOST
docker://USER@CONTAINER_NAME/PATH_IN_CONTAINER
4. mutagen monitor
Wait few seconds/minutes for first sync
5. It’s done
mutagen.io
20
Presentation title · Title of the chapter - 00/2018
Benchmark 5
No mounted volumes &
xdebug enabled & mutagen
21Presentation title · Title of the chapter - 00/2018
47ms
Presentation title · Title of the chapter - 00/2018
Benchmark 6
No mounted volumes &
xdebug enabled & mutagen
22Presentation title · Title of the chapter - 00/2018
349ms
Docker for Mac i optymalizacja środowiska developerskiego
● basic php optimizations
● optional xdebug
● mutagen.io
Summary
23
Follow us!
Questions?
Follow us!
Thank you!

More Related Content

PDF
Search engine based on Elasticsearch
PDF
Unifying Frontend and Backend Development with Scala - ScalaCon 2021
PDF
Apache Airflow at Dailymotion
PDF
AIRflow at Scale
PPTX
InfluxData Internals by Ryan Betts
PPT
Operation Migration: Migrating Static Content into Cascade Server with our ne...
PDF
Presto Summit 2018 - 09 - Netflix Iceberg
PDF
InfluxDB 2.0: Dashboarding 101 by David G. Simmons
Search engine based on Elasticsearch
Unifying Frontend and Backend Development with Scala - ScalaCon 2021
Apache Airflow at Dailymotion
AIRflow at Scale
InfluxData Internals by Ryan Betts
Operation Migration: Migrating Static Content into Cascade Server with our ne...
Presto Summit 2018 - 09 - Netflix Iceberg
InfluxDB 2.0: Dashboarding 101 by David G. Simmons

What's hot (20)

PDF
Introduction to Data Engineer and Data Pipeline at Credit OK
PDF
InfluxDB 2.0 Client Libraries by Noah Crowley
PPTX
Challenges in Building a Data Pipeline
PPTX
KDB+ Lite
PDF
KDB database (EPAM tech talks, Sofia, April, 2015)
PPT
Key Challenges in Cloud Computing and How Yahoo! is Approaching Them
PPTX
A Walkthrough of InfluxCloud 2.0 by Tim Hall
PDF
Iceberg: A modern table format for big data (Strata NY 2018)
PPTX
Managing multiple event types in a single topic with Schema Registry | Bill B...
PDF
RESTful with Drupal - in-s and out-s
PDF
hbaseconasia2017: HBase on Beam
PDF
GraphQL is actually rest
ODP
Geospatial web services using little-known GDAL features and modern Perl midd...
PDF
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
PPTX
Data- How Does It Work-
PDF
The Dark Side Of Go -- Go runtime related problems in TiDB in production
PDF
InfluxDB Internals
PDF
TiDB Introduction
PDF
CEPH DAY BERLIN - WHAT'S NEW IN CEPH
PDF
Scaling Redis: Dmitry Polyakovsky
Introduction to Data Engineer and Data Pipeline at Credit OK
InfluxDB 2.0 Client Libraries by Noah Crowley
Challenges in Building a Data Pipeline
KDB+ Lite
KDB database (EPAM tech talks, Sofia, April, 2015)
Key Challenges in Cloud Computing and How Yahoo! is Approaching Them
A Walkthrough of InfluxCloud 2.0 by Tim Hall
Iceberg: A modern table format for big data (Strata NY 2018)
Managing multiple event types in a single topic with Schema Registry | Bill B...
RESTful with Drupal - in-s and out-s
hbaseconasia2017: HBase on Beam
GraphQL is actually rest
Geospatial web services using little-known GDAL features and modern Perl midd...
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
Data- How Does It Work-
The Dark Side Of Go -- Go runtime related problems in TiDB in production
InfluxDB Internals
TiDB Introduction
CEPH DAY BERLIN - WHAT'S NEW IN CEPH
Scaling Redis: Dmitry Polyakovsky
Ad

Similar to Docker for mac & local developer environment optimization (20)

PDF
Continuous Delivery com Docker, OpenShift e Jenkins
PDF
DCEU 18: Developing with Docker Containers
PPTX
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
PDF
Sprint 17
PPTX
Docker for Web Developers: A Sneak Peek
PDF
Using Docker For Development
PDF
Nginx pres
PDF
DockerCon EU '17 - Dockerizing Aurea
PDF
Automating Complex Setups with Puppet
PDF
Automating complex infrastructures with Puppet
PDF
Super powered Drupal development with docker
PDF
Postgres the hardway
PDF
Graphing Nagios services with pnp4nagios
PPTX
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
ODP
Deploying Perl apps on dotCloud
PDF
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
PPTX
Deploying Windows Containers on Windows Server 2016
PDF
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
PDF
Scaling PHP apps
PDF
Porting Rails Apps to High Availability Systems
Continuous Delivery com Docker, OpenShift e Jenkins
DCEU 18: Developing with Docker Containers
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Sprint 17
Docker for Web Developers: A Sneak Peek
Using Docker For Development
Nginx pres
DockerCon EU '17 - Dockerizing Aurea
Automating Complex Setups with Puppet
Automating complex infrastructures with Puppet
Super powered Drupal development with docker
Postgres the hardway
Graphing Nagios services with pnp4nagios
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
Deploying Perl apps on dotCloud
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Deploying Windows Containers on Windows Server 2016
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Scaling PHP apps
Porting Rails Apps to High Availability Systems
Ad

Recently uploaded (20)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
KodekX | Application Modernization Development
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Understanding_Digital_Forensics_Presentation.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25 Week I
KodekX | Application Modernization Development
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?
Per capita expenditure prediction using model stacking based on satellite ima...

Docker for mac & local developer environment optimization

  • 1. Radek Baczyński, Warszawa - 22.11.2018 Docker for Mac & local dev environment optimization
  • 2. Presentation title · Title of the chapter - 00/2018 2 ● Same environment as production server ● Same environment on each dev machine ● Immutable infrastructure ● Easy setup & configuration ● Easy upgrades of services Why docker on dev machine?
  • 3. Docker for Mac i optymalizacja środowiska developerskiego ● Opcache settings ○ memory_consumption ○ max_accelerated_files ● PHP settings: ○ realpath_cache_size ○ Realpath_cache_ttl ● Doctrine ○ metadata_cache_driver ○ query_cache_driver ○ result_cache_driver Basic performance optimization 3 ● Docker for Mac ○ edge version ○ .raw disk ○ APFS mac file system ○ Preferences → File sharing ■ Limit to your “project” dir ● Symfony ○ Log to /dev/stdout ○ Disable profiler?
  • 4. Docker for Mac i optymalizacja środowiska developerskiego Mac Linux VM Docker 4 osxfs mounted volume 📄 index.php 📄 index.php
  • 5. Docker for Mac i optymalizacja środowiska developerskiego 👍 Same user experience 5 👎 Poor performance Docker for Mac
  • 6. Docker for Mac i optymalizacja środowiska developerskiego ● Aggressive opcache ○ opcache.validate_timestamps=0 ● RAM disk ● NFS ● PHP 7.4 ○ https://wiki.php.net/rfc/preload Alternative ideas 6
  • 7. Presentation title · Title of the chapter - 00/2018 Benchmark 1 Default setup 7Presentation title · Title of the chapter - 00/2018 services: backend: image: php-7.2 volumes: - ./:/app ports: - 8080:8080 2578ms
  • 8. Presentation title · Title of the chapter - 00/2018 Benchmark 2 Removed xdebug extension 8Presentation title · Title of the chapter - 00/2018 services: backend: image: php-7.2 volumes: - ./:/app ports: - 8080:8080 1058ms
  • 9. Docker for Mac i optymalizacja środowiska developerskiego :delegated :cached 9 Docker for mac half-solution for performance issue
  • 10. Presentation title · Title of the chapter - 00/2018 Benchmark 3 Xdebug enabled & Delegated volume mount 10Presentation title · Title of the chapter - 00/2018 services: backend: image: php-7.2 volumes: - ./:/app:delegated ports: - 8080:8080 358ms
  • 11. Docker for Mac i optymalizacja środowiska developerskiego ● In docker container run 2 php-fpm processes ○ Port 9000 without xdebug.so ○ Port 9001 with xdebug.so Xdebug trick 11
  • 12. Docker for Mac i optymalizacja środowiska developerskiego 2 fpm processes 12 Port:9000, with xdebug.so Port:9001, without xdebug.so
  • 13. Docker for Mac i optymalizacja środowiska developerskiego Nginx config 13 map $cookie_XDEBUG_SESSION $fpm_port { default 9000; PHPSTORM 9001; } server { listen 80; location = / { rewrite ^/(.*)$ /app_dev.php/$1; } location @rewrite { rewrite ^/(.*)$ /app_dev.php/$1; autoindex on; } location ~ .php { fastcgi_index app_dev.php; fastcgi_pass 127.0.0.1:$fpm_port; #... } } ● Map fastcgi port
  • 14. Presentation title · Title of the chapter - 00/2018 Benchmark 4 Delegated & Removed xdebug extension 14Presentation title · Title of the chapter - 00/2018 services: backend: image: php-7.2 volumes: - ./:/app:delegated ports: - 8080:8080 262ms
  • 15. Docker for Mac i optymalizacja środowiska developerskiego Not enough for big Symfony apps Real case 15
  • 16. Presentation title · Title of the chapter - 00/2018 Docplanner Docplanner monolith ● Delegated ● Xdebug trick ● Minor optimizations 16Presentation title · Title of the chapter - 00/2018 2432ms
  • 17. Docker for Mac i optymalizacja środowiska developerskiego ● Don’t use problematic mounted volumes Solution 17 version: '3' services: backend: container_name: symfony_demo image: php-fpm7.2 volumes: - ./:/app:delegated ports: - 8080:8080
  • 18. Docker for Mac i optymalizacja środowiska developerskiego docker-sync 💪 mutagen.io 🔥 Solution 18
  • 19. Docker for Mac i optymalizacja środowiska developerskiego ● Same idea as docker-sync ● Less problems ● Better performance ● Tight docker integration ● Works with any dockerized app ● Easy to monitor ● Easy to manage mutagen.io 19
  • 20. Docker for Mac i optymalizacja środowiska developerskiego https://asciinema.org/a/KN0Opv0VxsCBNxbGo9ohkb3oX 1. brew install mutagen 2. mutagen daemon start 3. mutagen create PATH_ON_HOST docker://USER@CONTAINER_NAME/PATH_IN_CONTAINER 4. mutagen monitor Wait few seconds/minutes for first sync 5. It’s done mutagen.io 20
  • 21. Presentation title · Title of the chapter - 00/2018 Benchmark 5 No mounted volumes & xdebug enabled & mutagen 21Presentation title · Title of the chapter - 00/2018 47ms
  • 22. Presentation title · Title of the chapter - 00/2018 Benchmark 6 No mounted volumes & xdebug enabled & mutagen 22Presentation title · Title of the chapter - 00/2018 349ms
  • 23. Docker for Mac i optymalizacja środowiska developerskiego ● basic php optimizations ● optional xdebug ● mutagen.io Summary 23