7

I am testing my website on "https://developers.google.com/speed/pagespeed/insights/" and have only low ratings (9-12/100).

My Setup:

Virtual Server (CentOS) with 16 GB RAM, 6 cores (Intel Xeon), SSD Storage Magento 2.1.7 Apache 2.4.6
MariaDB 10.1

I made sure to have 14GB RAM in my php.ini (memory_limit = 14000M).

Also edited .htaccess and .user.ini in magento root directory and pub directory (all have 14 GB RAM).

My configuration file for MariaDB (/etc/my.cnf) looks like this:

[client] port = 3306 socket = /var/lib/mysql/mysql.sock

[mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock skip-external-locking key_buffer_size = 384M max_allowed_packet = 10M
table_open_cache = 4096 sort_buffer_size = 16M
read_buffer_size = 4M read_rnd_buffer_size = 14M
myisam_sort_buffer_size = 64M thread_cache_size = 256

query_cache_type = 1 query_cache_limit = 4M

query_cache_size = 512M thread_concurrency = 8

log-bin=mysql-bin server-id = 1 innodb_buffer_pool_size = 3000M
innodb_additional_mem_pool_size = 80M

[mysqldump] quick max_allowed_packet = 512M

[mysql] no-auto-rehash

[myisamchk] key_buffer_size = 256M
sort_buffer_size = 256M read_buffer = 4M
write_buffer = 4M

[mysqlhotcopy] interactive-timeout

I don't know why my website is still so slow (server response is always 1-2.5 seconds according to google pagespeed), even though my hardware is good enough (enough RAM).

PS: My magento mode is developer and all css js minify and merge options are off.

  • Please post text results from Centos of ulimit -a and iostat -x for analysis. – Wilson Hauck Jul 4 '18 at 1:39
  • If you will post text results from Centos of ulimit -a and iostat -x for analysis someone will be better prepared to provide suggestions to consider. Any chance we could Skype connect? – Wilson Hauck Jul 12 '18 at 16:02
  • When you are READY to make some progress post the information requested on July 12, 2018 and apply the Suggestions posted on July 4, 2018. Thanks – Wilson Hauck Dec 15 '18 at 18:07
3

Reason for Slow

  1. It is in developer mode with CSS/JS merge/bundle/minify enabled.
  2. It is running on slow hardware.
  3. Some 3rd party extension breaks performance.
  4. SSD not used.
  5. Full page cache and other caches are turned off.

PS: Here is how to find out what M2 mode you are in:

cd magento_main_folder
php bin/magento deploy:mode:show

When you are in Developer Mode

This mode is needed when you are just getting your site ready for production. But wait time of 30s could be very frustrating and annoying.Here is 3 simple fixes you could try to speed up magento2:

1. Disable CSS & JS merge / bundle / minify That trick alone helped me reduce speed from 50s down to 2s.

Go to Stores > Configuration > Advanced > Developer > Javascript Settings and CSS Settings 

2. Move to PHP7 While magento 2 works great on php 5.6 a move to php7 alone can improve performance by 25%.

3. Server resources Magento 2 is a complex system. Especially in developer mode it requires powerful hardware.Avoid virtualization. Make sure you allocate at least 2G of RAM to M2.

When you are in production mode

1. Audit your 3rd party extensions Magento 2 is greatly extendable with plugins and modules. But unlike core functionality that was coded by Magento Core Team and experts 3rd party extensions are developed ( in most cases ) by average programmers. With average skills. One poorly written module could slow magento down big time.Get a list of all plugins you installed and disable them one by one. See if it affects performance in any way. Identify a bottleneck and contact vendor for assistance.Go ahead and install a fresh Magento 2 with sample data on the same server. Compare its speed to your production site. If a default M2 is as slow as your customized magento store then go to step 2. If it is significantly faster then you know you have an extension that slows you down.

2. Server hardware makes magento 2 slow You can simply find it out if you install a fresh M2 on the same server and compare its performance to your production site. If you don't see a difference then obviously your hosting plan is not suitable for magento2. Sign up for better hosting and secure more CPU/RAM power. Don't be cheap here!

3. Make sure full page cache is on

 System > Cache Management
1

I would recommend to check (even as a trial option) solutions like:

  1. NewRelic
  2. Blackfire.io
  3. xdebug

Those tools will show you exact traces and timing of each separate PHP Trace that is involved within any operation/transaction (and allow you to find bottlenecks within Application / Database Flows)

0

Suggestions to consider for your my.cnf [mysqld] section to improve performance

Lead with # spacebar the following to allow defaults vs overallocation for

sort_buffer_size
read_buffer_size
read_rnd_buffer_size

adjust the following:

query_cache_limit=1M  # from 512M for max size of 1 RESULT into QC
query_cache_min_res_unit=512  # from 4096 to store more RESULTS into QC
thread_cache_size=100  # from 256 for CAP see refman V8 to avoid OOM
innodb_lru_scan_depth=256  # from 1024 to conserve CPU time every second
innodb_flush_neighbors=0  # from ON to conserve CPU SSD has no rotational delay
innodb_purge_threads=4  # from 1 to expedite purge activity
innodb_flushing_avg_loops=10  # from 30 to reduce loop delays
max_write_lock_count=16  # to allow RD after nn write lcks vs up to ~4 Billion lcks

please post progress from time to time,

for additional suggestions check my profile, Network profile for contact info.

  • @shahirhajir Have you had an opportunity to try any of the above suggestions? Making progress? – Wilson Hauck Aug 6 '18 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.