2-Tier Web Architecture
The web architecture is changing for many reasons- read/write, high volume of data, more devices, mobile, etc. The good news is that it's changing in a simple direction.
We all know about this 3-tier web architecture:
Web Server: To serve static contents
App Server: To run business logic
Database : To store data. (SAN/NFS for storage)
What is the problem with this architecture?
Web Server: CDN now does this work. The static requests doesn't (mostly) come to the origin datacenter.
App Server: It itself complex piece of sw. I remember counting 50+ modules in an app server. It ran fine on vertically scalable machines like Sun E10K. How many companies are buying these machines to run app servers? It's challenging to horizontally scale on small machines based on-demand.
Databases: Good for consistency with always-read applications and is still good. Scaling is challenge. Disk IO is expensive. Always-write is challenging with RDBMS. Pl read Amazon's Dynamo paper for details.
So, what is the new web architecture?
It's a 2 tier. You punt one layer to CDN at the top and run your database in memory at the bottom.
Here is the new architecture-
Tier-1: It handles HTTP connection + runs the business logic. Example- Apache +PHP or Jetty.
Tier-2: It's memcached supported by a datastore at the back end. The datastore can be MySQL-type or Cassandra-type NoSQL. (You may also want to read Stanford's RAM Cloud paper)
This is the change:
CDN is the new web server.
App Server is the new web server.
MemcacheD is the new database.
RDBMS is the new disk.
Let's expand the above picture with a network diagram:
HAProxy#1 ...... HA Proxy #n
Is this architecture works for all web applications?
You may still need to execute range query against RDBMS. You may still need the consistency. You may still need App Server- RDBMS transactions. Your engineers may not be comfortable writing code close to the metal. But high performance web is clearly moving to some sort of this 2-tier architecture.
Last week here in Sunnyvale, Amazon CTO made a comment in AWS event and that summarizes the new architecture well: "For 90% use cases we use key-value store and for remaining 10% we use RDBMS".
If your application is complex than Amazon.com and gets more traffic than Amazon.com, then you may want to continue with 3-tier architecture!!! If not, think about the future with 2-tier architecture.