Magento 2 Configuration Best Practices and Settings

Magento 2 Configuration Best Practices and Settings

Magento 2 configuration manages various aspects of a store, including basic settings like currency and time zone and more advanced options like caching and indexing. It lets you customize your store's functionalities to match your unique needs and preferences. Proper configuration affects speed, user experience, SEO, and scalability. This tutorial will cover the essential steps to efficiently configure your Magento 2 store.

Key Takeaways!

  • Discover how to set up Magento cron jobs for automated task management efficiently.

  • Learn the differences between Indexer modes and how to optimize them for your store.

  • Understand the importance of Magento cache optimization with tools like Varnish for faster performance.

  • Explore asynchronous email notifications and order data processing to enhance operational efficiency.

  • Find out how to manage stock updates and customer segments for improved user experience.

  • Gain insights into client-side optimization settings for a more responsive Magento storefront.

Magento 2 System Configuration Best Practices & Settings

1. Magento Cron Jobs

All tasks at predefined intervals, dates, and times in Adobe Commerce are carried out using the cron command. To create a cron job in Magento, run the command "bin/magento cron:install" in your terminal. Ensure the file system owner has 'write' permissions for the Magento file system.


Learn how to configure Magento 2 cron jobs for optimal configuration properly.

2. Indexers

There are two modes in which an indexer can operate: Update on Save and Update on Schedule. In Update on Save mode, indexing occurs whenever there are changes to your catalog or other data. This mode is suitable for situations where there is a low level of update and browsing activities in your store. However, during high loads, it may result in notable delays and limited access to data.


For optimal production use, employ the Update on Schedule mode. This mode stores data update information and performs background indexation in portions through a dedicated cron job. To switch the mode of indexers, navigate to System, then Tools, and finally Index Management.

Magento 2 Indexer Settings for Optimal Catalog Update

3. Caches

To optimize your store's performance in production, enable all caches through the Cache Management page in the System > Tools section.

Magento 2 Cache Management Interface for Enhanced Performance

Varnish is a powerful page cache solution for production. It acts as a proxy server, delivering content quickly by sitting in front of your main server. When someone visits your website, the cache fulfills the request instead of sending it to Magento.


Varnish determines if visitors request the Home page or Checkout, serving cached content without executing a MySQL query or hitting any PHP code. To set up Varnish in Magento, access the Magento Admin.

To configure the full-page cache settings in your system, follow these steps:

Varnish Cache Configuration in Magento 2 for Speed Optimization

  • Navigate to Stores > Configuration > Advanced > System > Full Page Cache.

  • Select "Varnish Caching" from the Caching Application list.

  • Set a value in the TTL for public content field.

  • Expand the Varnish Configuration section and provide details for your specific Varnish configuration.

4. Asynchronous Email Notifications

When you enable the "Asynchronous email notifications" option, the tasks related to checkout and order processing email notifications are moved to the background. This helps improve efficiency and allows for smoother operation.

To enable this feature, follow these steps:

  • Go to Stores.

  • Click on Settings.

  • Select Configuration.

  • Navigate to Sales.

  • Choose Sales Emails.

  • Click on General Settings.

  • Enable Asynchronous Sending.

Configuring Asynchronous Email Notifications in Magento 2 for Efficiency

For more information, refer to the Sales Emails section in the Magento Open Source User Guide.

5. Asynchronous Order Data Processing

Intensive sales and order processing can happen simultaneously on a storefront. To prevent conflicts between read and write operations, Adobe Commerce can be configured to distinguish these two traffic patterns at the database level. Order data can be stored and indexed asynchronously.


Orders are stored temporarily and then transferred in large groups to the Magento Order Management grid without any issues. To enable this feature, go to Stores > Settings > Configuration > Advanced > Developer > Grid Settings > Asynchronous indexing.

Magento 2 Asynchronous Order Data Processing Interface

6. Saving Asynchronous Configuration

Saving a store configuration in projects with numerous store-level configurations can be time-consuming or lead to timeouts. The Async Config module allows for saving configurations asynchronously. It achieves this using a cron job that utilizes a consumer to process the save in a message queue. By default, AsyncConfig is disabled.


To activate AsyncConfig, follow these steps in the command-line interface:

bin/magento setup:config:set --config-async 1

The set command updates the app/etc/env.php file with the following information.

...
  'config' => [
      'async' => 1
  ]
  

To start processing the messages in the queue, launch the Consumer. It operates on a FIFO basis: bin/magento queue:consumers:start saveConfigProcessor --max-messages=1

7. Deferred Stock Update

During periods of high sales, Magento can delay stock updates for orders. This helps streamline the order placement process by reducing the number of operations. However, this option comes with risks and should only be used when Backorders are enabled in the store.


To boost Checkout performance, this option is available for stores capable of swiftly restocking items as required. To enable deferred stock updates on your site, follow these steps:

  • Go to Stores.
  • Click on Settings.
  • Select Configuration.
  • Navigate to Catalog.
  • Choose Inventory.
  • Click on Product Stock Options.
  • Activate Use Deferred Stock Update.

Magento 2 Deferred Stock Update for Improved Checkout Performance

8. Customer Segments Validation

Merchants with multiple customer segments may notice a decline in performance when customers perform actions like logging in and adding products to the cart.

When customers take certain actions, it triggers a validation process for customer segments. This process can lead to performance issues. By default, Adobe Commerce validates each segment in real-time to determine which segments match with customers and which ones do not.

Magento 2 Customer Segments Validation for Optimized Performance

To prevent performance decline, you can disable the Real-time Check if Customer is Matched by Segment system configuration. This will validate customer segments using a single combined condition SQL query.

To optimize this, follow these steps:

  • Go to Stores.
  • Click on Settings.
  • Select Configuration.
  • Choose Customers.
  • Click on Customer Configuration.
  • Go to Customer Segments.
  • Check if the segment matches the customer in real time.

Enabling this setting enhances customer segment validation performance when there are numerous customer segments in the system.

9. Improving Product Grid Performance by Limiting Product Numbers in the Grid

To improve product grid performance for large catalogs, you should limit the number of products in the grid. To achieve this, you can adjust the system configuration setting by navigating to Stores > Settings > Configuration > Advanced > Admin > Admin Grids > Limit Number of Products in Grid.


By default, this system configuration setting is turned off. However, you can enable it and set a specific value to restrict the number of products displayed in the grid.


You can limit product grid collections to specific pages, such as Catalog Product Grid, Add Related Products Grid, Add Products to Bundle Product, Add Products to Group Product, and Admin Create Order Page.

10. Client-Side Optimization Settings

To enhance the storefront responsiveness of your Magento site, follow these steps in the Admin section:

  • Enable Asynchronous indexing under Grid Settings.
  • Enable minification of CSS files.
  • Enable minification of JavaScript files.
  • Enable JavaScript bundling.
  • Enable minification of HTML.

These changes will help improve the performance of your Magento site's storefront.

FAQs

1. What are the best practices for Magento 2 configuration?

The best practices for Magento 2 configuration include using secure settings, keeping your store updated with the latest versions, and customizing settings to match your business needs.


2. How do I make sure my Magento 2 settings are safe?

To keep your Magento 2 settings safe, create strong passwords, set up secure payment methods, and regularly check for any security updates or patches. Choosing the right Magento hosting can also protect your site from potential security threats.


3. Can I customize my Magento 2 store to fit my business?

Yes! You can customize many parts of your Magento 2 store like its look, how it works, and what options you offer customers so that it fits just right with what you sell and who buys from you.


4. Should I update my Magento 2 store even if everything seems fine?

Yes - always keep your Magento 2 store up to date! It helps fix problems before they start and makes sure everything runs smoothly.


5. What is System.xml configuration in Magento 2?

The system.xml file is a configuration file in Magento 2. It helps create configuration fields in the System Configuration. This file is necessary if your module requires admin panel settings. To see how it looks, go to Store -> Setting -> Configuration.

Summary

Optimizing Magento 2 configuration is crucial for store performance and SEO success. Best practices focus on response time, SEO settings, and enhancing site performance. Implementing effective indexers, optimization settings, and database maintenance schedules is key to achieving Magento performance optimization.


Also, choosing the right Magento auto-scaling hosting, tuning your store cache settings, and enabling flat catalog data help to optimize store performance.

Shivendra T.
Shivendra T.
Technical Writer

Shivendra has over ten years of experience creating compelling content on Magento-related topics. With a focus on the Magento community, he shares valuable tips and up-to-date trends that provide actionable insights.


Get the fastest Magento Hosting! Get Started