Realtime: Node.js, MongoDB and Redis? -
Okay, first of all I want to tell you that I am new to all the techniques mentioned in the headline.
I want to create a new app, think about it as a real-time trading engine (for example stock).
Therefore, there are two things that are really important:
- speed / performance: everyone
- Security: make similar trades together But only one can be successful.
I thought about this kind of approach:
If a user purchases 10 pesos of stock x for $ 100 If he wants, he keeps every order with radis (speed) and pushes it to all customers with socket.io. Ok, as soon as another user wants to sell 15 points for $ 100, the script should check whether there is an open purchase order. If so, it saves it as a successful transaction in Mongodybi (permanency) and closes the purchase orders of 10 pesos
In this example, there are 5 rocks left The script displays that with such calculations: 15 (Selling for $ 100) is less than 10 (buy in 100 $) 5 remaining. Every time someone should do this, it will be done to calculate because I do not know how many shares have been left for the business.
Edit: Or can I reduce the 10 points of 15 places in radis so that I do not need to count every time but if something goes wrong then I do not know what the original data was . This is a problem.
Now the questions are:
- Do you want to do this? Can be a better idea?
- What if two users create exact orders at the same time? It could happen, that it is stored twice as a separate successful transaction in Mongodybi? Of course you can run audits on radis and mongodibi and compare it. But this would be a terrible solution.
Hope I understand what I am trying to ask. Thanks in advance!
First of all if you do not know anything from the heap that you are using, this It is not good to say that I need high performance (high availability, good security and so on)
For your question: First of all see how others have talked about similar things. Which makes it an excellent example for studying (it's complicated, so take a deep breath) If you want to use Mongo, you need to know that it does not support the transaction, so you have to see that How to implement them themselves. The example is really good.
Comments
Post a Comment