Docker: Connection PHP/Apache --> MySQL slow












0















I would like to ask for help on my Docker installation, because I can't fix it.
I have read a lot about slow Docker containers but all things I tried don't help.



When I browser the phpmyadmin UI it feels quite fast and tables/edits load quickly. But when I load my CMS it is slow (takes about 3 to 5 seconds) to load. Even the AJAX requests inside the CMS are slow. The CMS is very fast on my production webserver, in fact it is still faster than my local Docker installation. I guess there is a problem when connection form the webserver to the MySQL server. Had read about DNS problems with this, but couldn't find a way to solve it.



What I tried:




  • use 'link' to connect the containers

  • use 'network_mode: host'

  • use 'networks: - mylocalnetwork' and 'networks: mylocalnetwork: driver: bridge'

  • put the MySQL data inside the container (not on the host OS)

  • changed ports

  • some other, can't remember


Docker Version 2.0.0.0-mac81 (29211) (Engine: 18.09.0)



Docker-compose.yml:



version: '3'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_DATABASE: devtest
MYSQL_USER: root
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
ports:
- "9906:3306"
network_mode: "host"
web:
build: .
depends_on:
- db
volumes:
- /path/to/www:/var/www/html
ports:
- "8100:80"
tty: true
stdin_open: true
network_mode: "host"
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- db
external_links:
- db:mysql
ports:
- "9191:80"
environment:
PMA_HOST: db
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: pass
MYSQL_PASSWORD: pass
network_mode: "host"


Dockerfile



FROM php:7.2.2-apache

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysqli

#RUN apt-get update
#RUN apt-get install nano

RUN usermod -u 1000 www-data

RUN a2enmod rewrite
RUN a2enmod headers
RUN a2enmod expires


=== EDIT
From Docker App Advanced Settings:
CPU: 4
RAM: 2 GB
SAWP 1 GB
An exported SQL file is ~ 450 KB
CMS says allocated memory peak is 19.56 MB










share|improve this question

























  • Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

    – Stese
    Jan 7 at 14:15











  • Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

    – Keysmith
    Jan 7 at 15:24











  • Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

    – Wilson Hauck
    Jan 19 at 18:38
















0















I would like to ask for help on my Docker installation, because I can't fix it.
I have read a lot about slow Docker containers but all things I tried don't help.



When I browser the phpmyadmin UI it feels quite fast and tables/edits load quickly. But when I load my CMS it is slow (takes about 3 to 5 seconds) to load. Even the AJAX requests inside the CMS are slow. The CMS is very fast on my production webserver, in fact it is still faster than my local Docker installation. I guess there is a problem when connection form the webserver to the MySQL server. Had read about DNS problems with this, but couldn't find a way to solve it.



What I tried:




  • use 'link' to connect the containers

  • use 'network_mode: host'

  • use 'networks: - mylocalnetwork' and 'networks: mylocalnetwork: driver: bridge'

  • put the MySQL data inside the container (not on the host OS)

  • changed ports

  • some other, can't remember


Docker Version 2.0.0.0-mac81 (29211) (Engine: 18.09.0)



Docker-compose.yml:



version: '3'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_DATABASE: devtest
MYSQL_USER: root
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
ports:
- "9906:3306"
network_mode: "host"
web:
build: .
depends_on:
- db
volumes:
- /path/to/www:/var/www/html
ports:
- "8100:80"
tty: true
stdin_open: true
network_mode: "host"
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- db
external_links:
- db:mysql
ports:
- "9191:80"
environment:
PMA_HOST: db
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: pass
MYSQL_PASSWORD: pass
network_mode: "host"


Dockerfile



FROM php:7.2.2-apache

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysqli

#RUN apt-get update
#RUN apt-get install nano

RUN usermod -u 1000 www-data

RUN a2enmod rewrite
RUN a2enmod headers
RUN a2enmod expires


=== EDIT
From Docker App Advanced Settings:
CPU: 4
RAM: 2 GB
SAWP 1 GB
An exported SQL file is ~ 450 KB
CMS says allocated memory peak is 19.56 MB










share|improve this question

























  • Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

    – Stese
    Jan 7 at 14:15











  • Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

    – Keysmith
    Jan 7 at 15:24











  • Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

    – Wilson Hauck
    Jan 19 at 18:38














0












0








0








I would like to ask for help on my Docker installation, because I can't fix it.
I have read a lot about slow Docker containers but all things I tried don't help.



When I browser the phpmyadmin UI it feels quite fast and tables/edits load quickly. But when I load my CMS it is slow (takes about 3 to 5 seconds) to load. Even the AJAX requests inside the CMS are slow. The CMS is very fast on my production webserver, in fact it is still faster than my local Docker installation. I guess there is a problem when connection form the webserver to the MySQL server. Had read about DNS problems with this, but couldn't find a way to solve it.



What I tried:




  • use 'link' to connect the containers

  • use 'network_mode: host'

  • use 'networks: - mylocalnetwork' and 'networks: mylocalnetwork: driver: bridge'

  • put the MySQL data inside the container (not on the host OS)

  • changed ports

  • some other, can't remember


Docker Version 2.0.0.0-mac81 (29211) (Engine: 18.09.0)



Docker-compose.yml:



version: '3'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_DATABASE: devtest
MYSQL_USER: root
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
ports:
- "9906:3306"
network_mode: "host"
web:
build: .
depends_on:
- db
volumes:
- /path/to/www:/var/www/html
ports:
- "8100:80"
tty: true
stdin_open: true
network_mode: "host"
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- db
external_links:
- db:mysql
ports:
- "9191:80"
environment:
PMA_HOST: db
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: pass
MYSQL_PASSWORD: pass
network_mode: "host"


Dockerfile



FROM php:7.2.2-apache

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysqli

#RUN apt-get update
#RUN apt-get install nano

RUN usermod -u 1000 www-data

RUN a2enmod rewrite
RUN a2enmod headers
RUN a2enmod expires


=== EDIT
From Docker App Advanced Settings:
CPU: 4
RAM: 2 GB
SAWP 1 GB
An exported SQL file is ~ 450 KB
CMS says allocated memory peak is 19.56 MB










share|improve this question
















I would like to ask for help on my Docker installation, because I can't fix it.
I have read a lot about slow Docker containers but all things I tried don't help.



When I browser the phpmyadmin UI it feels quite fast and tables/edits load quickly. But when I load my CMS it is slow (takes about 3 to 5 seconds) to load. Even the AJAX requests inside the CMS are slow. The CMS is very fast on my production webserver, in fact it is still faster than my local Docker installation. I guess there is a problem when connection form the webserver to the MySQL server. Had read about DNS problems with this, but couldn't find a way to solve it.



What I tried:




  • use 'link' to connect the containers

  • use 'network_mode: host'

  • use 'networks: - mylocalnetwork' and 'networks: mylocalnetwork: driver: bridge'

  • put the MySQL data inside the container (not on the host OS)

  • changed ports

  • some other, can't remember


Docker Version 2.0.0.0-mac81 (29211) (Engine: 18.09.0)



Docker-compose.yml:



version: '3'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_DATABASE: devtest
MYSQL_USER: root
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
ports:
- "9906:3306"
network_mode: "host"
web:
build: .
depends_on:
- db
volumes:
- /path/to/www:/var/www/html
ports:
- "8100:80"
tty: true
stdin_open: true
network_mode: "host"
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- db
external_links:
- db:mysql
ports:
- "9191:80"
environment:
PMA_HOST: db
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: pass
MYSQL_PASSWORD: pass
network_mode: "host"


Dockerfile



FROM php:7.2.2-apache

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install mysqli

#RUN apt-get update
#RUN apt-get install nano

RUN usermod -u 1000 www-data

RUN a2enmod rewrite
RUN a2enmod headers
RUN a2enmod expires


=== EDIT
From Docker App Advanced Settings:
CPU: 4
RAM: 2 GB
SAWP 1 GB
An exported SQL file is ~ 450 KB
CMS says allocated memory peak is 19.56 MB







networking dns apache-http-server mysql docker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 7 at 15:23







Keysmith

















asked Jan 7 at 13:47









KeysmithKeysmith

11




11













  • Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

    – Stese
    Jan 7 at 14:15











  • Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

    – Keysmith
    Jan 7 at 15:24











  • Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

    – Wilson Hauck
    Jan 19 at 18:38



















  • Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

    – Stese
    Jan 7 at 14:15











  • Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

    – Keysmith
    Jan 7 at 15:24











  • Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

    – Wilson Hauck
    Jan 19 at 18:38

















Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

– Stese
Jan 7 at 14:15





Hi Keysmith. We'll need more info on your setup to give you a good idea of what might be happening. please can you provide the capabilities of the docker instance (CPU, RAM availablity etc), and the size of the relevant databases. Also, is the same slowness across all browsers?

– Stese
Jan 7 at 14:15













Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

– Keysmith
Jan 7 at 15:24





Thanks. I have updated my post above. And yes, slow on multiple browsers (incognito mode)

– Keysmith
Jan 7 at 15:24













Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

– Wilson Hauck
Jan 19 at 18:38





Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, df -h for a linux/unix free space list by device, for server tuning analysis.

– Wilson Hauck
Jan 19 at 18:38










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1391504%2fdocker-connection-php-apache-mysql-slow%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1391504%2fdocker-connection-php-apache-mysql-slow%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕