Skip to content

Autoscaling Panel

Stratus Autoscaling is one of the more powerful features of Mojo Stratus. Autoscaling keeps a store functioning even during periods of higher than usual traffic.

Configuration of Stratus Autoscaling does require some initial configuration. In order to fully benefit from this feature, we recommend that you contact MageMojo support for assistance.

How does autoscaling work?

When high traffic occurs on a Magento store, the code that is processed by PHP — the core Magento code — quickly becomes the bottleneck. Autoscaling resolves these bottlenecks by replicating the PHP code as "containers" across additional physical hardware instances in the AWS cloud.

Certain directories, such as /media/ and /var/ are not replicated, as these are generally static files that require greater consistency. These directories are shared across all the PHP containers.

Stratus Autoscaling only applies to the PHP-FPM code. Except in certain special cases — where MageMojo creates custom autoscaling configurations — Stratus Autoscaling does not automatically scale MySQL, Redis, Memcache, Elasticsearch, Varnish, or Nginx instances. Scaling these resources are not normally required.

If a store is experiencing extremely high MySQL activity, MageMojo Support can assist in creating an ideal autoscaling configuration.

Enabling Autoscaling

NOTE: Symlinks must use absolute paths in order for autoscaling to work properly.

  1. Go to Control > Autoscaling in the Stratus sidebar menu.

    • Enable AutoscalingSelect Autoscaling Enabled
    • Enable Zero Downtime deploymentsSelect Zero Downtime Deployment Enabled

    • Directories to Include — by default this includes the common directories for Magento 1 or 2 based on the setting chosen under the Magento > Stratus Template panel. Generally, this includes all core code that does not experience changes during normal production operation. These directories will be copied out to additional physical nodes during a scaling event. This should include files and folders that will not be written to during normal operation. Static theme files and code are included by default. If you have extra frameworks like Wordpress or custom scripts, you should include those directories.

    • Directories to Exclude — this section is either empty or contains pub/media as a Magento default. Large directories containing extraneous files or code not required by the Production instance should be included in this field. Excludes should match the shared folders, especially if you are including part of them in the Includes section. Any large media directories should be excluded. Otherwise scaling will take a very long time as those assets are copied over our network to additional hardware. And you should exclude large subfolders if the parent folder is in the include list. For example, you want to include pub/ for a Magento 2 store, but not include pub/media since it is very large. The exclusion ensures the subfolder is not copied but the rest of the parent folder is copied.

    • Shared Mounts — by default this is var/ and media/ (or pub/media on Magento 2) directories. 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. Shared mounts are mounted over the network from the home node for your store. The Magento media folder is the primary folder you need and var, since both folders experience frequent writes (log files or media cache). And most media folders are too large copy out and duplicating media would lead to split brain i.e. a captcha image can be generated on one node but not appear on another if the directory is not shared.

  2. Click DEPLOY CODE to apply the change. This may result in 1-2 minutes of downtime.

Updating Code

If Autoscaling is enabled, you can click DEPLOY CODE to relaunch services and refresh any scaled containers. For a "rolling update," use the Stratus CLI command autoscaling.reinit. Do not run this command 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 copied to additional services.
  • Weird behavior/ or errors — check the PHP error and Magento error logs; there is likely some code that not being included and causing an error.
  • Images are not showing with Autoscaling and Mirasvit SEO — Under Stores > Configuration > Mirasvit in the Magento Admin, set Enable SEO-friendly URLs for product images to Disabled. (seo/image/is_enable_image_friendly_url = 0)
  • CSS is missing or page structure is not rendering correctly — Under Stores > Configuration > Advanced > Developer > Template Settings in the Magento Admin, set Minify HTML to No. (dev/css/minify_html = 0) Another possibility is under Stores > Configuration > Advanced > Developer, in Developer mode, set Allow Symlinks to Yes. (dev/template/allow_symlink = 1 (true))
  • Instance takes longer than expected to redeploy services — Make sure there are no large dumps or backups stored in the Magento root directory. Every time php-fpm containers are redeployed, all files, including dumps and backups, are copied and will extend boot time and the ability of your store to scale on demand quickly.