Symfony 4 is painfully slow in DEV

user3429660 picture user3429660 · Feb 18, 2018 · Viewed 9.6k times · Source

I try to run a simple Symfony 4 project on a docker container. I have tested regular PHP scripts, and they work very well. But, with Symfony project, the execution gets ridiculously slow. For example, a page without any significant content takes 5-6 seconds.

I have attached the screenshots from Symfony's performance profiler.

Screenshot1 Screenshot2 Screenshot3 Screenshot4

Do you have any idea what how to reduce this execution time to an acceptable level?

Answer

user3429660 picture user3429660 · Feb 19, 2018

It seems that changing the consistency level greatly increases Symfony performance. (see Docker docs)

Here is my new docker-compose.yml file. Note the ":cached" after the volumne.

version: '3'
services:
  web:
    image: apache-php7
    ports:
     - "80:80"
    volumes:
      - .:/app:cached
    tty: true

Note from manual:

For directories mounted with cached, the host’s view of the file system is authoritative; writes performed by containers are immediately visible to the host, but there may be a delay before writes performed on the host are visible within containers.