I have been working on Magento An Adobe Company
community for a time now. Folks, who are familiar with Magento An Adobe Company
, we know that application speed is the most expected factor that counts in local development time.
Since the release of Magento 2.x.x there have been growing talks about - is Magento 1.x.x faster than Magento 2.x.x and vice-versa.
Simply put, any product, doesn't matter any - you name it, has its own pros and cons.
However, on the positive side, every product's major
release comes with pack of new features that we might previously have been talking about in the community.
In terms of setting up local machine for development, I am a firm believer of using my host machine as much as possible. It's purely to do with my years of skills around many different distribution of Linux OS. Alongside using host, I also use Docker regular basis for spin things up when necessary.
Magento setup - the traditional way
Setting up a default instance of Magento 1.x.x on a local machine generally used to take me 30 minutes
, without using vagrant or docker. On a 16GB MacBook Pro this setup generally works fast without needing any extra performance tuning.
Setting up a default instance of Magento 2.3.4 on a local machine generally takes me 30 minutes
- again, without using vagrant or docker. On a 16GB MacBook Pro this setup generally should work as fast as Magento 1.x.x without needing any extra performance tuning.
But Magento 2.x.x starts to show performance degradation as the code base starts to grow i.e multi-website setup, having multiple modules etc.
I know there are thousands of developer who have been suffering from it!
The solution to speed
So I came up with an architecture level solution to use RAM disk
which works blazingly fast. Using RAM disk
in E-Commerce might be something new but the usage of RAM disk
to run application has been a long practice in financial industry.
What is a RAM disk?
A RAM disk is a portion of memory allocated in the RAM by the OS. Once RAM disk is configured, it acts like a mountable drive as if it is an external physical drive. It can be mounted and unmounted at any time.
Why RAM disk is fast?
Any data put inside a RAM disk is processed without OS needing to write to a physical disk storage. The data communication between CPU kernel and RAM becomes direct. Hence the speed is super fast.
What I should know before I start using it?
Of course it has its downside. The data which are available in a RAM disk is volatile. It means any data will be instantly erased if for any reason the host machine lost its power. More importantly, the host machine needs to have as much RAM as possible.
Regular backup is the key factor
To mitigate data loss, it's an industry-wide practice to backup the data after certain interval - a very frequent interval i.e. every 10 mins.
What should be the size of a RAM disk?
As mentioned, a RAM disk acts like an external storage. A decent size would be 4GB. On MacBook Pro 16GB, it can handle up to two Magento 2.x.x setup at a time with 4 or 5 background application running i.e. PHPStorm, Table Plus and 2/3 browser windows with multiple tabs. To save further system resources on browser tabs, using tab suspending browser extension would be ideal.
What can I save in a RAM disk?
RAM disk can be used to save both the code base and MYSQL database. Both the code base and MYSQL database can be exposed to host machine using symbolic linking or just by using the volume mounting path
.
Do I need a super computer to use a RAM disk?
Generally, the host machine needs to have as much RAM as possible. I used a multi-store Magento 2.3.x and a single store Magento 2.3.x on a MacBook Pro 16GB RAM with regular incremental backup.
The more the RAM space the more the Magento 2.3.x setup you can have without exhausting system resources.
RAM disk architecture diagram
Final thoughts
The discussion on this article could open up a new window as to how we can achieve maximum speed from architectural point of view when it comes to production-level hosting as well. By the way, which doesn't mean, developers should overlook performance factors in their codes and relying heavily on stack resources. A non-performant code will always be non-performant even it gets deployed in a RAM disk.
While server resources can be redesigned, E-Commerce community should explore new and faster web-technology tools i.e. Vue, React.
Enjoy the speed!
Top comments (0)