Skip to content

Enable Autoscaling

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:

  • MySQL
  • Redis
  • Memcache
  • Elasticsearch
  • Varnish
  • Nginx

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

Enabling Autoscaling

  1. Open your Stratus panel
  2. Click Autoscaling from the left-hand navigation menu to bring up the form.
  3. 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
  4. 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.
  5. Set Enable Autoscaling to On at the top of the form
  6. Click Deploy Code to apply the change, this will cause 1-2 minutes of downtime.
  7. 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.

Troubleshooting

  • 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