Simple setup

How does a web request happen in a simple single-server setup? Note the order of the requests made

Step 1: Separating the data and web tier

Separating web traffic (web tier) and database (data tier) servers allows them to be scaled independently Data is now saved in a separate DB tier

Which database to choose?

There are, primarily, two kinds of databases:

  1. Relational database
  2. Non-relational database

Step 2: Multiple web servers - Using load balancer

  • Users will send requests to the public IP of the load balancer, which in turn will decide which server to forward the request to
  • If the traffic increases, the number of servers can be increased and the load balancer can start sending the increased requests to the new servers too.

Step 3: Replicating data

Step 4: Inserting a cache tier

  • Used in order to improve the data fetch speed of frequently read data
  • In this scenario, we will go with the Read-through cache

Step 5: Using a CDN

  • Used to deliver static content

Step 6: Scaling horizontally - Create stateless web tier

  • We need to move state (like user session data) out of the web tier
  • Good practice is to store session data in the persistent storage such as relational database or NoSQL
  • Each web server in the cluster can access state data from the persistent storage created above
  • This gives us the Stateless web server

Step 7: GeoDNS routing users

Demonstrating GeoDNS routing

Step 8: Decoupling systems to support independent scaling of systems

  • Message queues help with decoupling of systems reducing inter-service dependencies

Step 9: Logging

  • Monitoring logs is important in order to identify errors and problems in the system

Step 10: Collecting metrics

Collecting application system metrics

Step 11: Automating application development process

Automating application maintenance cycle

A full blown horizontally scaled application

Step 12: Scaling the database

Horizontal scaling vs Vertical Scaling

Sources