Zero To Million Users (Part 1) : Web Server

SDE Story Crafting
Dev Genius
Published in
4 min readMar 15, 2023

--

Welcome! Today we’re embarking on a journey from zero to a million users, and our first stop is the wild and wonderful world of web servers. Buckle up, grab your favorite coding snacks, and get ready to learn how to handle traffic like a pro. Let’s do this!

Table of content:
1. Journey FROM user sending a request TO getting a response back
2. Fundamentals of a web server
3. How many servers are required to handle growth
4. Database server? How to do this?

Journey FROM user sending a request TO getting a response back

Single Server Setup

The following explains user’s journey for a single server setup:

  1. User access website through domain name (e.g. www.google.com)
  2. DNS(Domain Naming System) returns IP Address to user. IP address is the location of the web server which contains the resources the user is requesting.
  3. Once IP Address is obtained, HTTP requests are send to web servers(using API)
  4. Web servers return HTML pages of JSON response (if available), basically the resource user was requesting.

Fundamentals of a web server

A web server is a software program hosted on a machine. It is almost always connected to the internet to serve(when requested) from anywhere over the internet. It delivers web content to clients (e.g. web browsers) upon request. Let’s explore some of the key concepts and technologies involved in building and deploying a web server.

  1. Server Hardware: A web server needs a physical or virtual machine to run on. You can set up a dedicated server or use a cloud hosting service like AWS, Google Cloud, or Azure. You need to consider the size and power of the server hardware based on the expected traffic to your website.
  2. Web Server Software: The web server software is responsible for accepting requests from clients and serving web content. Apache and Nginx are the most widely used web servers. They both support a wide range of features and configurations.
  3. Domain Name System (DNS): DNS is a system that translates human-readable domain names, such as www.google.com, into machine-readable IP addresses, such as 172.217.7.196. The IP address associated with a domain name represents the location of the web server hosting the website. Each domain name corresponds to one or more IP addresses depending on user’s geographic location. For example: The IP address of www.google.com can vary depending on your geographic location and other factors, as Google has many servers distributed around the world to provide fast and reliable service..
  4. HTTP Protocol: HTTP (Hypertext Transfer Protocol) is the standard protocol used by web servers to communicate with clients. Web servers respond to client requests with HTTP responses, which include the requested web content and status codes.
  5. Web Content: Web servers deliver web content, such as HTML, CSS, JavaScript, and multimedia files, to clients. You can store web content on the server’s file system or use a content management system (CMS) like WordPress or Drupal to create and manage web pages.
  6. Security: Web servers need to be secure to prevent unauthorized access, data breaches, and other security threats. You can use SSL/TLS encryption to secure client-server communication, implement access controls and firewalls, and apply security patches and updates.
  7. Monitoring and Performance: Monitoring and performance optimization are essential for a web server. You can use tools like Nagios, Zabbix, and Grafana to monitor server health, track server usage and traffic, and optimize server performance.

As a software engineer, you may also want to explore web server programming languages, such as PHP, Python, Ruby, and Node.js, and web server frameworks, such as Django, Flask, Ruby on Rails, and Express.js.

How Many Servers Are Required To Handle Growth?

2 servers are ideal in the initial phase of traffic growth. 1 server for the client’s (website or mobile) API requests. Another for storing the data i.e. for the database.

Why 2 servers? Security. Server that exposes API gives the leverage to be hit by anyone with any input. If this attack happens, then database should not be compromised. Hence, database on a different server which is not accessible by user.

Database Server? How to do this?

Hosting your database on a different server than your web server can offer several benefits, including improved security, better scalability, and easier maintenance. Here are the steps to host your database on a different server:

  1. Choose a hosting provider for your database server: You can either choose a cloud provider such as AWS, Google Cloud, or Azure or choose a dedicated hosting provider that specializes in database hosting.
  2. Set up the database server: Once you’ve chosen a hosting provider, you’ll need to set up the database server. This will typically involve selecting the appropriate database management system (DBMS) and configuring the server with the necessary hardware resources and software.
  3. Configure the database server to accept remote connections: By default, most database servers are configured to only accept connections from the local machine. To host your database on a different server, you’ll need to configure the server to accept remote connections.
  4. Update your web server configuration: You’ll need to update your web server configuration to point to the IP address or domain name of your database server.
  5. Test the connection: Once you’ve completed the above steps, you should test the connection between your web server and the database server to ensure that everything is working correctly.

By following these steps, you can easily host your database on a different server than your web server and take advantage of the benefits that this approach offers.

That’s a wrap! Follow for more. In the next part, we will discuss elaborately on database (types, when to use what).

--

--