MEAN vs LAMP stacks defined and compared

The long popular web development stack LAMP is slowly being chipped away from its dominant position by newer, trending technologies, letter by letter. MEAN is one total replacement which has been gaining ground lately.

What do those acronyms mean?

  • MEAN: MongoDB, ExpressJS, AngularJS, Node.js
  • LAMP: Linux, Apache, MySQL, PHP

MongoDB is a NoSQL database which won't support your existing applications because they would require some sort of relational database with SQL querying capability, probably including a whole lot of very custom queries. MongoDB is nothing close to a straight up drop in replacement for MySQL. It's possible to include a NoSQL database in addition to MySQL/Postgres in a LAMP web app. Node.js has some support for MySQL if you want that in your MEAN stack. There are other NoSQL databases to consider. Developers are learning MongoDB and coming up with new use cases for it and it excels at letting developers store data when they don't know what they want to store yet and don't need to be able to retrieve it together with other stored, structured data. It's better when you just want to store a lot of data together and retrieve it together.

ExpressJS is the leading web development framework for NodeJS. PHP has too many web frameworks to count, with Laravel currently trending hot, although it doesn't receive a letter in the LAMP stack (the L is for Linux). Node.js suffers from a dearth of choices in frameworks and Express.js offers a minimal framework on top of just Node.js. There are less minimal alternatives like Sails.js. There are no large, featureful, mature CMS or content management frameworks like WordPress or Drupal for Node.js yet. We may end up in a one-horse race when it comes to Node.js web frameworks just like Ruby on Rails.

AngularJS is a popular frontend JavaScript framework which is currently stuck between two major and incompatible releases, leaving many developers waiting on the sidelines instead of starting new projects with the old version of Angular while Angular 2 hasn't stabilized yet enough to use. It's also only one of many JavaScript frameworks with alternatives like ReactJS. But MERN doesn't sound as nice as MEAN. AngularJS doesn't care if your backend uses Mongo or SQL or is running Node or Django or Laravel or whatever. Nor does any other frontend framework - they are all getting thicker as the backends become thin, RESTful APIs.

Node.js is the JavaScript engine running on the server powering Express as well as replacing Apache as a web server for executing web / http requests which need to run some server-side JS code. This, combined with Angular or any frontend JavaScript framework, means you have a single language but two codebases for the browser and server and you can, in theory, move your "isomorphic" code from the server to the client codebase and vice versa, say, for validation. Your Node.js code must include / embed a full web server within the app to handle the requests which will then run your server-side Node code. In reality, a MEAN stack will probably also have a real web server, most likely Nginx but also possibly Apache, in front to handle access to static files, redirection / rewrites, compression, SSL, caching, etc. The MEAN acronym doesn't account for this missing letter. But being MEAN means just not caring.

So that's MEAN. Now what about LAMP and is LAMP still relevant or is it being replaced by MEAN? Quick answer: No.

Linux is the main deployment operating system for both LAMP and MEAN web apps. But many developers ran Windows or Mac locally and tested on local webservers, thus they had WAMP or MAMP stacks, and these differences could lead to bugs after deployment. Using Node.js leads to less of these issues, as does running a local development server in a virtual machine running Linux. And Linux is still the likely underlying OS for MEAN sites, not Windows or OS X Server. MEAN should thus be LMEAN or LMERN or LMEANN or something to be fair. Although it's common for MEAN developers to develop on Mac OSX it isn't included in the stack as it generally doesn't matter when deploying a Node app, not more than having the same version of Node and its dependencies.

Apache is still dominating the global web server market, although nginx is growing in popularity, with Microsoft's IIS in between. LEMP is sometimes used to distinguish people who replace Apache with nginx (E is for [E]nginx - no, there's no actual E in the software's name so it's only for convenience) in their LAMP stacks. Some people switch from Apache to nginx due to lower memory footprint handling high numbers of concurrent connections. Node.js is also able to handle many connections simultaneously without blocking long on any individual one. But Apache as a webserver has a lot of mature modules extending its features and a community of users who know how to configure it for any given website configuration, especially PHP sites.

MySQL is still the dominant open source (relational) database software, which something like half (according to Gartner research) of all sites use, along with the software from the company which now owns MySQL, Oracle. But it's a SQL database in a NoSQL trending environment. MySQL has a reputation for crashing and losing data and being difficult to scale across multiple servers. To be fair, MongoDB also has a reputation for not being fault tolerant. But despite MySQL's known problems, it's still the database more people know, and more people can query MySQL than "MongoDB query languag" or any of the NoSQL solutions. It does take some vigilance to protect against "little Bobby Tables" SQL injection attacks, shouldn't be a problem using any modern PHP framework with a database abstraction layer of any kind. MySQL requires schema updates when your idea of what you want to store changes, whereas MongoDB won't. You need to understand whether your data needs to be relational or not in which case MongoDB will fail to replace MySQL. Most of the existing web software out there in the world needs a relational db. MongoDB is trendy but it is definitely not for all use cases. MySQL is probably okay for most use cases, outside of which a specialized data storage method should be considered.

PHP gets a lot of hate, some of it warranted. This hasn't prevented the language from powering much of the World Wide Web (see WordPress, Joomla, and Drupal). Addressing the haters, the language itself has improved and added sorely missing features over the years and with some help from Facebook (which is also built on PHP) the language has gotten a lot faster as well. But PHP is the most important letter in the LAMP stack just as Node.js is the critical piece and server language in the MEAN stack.