The document discusses using Node.js microservices with Magento. Specifically, it discusses:
- Using Node.js to create microservices for Magento like NodeJento for the ORM and services for Laravel, Python, etc.
- Some benefits of using Node.js microservices include non-blocking I/O, single threading, and reusing the same tech stack on front-end and back-end.
- It provides an example of initializing a Node.js/Express app with NodeJento to query Magento database models and return product data.
3. Magento
Meetup
Kharkiv
#11
Resolving Magento issues
● Slow performance for non cached pages and
dynamic content
● Ajax Requests Performance Issue
● App bootstrap issue
● Scaling issues
● GraphQL performance issue
● Blocking I/O, HTTP, MySQL
● Deployment issues
● 6000+ reported GitHub bugs
● High Entry Level
● Slow development time
● Difficult to debug
● Legacy monolithic framework codebase
● Outdated technologies: Zend Framework 1,
KnockoutJS, old fashioned custom build ORM.
4. Magento
Meetup
Kharkiv
#11
Why NodeJS?
● It has Non-blocking I/O API
● It runs on the Single thread
● The same tech stack on the frontend and backend
● Node.js handles multiple requests
● Easy to install
● Fast, Google V8 engine used in Chrome and in Node.js
● The performance of Node.js is faster as compared to
PHP
● It possesses a rich community of developers
● NPM packet manager
● One language for Frontend and Backend and Desktop
● High salary
6. Magento
Meetup
Kharkiv
#11
Magento 2 Microservices
Instead of containing everything in a single monolithic codebase, the microservices-
based application is broken down into smaller, lightweight pieces based on a logical
construct. The application consists of independent small (micro-) services/extensions and
when we deploy or scale the app, individual services get distributed independently from
the monolith.
8. Magento
Meetup
Kharkiv
#11
Magento Strangler Pattern
Adobe: “In our case "Strangler pattern" was introduced on the level of a stand-alone
Node.js-based GraphQL server. Also, it gave us the possibility to develop services
from scratch not affecting monolith anyhow and not being burdened with PHP BiC
guidelines.”
Strangler Pattern is a way of migrating a legacy system incrementally by replacing
existing functionalities with new applications and services in a phased approach. After
the replacement of the entire functionality the new application system eventually replaces
all the old legacy system's features. The name "strangler pattern" was inspired from
strangler fig trees.
The strangler application consists of two types of services. First, there are services that
implement functionality that previously resided in the monolith. Second, there are
services that implement new features. The latter are particularly useful since they
demonstrate to the business the value of using microservices.
10. Magento
Meetup
Kharkiv
#11
Shared-database-per-microservices-and-
monolith pattern
The same database is shared by several microservices and monolith. You need to
carefully assess the application architecture before adopting this pattern, and make sure
that you avoid hot tables (single tables that are shared among multiple microservices). All
your database changes must also be backward-compatible; for example, developers can
drop columns or tables only if objects are not referenced by the current and previous
versions of all microservices.
12. Magento
Meetup
Kharkiv
#11
NodeJS + ExpressJS
npm install express
npm install nodemon
app.js:
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
nodemon app.js or node app.js
nodemon is a tool that helps develop node.js based applications by
automatically restarting the node application when file changes in the
directory are detecte
13. Magento
Meetup
Kharkiv
#11
What is NodeJento?
NodeJS implementation of the Magento 2 ORM on top of Sequelize
If you want to Sequelize to connect to a Magento database that is already
filled with tables and data NodeJento excised database directly without
invocation of the Magento 2 PHP framework, so we won’t have to write any
MySQL queries.
https://github.com/Genaker/nodejento