Back to blog home page

MEAN vs LAMP – How Do They Stack Up?

Posted by on Aug 26, 2014

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.

Conclusion

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.


Get a free hosted AngularJS backend with features such as user management, social signin, payment integration, security and more – GET STARTED NOW.

  • Pingback: Mean vs Lamp – How Do They Stack Up? | #T...()

  • g00glen00b

    I wonder if it’s fair to compare these two. The MEAN stack does not mention the operating system it can run on, you tell that it has no restriction, but on the other hand, the software (Apache, MySQL, PHP, Perl and Python) on the LAMP stack can be installed on a Windows server as well, true, it will be no longe called a LAMP server but a WAMP server, but I wouldn’t call it a “restriction” either.

    Also, the LAMP stack does not mention any front-end language, so it could use AngularJS as well.

    The main advantage, and which I agree on, is that the MEAN stack allows you to program in one language, JavaScript.

    • Fully agree.

      • Thanks for the comments @g00glen00b:disqus and @madhur_ahuja:disqus. The purpose of the blog was to spark discussion
        and not really focus on whether one stack was better than the other. For
        example, internally we use both. The thought was to create discussion
        around the stacks and offer both as options to those people working with
        AngularJS. In fact we plan to expand on this discussion in a future blog
        and talk about smaller stacks like mean.io (http://mean.io/#!/).

        • I’m not discussing about which stack is better either. I’m just saying that comparison is not really the best approach imo. I mean, the LAMP stack is a more low level stack (talking about OS and webserver) while the MEAN stack is more about front-end development.

          For example, you say that the LAMP stack can only run on Linux, while that is true, the software that you run on that stack is not bound to a specific OS. In fact, there are respectively Wamp and Mamp. So… why compare them?

          Same thing about Apache… Apache is a webserver indeed, but the MEAN stack does NOT replace Apache. It’s still a common technique to use a webserver in front of a Node.js server (which is in fact your application server, NOT a webserver).
          If anything, then Node.js in the MEAN stack is more comparable to PHP (both being runtime environments), than to compare Node.js to Apache.

          And also AngularJS… because the LAMP stack is so low level, is does not even mention AngularJS. It’s wrong to say that AngularJS is comparable to PHP or Python… even comparing Express.js to PHP or Python is invalid (because one is a language while the other one is a framework on top of a language).
          You could compare Express.js to MVC-like frameworks in PHP (for example Zend), though, the LAMP stack does not mention which framework to use (again, because it’s low level).

          But about AngularJS, again, the LAMP stack does not mention any front-end language and that means you can easily use any JavaScript framework, including AngularJS.

    • Santi

      Fully agree, too. I don’t think they can be directly compared, and I think it’s very unfair to even think one is better or superior.

      In fact, I think you can have a “LAMP” environment and still use most of the “MEAN” technologies there, I think they have little to do with each other, other than the fact that they are an acronym for a set of stack technologies.

  • gggeek

    Besides support for windows server, you did not mention Nginx, which is probably used as much as Apache, if not more, for modern LAMP installations.
    And of course you can use MongoDB and all other NoSQL technologies from php – so the situation is not as clear-cut as depicted here. I’d actually say that the “lamp” stack gives you more flexibility in deployment, not the opposite.

    But I agree that both the OS and the webserver are largely irrelevant to the application developer – the choice of programming language and data store have a much bigger impact.

    In my limited experience with it, Node makes a good framework for developing “services”, but it is quite lacking to develop websites.
    Any API call which is not async will in fact block the whole webserver when executed, making it in fact less scalable that Apache, unless the developer knows what he is doing.
    Simple things as serving static files with authentication need extra libraries and/or code.
    In the end it is often more productive to use both a classic webserver and node.js paired, using each for what it is best at.

  • Pingback: OpenQuality.ru | Качество программного обеспечения()

  • George

    It seems to me, as I just picked up the mean stack, that other than the “same language” argument… there really is no need to move to that… unless you want to be daring. After all, angular 2.0 is coming out soon and it’s a whole new language. I never had that issue with any of the LAMP / WAMP, jQuery, CSS stack pieces, and, true, as g00glen00b mentioned that a lamp stack could easily use a different database, and I can use any other front end framework, like ember, etc, without any complications… So, it seems that a lamp stack, being independent of the front end frameworks, makes it several times more useful when building prototypes or scalable apps. Just a thought.

    • Partly true, though I should mention that half of the MEAN stack (MongoDB + Express.js + Node.js) is about serving REST services, you could easily replace AngularJS by any other front-end framework(s).
      So, the part that it is more or less useful, I don’t think that it’s necessarily the truth. You can easily use MongoDB + Express.js + Node.js with any other front-end framework without having to change a letter of code at your back-end. The stack would be named differently (for example Nodember), but half of your codebase will still be the same.

      The main difference is that the MEAN stack is a framework-oriented stack, while LAMP does not mention any frameworks, not in the back-end, nor in the front-end. It doesn’t mean it’s better or worse for building prototypes, it’s just…. different.

      • George

        Great response. Being a non-framework type developer, I now understand why LAMP makes more sense for myself. Thanks!

        • Using LAMP doesn’t mean you should or should not use frameworks or libraries though. The MVC pattern is usually quite easy to use in many languages (for example by using Zend or CodeIgniter (those are the two I know) and/or front-end MVC frameworks like Ember.js or AngularJS or libraries like jQuery.

          • Peter Pottinger

            If you like Codeigniter you should try Laravel 5.3

  • Interesting. My choice for a web services stack is Linux, Node.js, PostgreSQL, and for client apps Qt5/QML.

  • Pingback: Apps Built on LAMP or MEAN Are Good For Your Business | alchemytechsolutions()

  • Pingback: 4 Takeaways from YI Incubator Tech Days that Developers Need to Know - Yodlee Interactive Blog()

  • Pingback: Angular.js and Full-Stack Framework for Single Page Application | Tools | Tuning Synesthesia (tSynsth)()

  • Pingback: What is the easiest way to connect a Android app with MongoDB? [closed] - DexPage()

  • Mean is simple to use and VERY flexible. This allows for easier adoption for experienced developers. MEAN Stack is surely an innovative, new and cutting-edge technology package that will perhaps conquer the market shortly.

    • yes but the learning curve…..i moved our team over to Laravel 5 + AngularJS using MongoDB. We use Node.JS for various RFID tracking datasets and even have it managing LED lights in a warehouse management system with a tiny bit of this and that mixed in for good measure.

  • Pingback: 4 Takeaways from Ynext Incubator Tech Days that Developers Need to Know - Production()

  • Pingback: MEAN vs. LAMP Stack: Pros and Cons - Hongkiat()

  • Pingback: MEAN vs. LAMP Stack: Pros and Cons | MotionBump Reader()

  • Pingback: MEAN vs. LAMP Stack: Pros and Cons | PSD TO WORDPRESS()

  • Pingback: MEAN vs. LAMP Stack: Pros and Cons – Open Code Group()

  • momentai

    For a site about being experts in responsive web development. You have a really annoying share bar that blocks the start of every sentence of every article when viewing your site on an iOS and Android device. Users literally have to read between the share bar and the huge comment button. May I suggest a margin or some padding?

  • George

    Can we stop saying that the MEAN stack is all the same language? Its syntax is very different. Additionally, if we did have the same language (functions, architecture and all) wouldn’t you find it confusing? What am I doing now? Getting data from the database, or testing some logic? How would you know what you’re doing? Sounds like a debugging nightmare. It happened to me. That’s why I went back to MySQL. And no, Linux is not your only choice for an *AMP type system. There’s WAMP, XXAMP, MAMP, LAMP, and more, which gives us great flexibility of operating systems. However, to follow Apple’s design, isn’t it better that the original is on Linux only? A closed system always performs better, even if your technology is outdated.