Open In App

Design a webpage that can show the status of 10M+ users including: name, photo, badge and points | System Design

We’ve got this huge community—over 10 million strong—and you want to build a webpage where everyone’s details, like their names, photos, those cool badges they’ve earned, and their points, can all be seen. That’s a massive load of information to handle. Achieving this goal necessitates an efficient and scalable system architecture capable of handling immense data volumes without compromising on performance or user experience.



1. Requirements of the Webpage System Design

1.1. Functional Requirements of the Webpage System Design

1.2. Non Functional Requirements of the Webpage System Design

2. Capacity Estimation of the Webpage System Design

Here are some capacity assumptions we can make for this system:



2.1. Traffic Estimates

Active Users = 10 million
Daily Active Users (DAU) = 5 million
Profile requests per user per day = 10
Total requests per day = 50 million

Avg QPS = 50 million / (24 hrs x 3600 sec/hr) = ~580 requests/sec
Peak QPS = 2 x 580 requests/sec = 1160 requests/sec

2.2. Storage Estimates

200 bytes for name = 200MB
500 bytes for photo = 500MB
10 bytes for badge ID = 10MB
4 bytes for points = 4MB
Total storage per user = 714 bytes

For 10 million users: Storage needed = 7.14 TB

2.3. Bandwidth Estimates

Profile data fetched per request

200 bytes (name)
500 bytes (photo)
10 bytes (badge)
4 bytes (points)
Total = 714 bytes
Daily active users = 5 million
Profile requests per user per day =10
Requests per day = 50 million

Daily Bandwidth: 50 million x 714 bytes = ~35 GB/day

3. High Level Design of the Webpage System Design

At a high level, the system manages two primary functionalities:

3.1. Updating User Status

Once authenticated, users have the capability to modify their profile information, including their name and profile image. Additionally, any changes in points or badges earned should be reflected and updated accordingly.

3.2. Reading User Status

The system design encompasses the retrieval of comprehensive user details, including names, profile points, and badge information, ensuring access to this data for the vast community of over 10 million users.

3.3. System Components of the Webpage System Design

4. Database Design of the Webpage System Design

4.1. Users Table:

{
-UserID
-UserName
-PhotoURL
-UserPoints
-UserBadgeID
}

4.2. Badges Table:

{
-BadgeID
-BadgeName
-BadgeDescription
}

5. How to show the status of 10 million users

To efficiently handle the display of 10 million user records, we’re organizing the data into manageable batches and showing only what fits on the screen at a time.

6. Communicating with the servers in Webpage System Design

6.1. User Authentication

Description: Allows users to securely log in to access the system.
Endpoint: `/auth/login`
Method: POST

Request:

POST /auth/login

{
“username”: “user123”,
“password”: “securepassword123”
}

Response:

{
“accessToken”: “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…”,
“expiresIn”: 3600
}

6.2. Retrieve User Profile

Description: Retrieves detailed information about a specific user.
Endpoint: `/users/{userID}`
Method: GET

Request:

GET /users/123456

Response:

{
“userID”: “123456”,
“name”: “Salik Alim”,
“photoURL”: “https://example.com/profile.jpg”,
“points”: 500,
“badge”: “Gold”
}

6.3. Search Users

Description: Allows searching for users based on specified criteria.
Endpoint: `/users/search`
Method: GET

Request:

GET /users/search?query=Salik&filters={“badge”:”gold”}&page=1&limit=10

Response:

{

“results”: [
{
“userID”: “123456”,
“name”: “Salik Alim”,
“photoURL”: “https://example.com/profile.jpg”,
“points”: 500,
“badge”: “Gold”
// …more user data
}
],
“totalResults”: 25
}

“`

6.4. Update User Profile

Description: Allows users to update their profile information.
Endpoint: `/users/{userID}`
Method: PUT

Request

PUT /users/123456

{
“name”: “Khabib Nurmagomedov”,
“photoURL”: “https://example.com/newprofile.jpg”,
“points”: 600,
“badge”: “Diamond”
}

6.5. Request for Next Batch

Description: Requests for next batch of data to be displayed on the screen.
Endpoint: `/users/nextBatch`
Method: GET

Request

GET /users/nextBatch?lastUserID=100&pageSize=50

Response

{
“users”: [
{
“userID”: 101
“name”: “User101”,
“photoURL”: “https://example.com/user101.jpg”,
“points”: 250,
“badge”: “Silver”
},
{
“userID”: 102,
“name”: “User102”,
“photoURL”: “https://example.com/user102.jpg”,
“points”: 180,
“badge”: “Gold”
},

// … more user data
],

“totalUsers”: 1000
}

7. Database Architecture of the Webpage System Design

Database

The database architecture is based on MySQL, a reliable and robust relational database management system.

Sharding

To efficiently manage the substantial data load and facilitate scalability, the database employs a sharding technique using the userID hash.

Master-Slave Architecture

Within this architecture, the master-slave replication mechanism plays a pivotal role. Data changes originating from the master node are asynchronously replicated to corresponding slave databases. These changes are captured as events on the master and then transmitted to the slave databases, ensuring that they maintain up-to-date copies of the data.

Simultaneously, sharding partitions and scales write operations across multiple master nodes, distributing the write workload evenly and facilitating efficient management of expanding user data.

Overall, this database architecture, employing sharding, master-slave replication, and strategic connectivity and scaling mechanisms, provides a resilient, scalable, and responsive framework to effectively manage a large and dynamic user base while maintaining data integrity, availability, and performance.

8. Low Level Design of the Webpage System Design

8.1. Client

The user will use desktop, mobile or web platform to either update their data or to check the status of other users.

8.2. Load Balancer

The load balancer acts as the pivotal gateway, efficiently distributing incoming requests among multiple web servers. Employing sophisticated algorithms, it ensures an equitable allocation of traffic, thereby optimizing system performance by preventing overload on individual servers.

8.3. Web Servers

It functions as the primary interface between users and the system, web servers handle HTTP requests and dynamically generate user interface pages. It collaborate with application servers to retrieve necessary data, presenting it in a user-friendly format.

8.4. Authentication Services:

Authentication services authenticate user credentials during login attempts, generate tokens or session identifiers upon successful validation, and manage the security context throughout the user’s session.

8.5. Write services

It serves as the core component managing all write operations pertaining to user profile information, encompassing functionalities such as creating, updating, or deleting data. Its primary aim revolves around segregating write functionalities from read services, ensuring independent scalability for different facets of the system.

Functioning as a pivotal component, it comprises several key elements:

8.6. Database

It stores user profile details like names, points, and badges and relies on MySQL due to its relational structure and adherence to maintaining high data consistency following ACID properties.

8.6.1 Master-Slave Setup

8.6.2 Sharding Implementation

8.7. How the Database will work in Webpage System Design?

8.7.1 Write Operations (Master)

8.7.2 Read Operations (Slaves)

8.8. Caching Servers

We’re utilizing Redis cache to hold batches of points, badge and name of users, specifically intended for displaying information on the screens.

8.10. Image Servers(CDN)

The Image Servers function as a cloud storage system housing all the images.

9. Work Flow of Webpage System Design

There are three workflows that we have to manage:

9.1. Changing the status of the users

9.2. Accessing the status of 10 million users

9.3. Searching for any specific user

10. How to make the system Scalable?

The system employs several techniques to enable scalability:

11. Conclusion

In summary, the system handles immense data volumes and high traffic demands, supported by a robust combination of database sharding, master-slave replication, intelligent caching, load balancing, microservices, and horizontal scaling, ensures responsive user experiences with consistent high availability and low-latency interactions. With additional features like advanced search capabilities and CDN-based image delivery, the system achieves scalability, maintaining peak performance even amidst substantial user growth.


Article Tags :