Magento Microservices and Node.js

Yegor Shytikov
5 min readMay 23, 2020

In Magento 2 every new feature gets added to the existing application using extensions making it more and more complex and slower. Scaling becomes hard and resource-wasting since everything has to be scaled together. Deployment turns into a nightmare thanks to the 5 million PHP lines of code waiting to be pushed into production every time, di compile, setup, upgrade, static content deploy, cache clean…

Magento Core, Extensions, Theme version update is another sad story…

There is a Magenro-less microservice framework it works with Magento 2 data directly without relying on legacy M2 slow core code:

The impact of microservices on eCommerce — Sander Mangel

Being in eCommerce for over 12 years, Sander has gained amazing experience as a developer, tech lead and now as an evangelist of modern technologies. Along with our host, Marcos Bravo C., they explain the concepts of microservices, headless and service-oriented architecture (SOA), and how they’re changing the environment of eCommerce. They also take a look at the leading eCommerce platforms, like Magento, Shopware or Hybris, their adoption of the headless approach and other modern technologies, and why some of them were bought recently by software giants.

After a certain complexity, it becomes difficult to handle even the smallest changes in the Magento enterprise environment.

To solve this problem you can use an eCommerce microservices architecture

In a microservice-oriented architecture, Magento features can be built up from multiple smaller pieces (cart, order, product, category, search, review) that work together but can be developed separately. By defining technology-agnostic communication channels, any language can be used PHP, NodeJS, Python, Rust, GO. This means that developers are not restricted to legacy technologies anymore, and they can freely just develop

If done properly, a microservice should be small enough to be rewritable in about two weeks by a single person.

But what makes Node.js the best option out there to build Magento's tinny services?

Magento Node.JS

Node.js and Magento.

Node.js became the go-to technology in the past years for both startups and enterprises that decided to embrace microservices.

Well, some argue that Node.js increased the productivity of their teams, and some will say their application became blazing fast or that their developers are happier with Node.

In fact, all of these claims are true, here’s why:

Productivity: The package manager for Node.js, npm has an incredible amount of modules that can be used instantly, which saves a lot of development effort. Also, as Node.js applications are written using JavaScript, front-end developers can easily understand what is going on and make changes if necessary. Since developers can use the same language on the entire stack and the very same modules in the frontend and in the backend, an incredible amount of time can be saved.

Performance: Node.js is one of the best solutions for creating high-performance, real-time web applications, thanks to its non-blocking, event-driven I/O model (parallel MySql/Redis queries execution). Combined with a microservice-based application, it can handle an extreme amount of Magento load with low response times (TTFB). By properly utilizing microservices and Node.js, it’s possible to handle the same load with only 5% of the hardware.

Magento Developers Happiness: Node.js is spreading like an unstoppable virus with its 3.5 million users and 100% annual growth rate according to the Node Foundation. Its module system — npm — is much more popular and grows significantly faster than the package managers for other languages often used in an enterprise environment.

Highly innovative Magento enterprise clients like Lego, Nike, Walmart already know that Node.js and Microservices are a great combination for achieving high performance, increased productivity, reduced costs, and satisfied developers.

The love affair with Amazon’s serverless offering since then has blossomed. Not only did we save a ton of money for the merchants by reducing wastage and DevOps a Magento Cloud Hosting cost but we were able to really embrace the Node.JS microservices architecture completely and Magento servers could now focus on their real job — render catalog pages rendering.

Magento + Lambda

If you are interested in Magento Serverless microservices fill free to email me: yegorshytikov@gmail.com

Using a Magento microservices architecture leveraging AWS’s Lambda we achieved :
1. Keep infrastructure costs down for our clients — We were able to keep infrastructure costs for our clients as low as possible. We work with a lot of early-stage eCommerce startups and every dollar is precious. The pay per use model with zero upfront costs helps startups save costs and deploy those resources in building features and responding to customer needs rather than worry about paying their monthly infra bills.

2.save time (and money) on DevOps tasks like rolling out EC2 instances, setting up auto-scaling, monitoring, looking at budget overruns, and let our DevOps team focus on adding value by Continuous Integration.

3. High-Level Code Reuse — Lambda functions take code reuse to a new level — now if we needed to say implement a feature to resize an image or create a pdf from an Invoice, Punchout or any other type of Magento — 3d party system integration we just called an API that we had created for an earlier project. Add to that, the microservices architecture makes this technology agnostic, so I could have a team working on a Magento PHP project called a Lambda function that was created on NodeJS or Go language without worrying about deploying to another server, etc..

Magento 2.3.4 GraphQL vs RestAPI vs Serverless Lambda Microservice performance

--

--

Yegor Shytikov

True Stories about Magento 2. Melting down metal server infrastructure into cloud solutions.