Best Practices for Building Scalable Web Application Architecture

November 28, 2017

Each Web Application that works great with limited number of users may not work well with large number of users. A well designed application should be able to scale seamlessly as demand increases and decreases, and be resilient enough to withstand the loss of one or more compute resources. Any web application which is going to handle traffic of hundreds and millions of users across the globe needs to be highly available, scalable, reliable and must ensure data integrity and security.

Coarse grained architecture needs to be transformed into fine grained modular architecture by iteratively applying Scale up and Scale out strategies by using Vertical Scaling, Vertical Partitioning, Horizontal Scaling and Horizontal Partitioning at each level and keep repeating the same until all heterogeneous nodes/components/micro services get into separate box so that all homogenous nodes can be auto scaled (Horizontal Scaling) at fine granular level in each layer to eliminate the possibility of Single Point Failures (SPOF). Simple!

Furthermore proc, network boundary level and disk level caching services, content delivery networks (CDNs) can be used to minimize Network latency, reduce Network I/O, reduce Disk I/O, reduce Round Trip Time, achieve stateless level performance even for Stateful web applications. Instead of over relying on one particular technology/platform, use various technologies in a complementary way e.g. Single Page App, Smaller DOM, AJAX, Distributed Cache, REST, SOAP, Open Source, Cloud Tools and Technologies, SQL, NO SQL, NewSQL, DevOps, Hardware acceleration etc. to derive maximum gains and cost advantages.

Choose right open source for caching according to the technology e.g. for Java, choose the open source that supports serialize and DE serialize POJOs for faster performance. Optimum utilization of caching at browser level, page level, object level, L1/L2/L3 level caching play significant role in boosting performance.

Journey often starts with building POC for WebApp with everything in One Box because of No funding till date and the POC solution to be used for Demo Purposes.

Here are some of the best practices to achieve highly Scalable Architecture from a Single Box POC

  • Apply Vertical Partitioning Strategies on to Single Box POC system to break it down into three layers and each layer going into separate Box i.e. Web Server, App Server and DB Server
  • Apply Vertical Scaling (Scale UP) Strategies to Tune Web Server and App Servers towards CPU and DB Servers towards RAM for hardware performance optimization at Box level
  • Setup each DB Cluster with one Master Node and multiple Slave Nodes. All Writes and Critical Reads should go to Master Node, which should use SAN to maintain higher performance while dealing with frequent DISK I/O. Slave nodes to participate in handling Reads, which shouldn’t cause Disk I/O, achieve auto scaling for DB Reads. Use DB Replica and Caching for higher performance. Use No SQL for less frequently changing data such as product description, user profiles etc.
  • Apply partitioning at the table level, column level and row level for better performance and achieve fine grained architecture of DB layer. Repeat the DB Cluster (Step 3 & 4) as many times as you need
  • Apply Vertical Partitioning Strategies to Convert Monolithic App Architecture into Micro Services and use Loose Coupling through Standard Message Queue. Each Micro Service being heterogeneous to other and going into separate Box
  • Apply auto scaling (Horizontal Scaling – Scale OUT) at each Micro Service level
  • Use combined approach of Centralized Session Store and Clustered Session Management to avoid sticky session bottleneck and achieve stateless performance level with the underlying approach that only Write should trigger Disk I/O, Read should be directly from memory
  • Integrate with other services such as email service, which can be auto scaled like any micro service
  • Replace unwanted Synchronous calls with Asynchronous Calls and identify other performance and scalability bottlenecks in each fine grained part of web application
  • Use Content Delivery Networks (CDNs) for serving contents from nearest Availability Zone(s)
  • Achieve Http Acceleration by using Reverse Proxy Server on top of Web Server
  • For secure web Apps, Attach hardware SSL acceleration with Reverse Proxy
  • Use Load Balancer Cluster to make one complete SET (say for 10 million users) which consists of Web Server cluster, Auto Scaling at Each Micro Service level, multiple DB Server clusters etc.
  • Repeat the SET for another 10 million users and so on
  • Put Global Redirector on top of repeating SETs to provide single URL to hundreds of millions of users across the globe

 

Get in Touch
chatwithus