jorge07 / symfony-6-es-cqrs-boilerplate

Symfony 6 DDD ES CQRS backend boilerplate.
MIT License
1.07k stars 187 forks source link

Improve docker performance and allowing public php files in dev env #166

Closed jorge07 closed 4 years ago

jorge07 commented 4 years ago

Reason

Docker file sync in windows and mac are very expensive and make things very slow. Since log ago I use Dinghy to develop in mac and performance is very close to native linux. As this as grow and I'm not the only one I tried during lasts weeks docker4mac and docker4windows and even if are far far away in performance against Dinghy and native, here some tricks that I found while fighting with 1-2s per request.

The results are:

[x] Docker4Mac ~1-2s -> 300-400ms [x] Docker4Windows ~2-4s -> 350-500ms [x] Dinghy 200ms-500ms -> 70-150ms

cv65kr commented 4 years ago

I tested on my dinghy (provider xhyve). In most time I have a 504 error. When I removed your changes everything is fine.

PHP logs:

php_1            | 2020-06-06 20:33:04,114 DEBG 'fpm' stderr output:
php_1            | [06-Jun-2020 20:33:04] WARNING: [pool www] child 17, script '/app/public/index.php' (request: "GET /index.php") executing too slow (5.447717 sec), logging
php_1            |
php_1            | 2020-06-06 20:33:04,116 DEBG 'fpm' stderr output:
php_1            | [06-Jun-2020 20:33:04] NOTICE: child 17 stopped for tracing
php_1            | [06-Jun-2020 20:33:04] NOTICE: about to trace 17
php_1            | [06-Jun-2020 20:33:04] NOTICE: finished trace of 17
php_1            |
php_1            | 2020-06-06 20:33:17,456 DEBG 'fpm' stderr output:
php_1            | [06-Jun-2020 20:33:17] WARNING: [pool www] child 13, script '/app/public/index.php' (request: "GET /index.php") execution timed out (120.396661 sec), terminating
php_1            |
php_1            | 2020-06-06 20:33:17,502 DEBG 'fpm' stderr output:
php_1            | [06-Jun-2020 20:33:17] WARNING: [pool www] child 13 exited on signal 15 (SIGTERM) after 313.108692 seconds from start

Nginx logs:

nginx_1          | 2020/06/06 20:29:10 [error] 6#6: *1 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.64.1, server: es.local, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.7:9000", host: "nginx.symfony-4-es-cqrs-boilerplate.local"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:29:10 +0000] "GET / HTTP/1.1" 504 168 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 2020/06/06 20:30:22 [error] 6#6: *1 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.64.1, server: es.local, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.7:9000", host: "nginx.symfony-4-es-cqrs-boilerplate.local"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:30:22 +0000] "GET / HTTP/1.1" 504 168 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:31:16 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 2020/06/06 20:32:17 [error] 6#6: *5 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.64.1, server: es.local, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.7:9000", host: "nginx.symfony-4-es-cqrs-boilerplate.local"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:32:17 +0000] "GET / HTTP/1.1" 504 168 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:32:54 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:32:55 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:32:58 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
nginx_1          | 2020/06/06 20:33:57 [error] 6#6: *5 upstream timed out (110: Operation timed out) while reading response header from upstream, client: 192.168.64.1, server: es.local, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.7:9000", host: "nginx.symfony-4-es-cqrs-boilerplate.local"
nginx_1          | 192.168.64.1 - - [06/Jun/2020:20:33:57 +0000] "GET / HTTP/1.1" 504 168 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15" "-"
jorge07 commented 4 years ago

Interesting. Let me review it

cv65kr commented 4 years ago

@jorge07 I restarted Dinghy and now works fast and properly. Great work.

jorge07 commented 4 years ago

Nice! Ready to merge then

Lutacon commented 4 years ago

fastcgi parameter "SCRIPT_FILENAME" is duplicated

jorge07 commented 4 years ago

Thanks, fixed in master