Upgrade : Get Unstuck from the LAMP Stack to the MEAN Stack

Posted On // 13 comments

Upgrade : Get Unstuck from the LAMP Stack to the MEAN Stack

Understanding the role each technology plays in the stack is crucial when moving from LAMP to MEAN for web development. Whether you’re looking for consolidation of technologies or to leverage in-house JavaScript expertise, the MEAN stack can offer a lot to a flexible web development organization. The team here at BACK& wanted to try and help sort out the pros and cons of each stack. So below I’ll detail the MEAN stack, how it compares to the LAMP stack, and offer a few tips for optimizing your choices.

The Operating System

The first choice in any tech stack is the operating system. While the LAMP stack locked the operating system to a variant of Linux, the MEAN stack has no such restrictions. Linux is still a good choice for an app built on MEAN, but it is by no means the only option; any operating system that can run Node.js is a viable alternative.

The Web Server

In the MEAN stack, the web server – provided by Apache in LAMP – is provided by Node.js. This can improve the performance of the application, as Node.js is entirely non-blocking and event-based, allowing for true concurrency among requests. Node.js is lightweight and relatively new, however, which ultimately means that your organization will be largely on its own when it comes to non-standard extensions. While there is active plug-in development for Node.js, the technology is not as matured as Apache. This usually means that you need to write your own plug-ins to cover the areas where Node.js is missing functionality. Additionally, choosing Node.js locks all code on your web server into JavaScript. For new development this isn’t a major concern, but converting a back-end of significant complexity can be time-consuming.

The Data Store

The MEAN stack replaces LAMP’s use of MySQL (or another relational database) with MongoDB (or an equivalent non-relational database). For many web apps, this will be the most significant change. Translating the data in an existing SQL database requires a lot of forethought to eliminate redundant/unnecessary object attributes, and will likely require a custom software suite to accomplish. However, once this is done the database will be much faster for data retrieval.

The Code

MEAN makes use of Express.js and AngularJS to drive web page presentation and control flow, tasks covered by PHP or Python in the LAMP stack. Express.js serves as the controller layer, directing application flow and marshaling data for AngularJS, which handles data presentation. The primary benefits offered by these scripts are a simplified back-end architecture – for example, Express.js weighs in at only 1,143 lines of code – and a purely client-side presentation layer in AngularJS that can be easily embedded into any existing web application. Furthermore, usage of Express.js and AngularJSo n top of Node.js gives your technology stack the added benefit of being entirely in one language, meaning your front-end developers now have the ability to trace all the way down the stack without having to learn another programming language.

Additional Considerations

Probably the biggest choice to be faced when converting from LAMP to MEAN is the choice of data store. While the MEAN stack is designed to work with a non-relational database, there are plug-ins for Node.js that allow the stack to run off of a relational database just as easily. The front end handles everything in JSON, so the only true consideration is how the data is stored before it is retrieved, or the difference between Relational and Non-Relational databases.
Relational databases, with their support for highly complex structured queries, lend themselves well to performing complex calculations with data. Non-relational databases excel at managing operational data, such as a list of objects in a system. The lack of a schema allows for fluid object definitions that don’t require extensive code changes, and by removing the need for extensive and complicated queries the system can often operate more efficiently than a similar architecture build over a relational database.


Converting to the MEAN stack gives your development team a number of benefits, the three most significant being a single language from top to bottom, flexibility in deployment platform, and enhanced speed in data retrieval. However, the switch is not without trade-offs; any existing code will either need to be rewritten in JavaScript or integrated into the new stack in a non-obvious manner. Ultimately the choice to switch to a MEAN stack from LAMP will be based in your organization and the priorities for the project under development.
Courtesy of Blog.BackAnd