26. Design Ecommerce Product Listing
Chapter 1: Introduction to Ecommerce Product Listing Page
Objective: Design a simple ecommerce product listing page for a small shop owner with up to 100 items.
System Design Motive: Understand the structured approach to system design by taking small steps rather than massive leaps.
Expected Features:
Owner can add, update, or delete products.
Customers can access the product catalog (payment features are excluded).
Storage Requirements:
Total data is manageable since there are only 100 items.
Estimated payload for each item: 1 kilobyte, totaling up to 100 kilobytes of data.
Suitable to fit into a single database server.
Database Choice:
Given the small size, a SQL database is recommended because of the structured nature of the data (title, description, etc.).
Chapter 2: Front End and Back End Separation
HTTP Based Server: Expose APIs for data access.
Load Balancer:
Multiple API servers are needed to handle potential high traffic, placed behind a load balancer (e.g., api.mystore.com).
Forms part of a classic 3-tier architecture: users, compute, and storage.
Front End Development:
Essential for customer interface; uses standard front-end approaches for rendering catalog.
Admin Interface:
Create a separate Admin UI for shop owners to manage inventory.
Separation prevents entanglement of user and admin interfaces to reduce bugs and enhance security.
Chapter 3: Facing Front End Service
Admin UI Security: Separate admin interface is crucial as admin users have elevated privileges.
Access Control: Ensure proper checks on API calls to verify admin privileges.
Architecture Overview:
Front end interacts with back end, which communicates with the database.
A distinction is made for user-facing front end and admin functionalities to streamline operations and increase security.
Chapter 4: Handling High Read Load
Backend Scaling:
Due to high read requests from numerous users, the backend must scale accordingly.
Load balancer in front of backend servers allows for additional instances during high traffic periods.
Catalog Database Management:
Given read-heavy traffic, scalability is crucial.
A read replica setup manages excessive read requests:
Write requests handled by the master database.
Read requests can be distributed across master and replicas.
Myth Buster: The master database can handle both reads and writes depending on frequency and load distribution.
Chapter 5: Managing Writes and Reads
Write Operations: Admin UI writes occur less frequently (e.g., adding products).
Connection Management:
Each API server connects to both the master and replica databases simultaneously.
Alternating read requests between master and replica to balance load effectively.
Caching Considerations:
While caching can optimize reads, potential issues with cache invalidation can complicate the architecture.
Read replicas being easier to manage than caches here due to the simplicity of propagation of updates.
Chapter 6: Conclusion and Further Tasks
Exercise:
DB Design: Create a database structure for the product catalog.
API Development: Build a simple backend with appropriate data handling.
Read Replication Setup: Implement two database connections and randomize read request distribution.
Understanding Cache: Explore caching as an alternative while recognizing the complexities related to cache management.
Reflection on Design Choices: The exercise encourages awareness of practical system design decisions and their implications on performance and reliability.
This supports the understanding of structured system design in creating scalable, maintainable architectures suitable for small-scale ecommerce applications.