...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
On this page.
Table of Contents |
---|
Introduction
How do you build a similar online shopping system that stores an inventory of products under different categories, allow customers to search through them, and make purchases. Furthermore, how do you handle the expanding load on the website and prevent it from crashing down, particularly on busy days, such as the Black Friday Sale?
Step 1 - Understand the problem and establish the scope
Features ? | See below functional and non-functional requirements. |
---|---|
Supported devices ? | laptop/desktop, mobile. |
… | … |
Functional requirements
User Profile Management
Product on boarding
Select Product
Search Product
Cart facility
Proceed to buy
Non Functional requirements
Consistency
Availability
Latency
Step 2 - High-Level Design
...
Elasticsearch is a NoSQL DB, important because we are doing a lot of text search where traditional RDBMS DBs are not performing really well. It will be highly customizable, extendable through plugins, we can build robust search without much knowledge quite fast.
Spark Jobs will be needed to make recommendations to the user. Jobs will run on the data (user service, on-board product service), data will be unstructured data, will aggregate all these data and can put it into HDFS cluster. So, later with the new details, it will be able to make new recommendations.
3 major flows could be considered : Product on boarding, Search Product & Cart / buy Product.
On-Board Product Flow
...
Search Product Flow
...
Redis Cache is introduced to make the search feature more performant.
Cart / Buy Product Flow
...
Introduction of point-to-point communication : Cart Service communicating directly to Payment Service. No need to introduce between the services an integration via queue mechanism.
Step 3 - Design deep dive
Scale the DBs : DB replications and sharding
Scale the API Tier : work with stateless services (user services, for example authentication) - so easy to scale horizontally.
Introduce the rate limiter to handle the calls - Throttling pattern
Introduction of workers / web job (directly related to the App Service if Azure App Service).
Introduce Caching for User DB.
Introduce Data log to prevent data loss if necessary.
Concurrency : What if 2 users try to order the same product ? Introduce the lock