What database solution do you offer for online sales

Can you give me a suggestion on creating a database?

I want to sell tickets to events, but the problem is that the database can become bootable when many users buy tickets at the same time for the same event.

  • If I have a counter of tickets left for each event, there will be more updates in this field (blocking), but I can easily find how many tickets are left.
  • if I pre-create tickets for each event, it will be difficult to know how many tickets are left.

Maybe it would be better if each event can use a separate database (if it is expected that the queries for this event will be high)?

Maybe the backup should also be done asynchronously?

Do I need to use a relationship database (MySQL, Postgres) or a relationship database (MongoDB)?

I plan to use AWS EC2 servers so that I can run more servers if I need to.

I heard that “relationship databases do not scale,” but I think I need them because they have transactions and data consistency that I will need when working with a certain number of tickets. Am I right or wrong?

Do you know some online resources for such topics?

+4
source share
4 answers

If you sell 100,000 tickets in 5 minutes, you need a database that can handle at least 333 transactions per second. Almost any DBMS with the latest equipment can handle this amount of traffic.

If you do not have such an optimal database schema and / SQL, but this is another problem.

+5
source

Check out this issue on inventory release .

I do not think that you will encounter the limitations of a relational database system. However, you need one that handles transactions. As I recommended for the poster in this question, you should be able to process reserved tickets that affect inventory or tickets for orders when the buyer assumes obligations until the transaction is completed.

+3
source

First of all: when it comes to selling goods (e-commerce), you really need transaction support. This basically excludes any NoSQL solutions such as MongoDB or Cassandra.

Therefore, you must use a database that supports transactions. MySQL does, but not in every storage engine. Be sure to use InnoDB, not MyISAM.

Because many popular databases support transactions, so it's up to you to choose which one.

Why transactions? Because you need to fill out a bunch of database updates, and you have to be sure that they all work as a single atomic operation. For example: 1) make sure the ticket is available. 2) Reduce the number of tickets available in one 3) process a credit card, get approval 4) write information about the purchase in the database

If any operation fails, you must undo previous updates. For example, if a credit card is declined, you should refuse to reduce the available ticket.

And the database will block these tables for you, so there are no changes that someone is trying to buy a ticket between steps 1 and 2, but the number of tickets available has not yet been reduced. Thus, without locking the table, it would be possible to get a situation where only 1 ticket is left, but it is sold to two people, because the second purchase began between steps 1 and 2 of the first transaction.

It is important that you understand this before you start programming an e-commerce project.

+3
source

your question seems broader than database design.

First of all, the relational database will scale perfectly for this. You may need to consider the level of web services that will provide the actual brokerage trading for end users. here you can manage things in cached mode regardless of the actual database design. however, you need to consider the appropriate steps for inserting data and updating, as well as choosing to optimize your performance.

the first step would be to continue and build a well-normalized relational model for storing your information. secondly, to create some web service interface for interacting with the data model, then put this in the user interface and stress test for many simultaneous transactions.

You will need my bid to then process your level of web services iteratively until you are happy - but your database (well normalized) will not cause any bottleneck problems.

+2
source

Source: https://habr.com/ru/post/1341814/


All Articles