Critically examining the underlying architecture for a web application is an important step in defining the end product. That explains why one of the first questions that developers ask each other is: “What stack are you using?”
The LAMP stack (Linux/Apache/MySQL/PHP), the WISA stack (WindowsIISSQL ServerASP.NET), and the Java web application stack (Linux or Solaris/Tomcat/MySQL/JSP) seem to be the most popular, but there are countless others and important distinctions and trade-offs among the available solutions. For instance, free isn’t always cheaper, and feature-rich doesn’t always mean more functionality. The aim of this article to compare and contrast the different stacks available and help answer the question developers should be asking: “What stack is best for me?”
This article defines some practical stack criteria and explores which trade-offs are important for different developers. Particularly, it examines the solutions from the points-of-view of the following developer types:
- Start-up and hobbyist developers: Ideas and concepts fuel these developers’ effort. They want the architecture to be simple so they can focus on the idea, test changes quickly, and get something running.
- Small and mid-sized business (SMB) developers: These developers tend to use frameworks and more traditional design patterns, and they generally are creating something more maintainable and upgradeable than the start-up/hobbyist developer.
- Enterprise-level developers: Security, integrity, and privacy tend to be the most important criteria for these developers. As such, they rely more heavily on standards and staying on par with the IT industry.
This article covers the LAMP, WISA, and Java web stacks including JBoss and GlassFish. It will go over the basics of how they work, what they can do, and how each addresses different needs for different deployments. It will provide a recommendation for the data tier as well.
The LAMP StackOf all the stacks, LAMP is the one that seems to be getting the most attention lately. Digg, Facebook, and other Internet giants are partly responsible for drawing attention to it. But make no mistake; this stack has been around for a long time. The key draw seems to be that it is free (as in it doesn’t cost anything AND it is open source), but to say it is zero-cost would be inaccurate. It doesn’t cost anything to download, but installation might not be so cheap. There may not be a direct cost associated with licensing, installation, setup, or deployment, but the process isn’t as quick and easy as one might hope.
LAMP isn’t a well-defined concept. Nearly every LAMP shop uses some flavor or variant of the basic LAMP stack. For beginners, setting up a custom stack may take a few days of scouring the Internet. True, packages like XAMPP may make it simple to get a service stack up on top of the OS, but going from nothing to OS, server, scripts, and database may not be possible in one go. It may also be difficult to find a “Professional LAMP Setup Guru” if the beginner runs into trouble.
When up and running, the products generally work pretty well together, and in a straightforward way. In terms of performance, Linux makes for a fast response system but the PHP layer presents some limitations. PHP is an interpreted language, so the server must interpret each PHP script in its entirety, every time that script runs. While this has the benefits of not needing compilation and gaining some language perks, the downside is performance. According to another article, Digg.com had to scale up to 100 servers just serve up 30GB of data and maintain high performance. However, there are ways around this using Alternative PHP Cache (APC) or other accelerators.
PHP also doesn’t give very much access to the page lifecycle. Really, it is intended only for request and response handling, provided that the server is invoking it at the right times. This makes it beautiful for simple (technically speaking) sites like Digg, but not powerful enough for more intensive applications being hosted on the web. Among the useful features it lacks from an enterprise application point of view are things like persistence management (à la JPA/JTA or Entity Framework style) or a reasonably powerful session manger.
So what this all means is that, for more than just reasons of being free, this stack is best suited for hobby/student development and SMB development. Mostly because ideas for sites like Digg or Facebook don’t actually need any enterprise features or anything more than request/response handling. There isn’t any intensive data processing going on. Things like failover, backup, and security need to be added on by other products and are not standard or straightforward. However, because the LAMP architecture is scalable, adding load balancing, server farming, and other such features may provide enterprise functionality.
Those Windows users just starting with web development and worried about the jump to Linux should note that a similar stack (WIMP: WindowsIISMySQLPHP) is not uncommon on the Windows platform.
The WISA StackMicrosoft did a fine job with the .NET Framework, especially version 3.5 and higher. It doesn’t offer a choice of flavors or options, but there are an abundance of certified professionals who can set up and administer it for any shop’s particular needs. For convenience and uniformity, becoming a “Microsoft Shop” has some appeal; The products come preconfigured for use with each other, so you don’t need to do much more than run an install. However, it is expensive.
Windows Server 2008 comes with features that IT administrators beg for, but that ultimately aren’t as useful to web applications. Internet Information Services (IIS) 7.0 is an important component, but only because it enables powerful capabilities for SQL Server and ASP.NET. When standalone and not very tightly integrated with those technologies, IIS is bulky as a server. SQL Server, along with most of the components in the stack, is a hardware hog. The benefits of WISA really seem targeted at enterprises looking for features such as clustering, failover, security, automated administration, and business intelligence.
What is most useful to web developers is ASP.NET—especially thanks to the Entity Framework released in late 2008 and its integration with IIS. There isn’t much a developer can’t do with the technology. The Entity Framework brings ASP.NET up to the level of Java EE, with automated generation of classes for interaction with the database. With IIS 7, each application can actually make server-specific changes to the way things like authentication are handled. With IIS 7’s integrated pipelining, the application also gets access to everything from when the server first receives a request to how the server checks authentication and so on.
Obviously, because .NET is intermediately compiled, source code is not visible to anyone. It is just-in-time (JIT) compiled instead of interpreted on the fly. This enables two things: code hiding and increased performance. So it is actually possible to create a saleable web application without selling the code. The performance benefit results from the .NET JIT architecture needing to compile only once.
The obvious hitch in the design is the lack of portability. Other than the Mono open source development platform, there are NO alternatives to deploying a WISA web application. You are allowed to choose another DBMS though!
Ultimately, WISA is overkill for anything other than an enterprise application or a SMB application that needs any of the WISA advanced features. The price for the software and for the professional services to maintain it doesn’t really justify it for anything less. Of course, students or hobbyists hoping to get enterprise jobs probably should get themselves acquainted with this stack.
The Java Web StackRed Hat, Sun, and every other enterprise Java vendor in the world implement their own Java web stacks. Sun, for instance, advocates using Solaris/GlassFish/MySQL/JSP (JavaServer Pages), while Red Hat pushes a more mature Java web stack: Red Hat/Tomcat/MySQL or PostgreSQL/JSP. But Java is Java, no matter who implements it. While functionally that’s true, performance and ease of development differ drastically.
Red Hat StackRed Hat is Linux, which, again, is great for server software. Tomcat is now in its sixth version and well architected. It’s a pure Java server, which may have performance implications if used as a purely HTTP 1.1 server. A nice feature of Tomcat is that it is fully configurable using just XML configuration files, much like IIS in the WISA stack. Unlike the IIS/.NET architecture, Tomcat’s HTTP connector (Coyote) is separate from its server-side processor (Catalina). This means, as the Java Servlet API specifies, slightly less access to the I/O stream. Because servlets are compiled into JARs, they offer information hiding and a performance benefit that purely scripted technologies don’t.
MySQL works very well in a web application, but when using Java persistence or transaction management (JPA/JTA), it doesn’t really matter what database you use because performance is bottlenecked at the application. As a post from TheServerSide.com point out, performance is better achieved writing custom stored procedures.Still, MySQL scales nicely (with help) for certain (i.e., read-only) web applications, but lacks true DBMS functionality (constraints, triggers, etc).
JBoss StackJBoss Web Server combines an EAR (enterprise application resource) server and a web server into one product. It uses the Tomcat server. While there is no specified database, HSQLDB and MySQL seem to be the most common. Typically, JBoss applications use the Hibernate persistence manager. It is a pure Java product, meaning that applications developed for it are write once, deploy anywhere.
Because JBoss is essentially just a Java application, performance is completely dependent on proper setup. While the setup can be hard to get right and hard to get high-performance from, it does come with load balancing already intact.
Developing for this stack also is fairly easy, thanks to Eclipse and NetBeans. Developers need only point to their downloaded copy of JBoss and they can start coding right away. Furthermore, the J2EE standard provides a lot of enterprise-level components such as transactions and pooling, much like its .NET counterpart.
Sun StackSun offers GlassFish as an alternative to other stacks such as JBoss. Really, JBoss and GlassFish are designed to be highly deployable web application containers; you deploy GlassFish—which is highly portable from target to target—with the web application itself. With GlassFish (although the current 2.x version is reportedly buggy), using a modified Tomcat server and including something called Grizzly is supposed to enable scalability. That would give Sun a line of components to implement their own complete stack.
To summarize, the Java web stack (depending on how it’s defined) is good for any level of development. Its versatility is probably why so many stack variations exist. The Red Hat stack is probably more for SMB or enterprise developments. Red Hat has a reputation for being very good with support. Hobbyists and SMBs can easily set up their own Java web stack for free on top of their current OS, but setting up the OS is entirely up to them.
SQL Anywhere for the Data Tier
Sybase has a product called SQL Anywhere with a unique Web Edition, which is free with no limitations on scalability (unlike SQL Server’s and Oracle’s free versions). It’s a DBMS that actually runs its engine as an application instance (meaning you can have as many engines running as you want). It’s highly scalable, from mobile and embedded devices all the way to enterprise applications (so Sybase claims).
For the web developer, there are benefits to using SQL Anywhere as an alternative to the seemingly ubiquitous MySQL. Namely, it is supported on a multitude of platforms (even more so than MySQL), and it actually implements a lot of useful features. For instance, it should put an end to the days of relying on the application to ensure data integrity. Certainly, business logic should remain in the business tier and ORM should be the way to go for data integrity, but checking to make sure that data is consistent (i.e., that all data stored in a database table’s column are of specific values) is better handled by the database itself. The use of check constraints and triggers allows the database to handle everything.
SQL Anywhere also includes cool new features like synchronization support, which enables you to take parts of web application data offline for occasionally connected clients. Features of particular interest to web developers are comprehensive GUI administration tools, dynamic cache sizing, and full-text indexing.
Which Stack Is the Right One?
Ideally, the choice of stack should depend on the application, not the other way around. However, some stacks have more typical audiences then others:
Start-up and Hobbyist Developers
LAMP is really great for web sites or web applications of the mass-consumer type. Typically, ease of coding is the key to getting an innovative web site idea up and running. Scaling really becomes a problem only when the application grows to enterprise-caliber. There is no need to pay for other stacks, because the extra functionality won’t be used. Without the extra bells and whistles in this stack, it might be easier for a hobbyist or student to learn the inner workings of web applications from it.
SMB developers really need to look critically at what their needs are and will be. Setting up a custom (and free) Java web stack could be the solution, but so might a LAMP stack or even a WISA stack. The nice part about the Java web stack is that it presents the most scalability and options should the target deployment OS change. JBoss is newer, but it is really the only way to go if the development can’t commit to a deployment just yet.
Enterprise-level developers should consider WISA because those are the environments for which it’s intended. For enterprises wishing to place the onus of maintenance on IT or a third party—and not development—then this is definitely the way to go. Though, maybe the next version of GlassFish will present an even better enterprise stack.