Note-
Recommended to read PART-1.
Part-1 Summary Recap…

Multiple clients and single server
We discussed in the previous part, that a client will send a request and a server will send the response back.
As discussed earlier a server is essentially a computer and like every computer it is has — memory and CPU. Right now your webpage is locally stored in the server’s memory and the request is processed by server’s CPU.
Earlier we assumed only a single client is calling the server, now imagine if thousands of clients are calling the server, the CPU of the server will not be enough to process these many requests and client will face errors or very slow response.
How do we resolve this?
Introduction to Web-Tier & Data-Tier
We are going to now scale the server. If this server is not enough to process ‘X’ number of requests, a simple solution is to bring out a bigger server (with faster processing power). But hold on ! your existing server is also storing the web page right? So it has a lot of data. If we bring a new server, we will have to take the pain of transferring this data to the new server.
Therefore, it is wise to NOT store the website data locally on the server but on a database and the server must fetch the website data from this database. The web server is only supposed to serve the client’s requests. Hence, we are separating the ‘web-tier’ and ‘data-tier’. This will help each of them to scale independently.
- If the database is small and needs to scale to a bigger database, the server is not touched at all.
- If the server is slow, and need to scale to a faster server, the database is not touched at all.
Thus, this is the benefit of separating database and the server.

In the above diagram —
- User enters the website amazinglyme.com and presses send.
- The request goes to the DNS to resolve the domain to IP address.
- The IP is resolved by DNS and sent back to the client.
- The client will send the request to the IP of the server.
- The web server receives the request and reads the website data from the database (and also may some write data to the database), and then sends response back to the client’s system.
See you in part-3 where we will talk about scaling the server — Vertical vs Horizontal scaling.