Mysql performance issue on Macbook Pro M1

I am seeing this message in my docker container I created for WordPress based projects.

Screenshot-2022-10-08-at-5-56-23-PM

And sometimes I am noticing the slow loading of pages which may be due to this.
Here is my docker container code

I think I am using the wrong platform for MySQL as I was facing some error while running the container for the first time on this new Mac machine. So I did google and found a solution to add platform option. Which stopped the error but now I have a slow DB.

Can someone help me in right direction?

Thank You,
Aslam

You can find the supported platforms for each tag here: https://hub.docker.com/_/mysql/tags

linux/x86_64 is not one of those, but the other name of x86_64 is amd64 which is there.
However, the problem is probably not the platform, since I guess Docker recognized x86_64 as an alias of amd64 and pulled the right image. You donā€™t need the platform option if the image supports the architecture of your CPU. If it doesnā€™t, it will either not run or you use the platform option to emulate one of the supported architectures by the image. It will be an emulation so it will run slower and sometimes, since emulation is not perfect, it will not work at all. Older images in the mysql repository (or possibly MySQL itself) did not support ARM architecture. mysql:8 does. If you want to use older versions of MySQL or at least a compatible database engine, you can try MariaDB if you can find out which version was compatible with MySQL 5.7.

If you already have a MySQL database server running, make sure you donā€™t just replace the image with mariadb, but export the current databases and import it into mariadb if you canā€™t or donā€™t want to recreate the data in the other container an other way.

1 Like

Thatā€™s a great explanation @rimelek
I think my problem is mysql version as I am using 5.7 version.
I have already done some work on an existing project so I will try version 8 on another image and see if that helps.

Thank You.

@rimelek I have just updated my docker container to use mysql version 8. The changes can be seen on same repository. But there is still like 5-6 seconds delay while browsing the wordpress site.

aslamdoctor/docker-wordpress/blob/main/docker-compose.yml

It is something like this, I open the site for first time, it take few seconds to load then if I browse inner pages immediately, its fast. But then if I leave the browser open say for a minute and do nothing and come back again and try to surf the site, its again few seconds wait for the first time. Its like some kind of session is ON while browsing the site for first time then all the pages loads faster then when I am away for 2-3 minutes, the session is off. Any help? Could it be because I am using traefik container for hosting the sites locally?

I donā€™t think so, but you can try without that and see if there is any difference.

Thanks for the reply. I tried without traefik, same result. Then I tried with Mariadb and still same result.
I think its the famous mac m1 + docker speed issue.

But if I run a simple wordpress container, it works fine. Here is a code for that. Notice it also uses Mariadb.

services:
  db:
    # We use a mariadb image which supports both amd64 & arm64 architecture
    image: mariadb:10.6.4-focal
    # If you really want to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somewordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    expose:
      - 3306
      - 33060
  wordpress:
    image: wordpress:latest
    volumes:
      - ./wp_data:/var/www/html
    ports:
      - 80:80
    restart: always
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
      - WORDPRESS_DB_NAME=wordpress
volumes:
  db_data:

I found the solution and I am going to sound stupid :persevere:

I had this entry inside /etc/hosts file

127.0.0.1 mywebsite.local

But not this

::1 mywebsite.local

And that was the only problem.
What a waste of time.

Not at all! First of all, learning is not a waste of time and the solution does not always come immediately. And second, I still donā€™t understand why using an IPv6 address instead of IPv4 helped.