These are instructions for Hypernode. Instructions for Hipex would be a bit different. - Jos
This might help with making sure that large / long-running scripts won't hang. One CLI command needed.
hypernode-systemctl settings mysql_enable_large_thread_stack --value True
After this, a MySQL restart is needed. Couple of minutes downtime.
For background info see here: https://support.hypernode.com/en/hypernode/mysql/how-to-configure-a-large-mysql-thread-stack
On Hypernode, mostly default settings are used for MySQL. This is sometimes OK for smaller sites. Most of the time: not optimal. Hypernode can and will change these settings on request per mail.
- login via SSH
- do
wget https://raw.githubusercontent.com/BMDan/tuning-primer.sh/master/tuning-primer.sh
- do
chmod +x tuning-primer.sh
- Run tuning-primer.sh by
./tuning-primer.sh
-- and look at the report and values. - Especially look for:
join_buffer_size
,table_open_cache
,table_definition_cache
,table_cache
, andinnodb_buffer_pool_size
.
On a small database, the innodb_buffer_pool_size
is mostly OK. On a larger database, if not large enough, swaps will occur between memory and disk.
This value needs to be increased. A normal "rule of thumb" is that mysql memory should take up about 80% of total RAM.
I advise that we use a mamximum of 50% of RAM, just to be sure that there is more than enough memory left for nginx, elastic, varnish, php and redis.
- Look at
htop
memory usage. In this example you see that only ~10G of total 32G is used. We can safely increase RAM usage of MySQL to around 16G (if needed). - In this case we can ask Hypernode to increase the setting of
innodb_buffer_pool_size
to 16G.
- upload the tweaked vcl file to
/data/web/magento2
varnishadm vcl.load mag2 /data/web/magento2/vcl-jhp-optimized-jos.vcl
varnishadm vcl.use mag2
varnishadm vcl.list
(see if new varnish vcl is used)- wait 5-6 minutes (see timestamp on
/data/var/varnish/default.vcl
<-- this needs to be updated) hypernode-servicectl restart varnish
hypernode-servicectl reload nginx
- check
varnishstat
for hit rate and cache usage.
- Create extra file in:
/data/web/nginx
--> filename:server.header_buffer_jos
- add content:
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
- save
hypernode-servicectl reload nginx
- Create extra file in:
/data/web/nginx
--> filename:server.bots_goaway_jos
- add content:
if ($http_user_agent ~* (360Spider|bingbot|BLEXbot|SEOKicks|Mauibot|Riddler|ltx71|ZoominfoBot|seznam|velen|GrapeshotCrawler|Baidu|Censys|Pinterest) ) {
return 410;
}
- save
hypernode-servicectl reload nginx
in the /data/web/magento2/pub/media/
directory.
(except /catalog
dir because of SRS import). This also makes jpgs load progressively in browsers.
cd /data/web/magento2/pub/media/
find . -type f -not -path "./catalog/*" -not -path "./tmp/*" -not -path "./import/*" -name "*.jpg" -exec jpegoptim --all-progressive -p -t -v -P {} \;
- let this run in the background. Can take a long time.
cd /data/web/magento2/pub/media/
find -type f -iname "*.png" -exec optipng -fix -o4 -v -preserve {} \; -exec touch -m -a {} \; -exec chmod 755 {} \;
- let this run in the background. Can take a long time.
-
stores > configuration > mirasvit > page cache warmer: --> "Forcibly make pages cacheable"; set: configured + set 3 checkboxes; save config.
-
stores > configuration > advanced > system > full page cache: --> set TTL for public content to: 2629743 (1 month); save config.
This pre-connects the DNS to domains that will be loaded later, after the HTML has parsed. This speeds up page loads with slow-loading external sites/scripts, by already connecting to those domains AS SOON AS the http header is sent to the browser. Longer explanation: https://andydavies.me/blog/2019/03/22/improving-perceived-performance-with-a-link-rel-equals-preconnect-http-header/
Change the nginx config:
- Create extra file in:
/data/web/nginx
--> filename:server.preconnect.conf
- add content (set domains etc. accordingly)
add_header Link '<https://cloud.wordlift.io/>; rel=preconnect; crossorigin=anomynous; probability=1.0;';
add_header Link '<https://connect.nosto.com/>; rel=preconnect; crossorigin=anonimous; probability=1.0;';
add_header Link '<https://cloud.wordlift.io/app/bootstrap.js>; as=script; crossorigin=anonymous; rel=preload;';
- save
hypernode-servicectl reload nginx
Done.
Test the header by using curl -I https://www.example.com
.
====
- Upgrade Magento from 2.x naar 2.4.x, including ElasticSearch. ("Search_tmp table" bug); lower mysql load.
- Upgrade Template (Theme) to newest version.
- Improve SRS import script: faster -> import only changed items;
- flush only cache for changed items, not complete FPC
- Remove unneeded JS and external pixels/scripts from template
- Configure and use Cloudflare.