All posts by

Public interfaces

A public interface is a set of code that third-party developers can call, implement, or build as a plug-in. Magento guarantees that this code will not change in subsequent releases without a major version change.

Public interfaces for a module are marked with @api annotation.

Service contracts

Magento is a modular system that enables third-party developers to customize and overwrite core parts of its framework. This flexibility, however, comes at a price. Business logic tends to leak across the layers of the Magento system, which manifests as duplicated and inconsistent code.

Merchants might be reluctant to upgrade Magento because customized extensions that they have purchased might not be compatible with new versions of Magento. Also, Magento and third-party developers can find it difficult to track and report the dependencies that customized extensions have on other extensions.

To address these issues, the Magento system introduces service contracts.

A service contract is a set of PHP interfaces that are defined for a module. A service contract includes data interfaces, which preserve data integrity, and service interfaces, which hide business logic details from service requestors such as controllers, web services, and other modules.

If developers define data and service interfaces according to a set of design patterns, the result is a well-defined, durable API that other modules and third-party extensions can implement through Magento models and resource models.

Magento 2.3: Error Assigning Related Products

check the following tables in your DB:

catalog_product_link_attribute and catalog_product_link_type

If those are empty, you need to run the following SQL queries:

INSERT INTO catalog_product_link_attribute (product_link_attribute_id, link_type_id, product_link_attribute_code, data_type) VALUES
(1, 1, ‘position’, ‘int’),
(2, 4, ‘position’, ‘int’),
(3, 5, ‘position’, ‘int’),
(4, 3, ‘position’, ‘int’),
(5, 3, ‘qty’, ‘decimal’);

INSERT INTO catalog_product_link_type (link_type_id, code) VALUES
(1, ‘relation’),
(3, ‘super’),
(4, ‘up_sell’),
(5, ‘cross_sell’);


A cluster is the group of computing machines that can individually run the software. Clusters are typically utilized to achieve high availability for server software.

Clustering is used in many types of servers for high availability.

App Server Cluster – An app server cluster is the group of machines that can run an application server that can be reliably utilized with a minimum of downtime.

Database Server Cluster – A database server cluster is the group of machines that can run a database server that can be reliably utilized with a minimum of downtime.


Scalability is the ability of a system, network, or process to handle a growing amount of load by adding more resources. The adding of resource can be done in two ways

Scaling Up – This involves adding more resources to the existing nodes. For example, adding more RAM, Storage or processing power.

Scaling Out – This involves adding more nodes to support more users.

Any of the approaches can be used for scaling up/out an application, however,r the cost of adding resources (per user) may change as the volume increases. If we add resources to the system It should increase the ability of the application to take more load in a proportional manner of added resources.

An ideal application should be able to serve high level of load in fewer resources. However, in a practical, linearly scalable system may be the best option achievable.

Poorly designed applications may have a really high cost on scaling up/out since it will require more resources/user as the load increases.

High Availability

Having better service capacity with high availability and low latency is mission critical for almost all businesses.

Availability means the ability of the application used to access the system, If a user cannot access the application, it is assumed unavailable. High Availability means the application will be available, without interruption.

Achieving high availability for an application is not always an easy task. Using redundant server nodes with clustering is a common way to achieve a higher level of availability in web applications.

Availability is commonly expressed as a percentage of uptime in a given year.


Sharding is an architectural approach that distributes a single logical database system into a cluster of machines.

Sharding is Horizontal partitioning design scheme. In this database design rows of a database table are stored separately, instead of splitting into columns (like in normalization and vertical partitioning). Each partition is called a shard, which can be independently located on a separate database server or physical location.

Sharding makes a database system highly scalable. The total number of rows in each table in each database is reduced since the tables are divided and distributed into multiple servers. This reduces the index size, which generally means improved search performance.

The most common approach for creating shards is by the use of consistent hashing of a unique id in the application (e.g. user id).

The downsides of sharding are,

  • It requires the application to be aware of the data location.
  • Any addition or deletion of nodes from the system will require some rebalance to be done in the system.
  • If you require a lot of cross-node join queries then your performance will be really bad. Therefore, knowing how the data will be used for querying becomes really important.
  • A wrong sharding logic may result in worse performance. Therefore make sure you shard based on the application need.

Session Replication

Session replication is used in application server clusters to achieve session failover.
A user session is replicated to other machines of a cluster, every time the session data changes.
If a machine fails, the load balancer can simply send incoming requests to another server in the cluster.
The user can be sent to any server in the cluster since all machines in a cluster have a copy of the session.

Session replication may allow your application to have session failover but it may require you to have extra cost in terms of memory and network bandwidth.