NOTE: Symlinks must use absolute paths.
Stratus Autoscaling requires some configuration to get working. We recommend working with our support to enable this feature.
How does autoscaling work?
In a typical high traffic scenario, PHP or PHP-FPM will be the resource that runs out first. If you had a dedicated server with 24 cores and a large sale, your site overhead would be in PHP resource usage, with the next bottleneck being MySQL. Sometimes the reverse is true.
Using Autoscaling, PHP-FPM can scale horizontally across physical hardware as needed to handle the additional load. Code is copied to into new PHP-FPM containers as they are spun up. Directories experiencing heavy file writes or requiring consistency, such as media/ and var/, are shared between all containers.
Only PHP scales?
Yes, only PHP-FPM is affected by autoscaling. The other services listed below do not automatically scale their available resources:
Scaling the other services is not required for most customers(Nginx uses very little CPU or RAM to do anything), though our single-tenant plans can have more resources added to those services. Multi-tenant plans have lower limits for MySQL.
If you see bottlenecks in MySQL or expect very high volume (at least several thousand RPM by New Relic APM metrics) please contact us for a custom solution
- Open your Stratus panel
- Click Autoscaling from the left-hand navigation menu to bring up the form.
- You will see 3 boxes
- Directories to include – by default this includes the common directories for Magento 1 or 2 based on the setting chosen under Magento->Stratus Template in the Stratus panel. This includes all core code that does not experience changes during production operation
- Directories to exclude – this is empty or only pub/media by default for Magento. Large directories containing extraneous files or unneeded files for production should be set here
- Shared Mounts – by default this is var/ and media/ or pub/media on Magento 2. Both of these directories experience writes such as cache images or logs during production operation and need to be accessed by all running PHP-FPM containers
- Edit to suit, some considerations are whether you have extra frameworks like a WordPress blog in your site, in which case you would want to add that to the Directories to Include (assuming you do not have a large amount of media on your WordPress installation) If your extra frameworks do have large media directories, those media directories should be added to Shared Mounts.
- Set Enable Autoscaling to On at the top of the form
- Click Deploy Code to apply the change, this will cause 1-2 minutes of downtime.
- Now you are set, when load reaches certain thresholds additional PHP services will spawn automatically.
Updating code while scaled
You can use the Deploy Code button to relaunch services and refresh any scaled out containers. For a rolling update, use the Stratus CLI command _autoscaling.reinit _Do not do this under load unless absolutely necessary as it will cause downtime.
Our general recommendation is to never change production code during high volume traffic/sales except in emergencies.
- Some pages are not loading or showing a 404 – check your includes to be sure the code is properly being copied to additional services
- I see weird behavior/errors – Check the PHP error and Magento error logs, likely some code is not being included and causing a fatal or other error
- Images are not showing when I turn on autoscaling and I use Mirasvit SEO. – Under Stores->Configuration->Mirasvit->Enable SEO-friendly URLs for product images to DISABLED.
seo/image/is_enable_image_friendly_url = 0
- My CSS is missing or my page structure is garbled. – Under Stores > Configuration > Advanced > Developer > Template Settings: Set minify html to NO.
dev/css/minify_html = 0
- My CSS is missing or my page structure is garbled. – Under Stores > Configuration > Advanced > Developer in Developer mode.
dev/template/allow_symlink = 1 (true)
- My instance takes longer to redeploy services. – Make sure there are no large dumps or backups stored under your Magento root directory. Every time php-fpm pods are redeployed, they will copy these dumps as well and this will extend boot time and the ability of your store to scale on demand quickly.