Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang fault-tolerant application: PA or CA of CAP?

I have already asked a question regarding a simple fault-tolerant soft real-time web application for a pizza delivery shop.

enter image description here

I have gotten really nice comments and answers there, but I disagree in that it is a true web service. Rather than a web service, it is more of a real-time system to accept orders from customers, control the dispatching of these orders and control the vehicles that deliver those orders in real time.

Moreover, unlike a 'true' web service this system is not intended to have many users - it is just a few dispatchers (telephone operators) and a few delivery drivers that will use it (as for now I have no requirement to provide direct access to the service to the actual customers; only the dispatchers and delivery drivers will have the direct access).

Hence this question is a bit more general.

I have found that in order to make a right choice for a NoSQL data storage option for this application first thing that I have to do is to make a choice between CA, PA and CP according to the CAP theorem.

Now, the Building Web Applications with Erlang book says that "while it [Mnesia] is not a SQL database, it is a CA database like a SQL database. It will not handle network partition". The same book says that the CouchDB database is a PA database.

Having that in mind, I think that the very first thing that I need to do with my application is to decide what the 'fault-tolerance' term means regarding to CAP.

The simple requirement that I have is to have the application available 24/7(R1). The other one is that there is no need to scale, the application will have a very modest amount of users (it is probably not possible to have thousands of dispatchers) (R2).

Now, does R1 require the application to provide Consistency, Availability and Partition Tolerance and with what priorities?

What type of data storage option will better handle the following issues:

  1. Providing 24/7 availability for a dispatcher (a person who accepts phone calls from customers and who uses a CRM) to look up customer records and put orders into the system;
  2. Looking up current ongoing served orders and their status (placed, baking, dispatched, delivering, delivered) in real time;
  3. Keep track of all working vehicles' locations and their payloads in real time;
  4. Recover any part of the system after system crash or network crash to continue providing 1,2 and 3;

To sum it up: What kind of Data Storage (CA, PA or CP) will suite the system described above better? What kind of Data Storage will better satisfy the R1 requirement?

like image 993
skanatek Avatar asked Aug 21 '12 19:08

skanatek


1 Answers

  • For your 24/ requirement you are searching a database with (High) Availability because you want your requests to succeed everytime (even if they are only error results).
  • A netsplit would bringt your whole system down, when you have no partition tolerance
  • Consistency is nice to have, but you can only have 2 of 3.

Your best bet will be a PA solution. I highly recomment a solution which has been inspired by Amazon Dynamo. The best known dynamo implementations are riak and couchdb. Riak even allows you to change PA to some other form by tuning the read and write replicas.

like image 73
Tobias P. Avatar answered Nov 20 '22 08:11

Tobias P.