Getty Images/iStockphoto

Tip

LAMP stack vs. MEAN stack: Which is right for you?

LAMP and MEAN stacks are two options for application hosting. Their differences lie in the way you use and deploy them.

When you deploy web apps, there are two acronyms to know: LAMP and MEAN. Each term refers to a different software stack for application hosting, and each approach offers different advantages and drawbacks.

LAMP and MEAN share several similarities. They both consist entirely of open source components, which are flexible and modular; it's easy to swap in alternatives. They are also both based on secure and mature technologies. But the two stacks aren't the same: LAMP is usually best for complex sites that are large scale and deal with heavy traffic, whereas MEAN is best for building strong full stack applications typically used to create cloud hosted applications.

What is the LAMP stack?

The LAMP stack is an application hosting stack based on Linux, Apache HTTP, MySQL and PHP. Each aspect of the stack serves a purpose when you deploy an app:

  • Linux serves as the operating system for the host server.
  • Apache HTTP is the web server.
  • MySQL provides a database.
  • PHP is the programming language for the app itself.

There are many variants on this approach, and you can swap each of the components for an alternative. For example, you could use NGINX as the web server and keep the other LAMP components in place. Or you could replace MySQL with another SQL-style database.

Although a classic LAMP stack runs on Linux, it's possible to run Apache, MySQL and PHP on Windows. You can easily port the LAMP stack to Windows if you wish. In this case, you'd end up with a WAMP stack.

What is the MEAN stack?

The MEAN stack is an application hosting stack based on MongoDB, Express.js, AngularJS and Node.js:

  • MongoDB serves as the application's database.
  • Angular, a JavaScript framework, is the language used to develop the app.
  • Express and Node host the app and function like Apache does in the LAMP stack.

Like the LAMP stack, there are many variants on the MEAN stack. For example, you can swap in React, another JavaScript framework, in place of Angular, to create the MERN stack.

Unlike the LAMP stack, MEAN doesn't include an operating system. However, MEAN applications can run on any major operating system: Linux, Windows or macOS.

Key differences of LAMP vs. MEAN

There are notable differences between LAMP and MEAN that may make one stack better than the other for your needs.

Development languages

LAMP and MEAN use different application development frameworks. To use the LAMP stack, you must be comfortable developing your application in PHP, whereas MEAN uses Angular.

This difference is about more than just preference. PHP is a server-side language that uses HTML to render an application's front end. Angular exclusively focuses on front-end development using JavaScript. Although it's possible to implement most types of application functionality using either language, you would take a different approach if you chose PHP instead of Angular, or vice versa. And you would face different types of security challenges. For example, front-end apps are more susceptible to cross-site scripting attacks (although server-side apps are not immune to them).

Database types

Each stack uses a different type of database. MySQL is a SQL database. It stores data in a highly structured form. MongoDB is a NoSQL database and offers a more flexible schema.

The LAMP stack is a more natural fit for applications that only need to store traditional types of data -- such as user account information -- that can fit neatly within a standard database table. MEAN might be better for hosting apps that need to store a broader or less predictable set of data types. For example, if your application processes and stores video and audio files, it would typically be easier to fit into MongoDB.

History and popularity

The LAMP stack has been receding in popularity in recent years as Apache, MySQL and PHP gradually lose market share. The MEAN stack is likely to look and feel more modern to most of today's developers.

The MEAN stack is more oriented toward APIs and microservices than the LAMP stack. Although it's possible to use APIs or microservices architectures using LAMP, doing so would require more work in most cases because LAMP was conceived long before API-driven development and microservices became common.

Scalability

Both LAMP and MEAN allow you to add more application instances and allocate more resources to your apps, but MEAN's API-oriented, microservices-friendly approach makes it more scalable than LAMP. For instance, if you deploy a MEAN app using microservices, you can scale each service independently which leads to better overall performance and efficiency. MongoDB also has a native horizontal scaling features that can help to enhance scalability without compromising performance.

You can implement horizontal scaling in LAMP, but it's more complicated. A LAMP app is more likely to operate as a monolith, which requires you to scale the entire app up or down and is a less efficient approach.

Web serving approach

The LAMP stack uses a traditional web server, Apache, to enable web apps to interact with users via the HTTP protocol. MEAN uses Express in conjunction with Node. These components aren't a web server; they provide a web application framework that can handle HTTP requests.

In this regard, the differences between LAMP and MEAN amount to almost nothing from the end-user perspective. For developers, there are small differences between using Apache versus Express and Node. For example, Apache can do more out of the box, whereas Express and Node rely more heavily on add-ons to implement functionality beyond handling basic HTTP requests.

How to decide between LAMP and MEAN

Either stack offers a stable, mature and secure approach to deploying apps.

LAMP tends to be the better choice in the following scenarios:

  • Your app will include many pages or a wide array of content.
  • Your app will be deployed as a monolith.
  • You want extensive control over the server-side environment.
  • The types of data your app needs to store can fit easily in a SQL database.
  • You are comfortable with PHP.

Consider MEAN for these scenarios:

  • You plan to build a microservices app.
  • Your app will include relatively few pages. Single-page apps, or SPAs, are ideal candidates for the MEAN stack.
  • You need flexible and scalable data storage.
  • You want to maximize the scalability and efficiency of your app.
  • You prefer front-end development over server-side programming.

People sometimes say that LAMP is better for small or medium-sized applications, or that MEAN is better for apps that need to process data in real time. However, these statements aren't necessarily accurate. Some of the world's largest websites, such as Wikipedia, use LAMP.

A well-designed and implemented LAMP app can be just as responsive as a MEAN stack. The LAMP stack can handle real-time data processing just as well as the MEAN alternative.

Chris Tozzi is a freelance writer, research adviser, and professor of IT and society who has previously worked as a journalist and Linux systems administrator.

Dig Deeper on IT systems management and monitoring