Intensive access and modification of database table

18 views
Skip to first unread message

tristant

unread,
Jul 19, 2020, 11:18:15 AM7/19/20
to Django users
Hi,

I am wondering if anyone could point me to any documents or readings on how to big eCommerce sites such as Amazon or eBay implements the following situation:
- A seller posts a product with an initial quantity, 'init_qty'.
- An unknown number of clients access the product concurrently, add it to their shopping cart.
- The site needs to manage the contemporary available quantity, "avail_qty", and all times. And switch the product to "unavailable" if the quantity drop to zero.
- However, the effective "avail_qty" is only updated permanently in the database if and only if the client checks out and pays.

For small eCommerce sites, updating the database frequently is not a big deal. But if the product count and client count is large, what is the efficient way to implement this?

Thanks,


Aldian Fazrihady

unread,
Jul 19, 2020, 2:01:57 PM7/19/20
to django...@googlegroups.com
Hi,
There are more than one transactional data architectures to achieve the goals, so only Amazon, eBay, or any other big commerce employees can answer your question.
However, if you are using transactional SQL as Django is using it by default, you probably need to learn about horizontal partitioning.

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd2b979b-6f63-465b-b6e7-8a831e53bf28n%40googlegroups.com.

Tran Trong Tri

unread,
Jul 19, 2020, 2:37:52 PM7/19/20
to django...@googlegroups.com

Derek

unread,
Jul 20, 2020, 6:38:56 AM7/20/20
to Django users
Its likely that Big Sites keep their detailed IP private; its unlikely that you are working on such a site.

Aldian is correct that there are many strategies, or combination of strategies you could use, and the exact one really does depend on the team's skills and choices of technologies.

One idea could be to use a key-value store such as Redis, which is fairly fast (see https://redis.io/topics/benchmarks but especially see "Pitfalls and misconceptions" to get some appreciation that real world problems are not at all trivial and most answers start with "it depends..."). You can use product ID as the key, linked to a pair of "current DB available; current total In-carts" values.  This would make lookups quick and you only need DB access/change when, as you say, an actual transaction is concluded.

This is just a possibility; and one of many you could employ.

Derek
Reply all
Reply to author
Forward
0 new messages