Magento 2 Advanced Performance

Magento 2 Advanced Performance

Magento advanced performance is one of the main factors to lead work more successful. In case you want to keep shoppers stay longer on the webshop, it should provide an excellent shopping experience. Improve Magento 2 performance and enhance customers experience by using modern methods. Here is a couple of techniques that will speed up your webshop even more.

Varnish caching

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. Varnish caches you web server response, stores it in memory and provides this stored response to any equivalent requests without accessing your application directly. Varnish is designed to provide a very fast response and then provide up to 300x speedup depending on the architecture. Magento 2 supports versions 3.0.5 or later or any Varnish 4.x version.

Magento 2 Advanced Performance_1

Using Varnish with Magento 2

Apache 2 configuration

In order to use Varnish with Magento 2, first off, make sure Varnish is installed on your web server. Installation procedure may vary depending on your OS. Varnish responds directly to incoming HTTP request, so your web server (e.g. Apache 2) should be configured to listen on a port other than default port 80. Edit your Apache 2 configuration file and change the value of the listen port to 8080 as an example.

Varnish system configuration

Open /etc/sysconfig/varnish (or /etc/default/varnish on Debian and Ubuntu) and set the Varnish listen port to 80:

For Varnish 4.*, make sure that DAEMON_OPTS contains the correct listening port for the -a parameter:

Magento 2 configuration

Log in to the Magento Admin as an administrator and go to Stores->Configuration->Advanced->System->Full Page Cache. From the Caching Application list, click Varnish Caching. Enter a value in the TTL for the public content field. Expand Varnish Configuration and fill in the required information.

Magento 2 Advanced Performance_2

Database Sharding (Magento Commerce only)

Magento Commerce comes with the ability to use three separate databases for different functions of Magento application. These areas are Checkout, Orders and product data. This separation allows independent scaling and replication and provides additional flexibility how Magento 2 database can be scaled depending on your needs.

This Split Database functionality requires you to set up three master databases (they can be hosted on the same server or spread to other servers):

  • One master database for checkout tables.
  • One master database for sales tables (also referred to as Order Management System, or OMS, tables).
  • One master database for the remainder of the Magento 2 application tables.

In addition, you can optionally set up any number of slave databases that serve as load balancers and backups.

Magento 2 Advanced Performance_3Magento 2 Advanced Performance_4

Creating Split Database

In order to create additional databases (in this example they will be hosted on the same server), you need to log in to database server and enter the following command to get to a MySQL command prompt:

Enter the MySQL root user’s password when prompted. Enter the following commands in the order shown to create database instances named magento_quote and magento_sales with the same usernames and passwords:

Configuring Magento Commerce to use the checkout and sales databases

After setting up a total of three master databases, apply the Magento command line to configure Magento to use them. These commands set up database connections and distribute tables among the master databases.



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *