4 ms·
I do not understand why, when updating a balance from a CC transaction, you wouldn't be using transactions. Start Transaction Update Balances Call CC Pro
by MichaelGG 13y ago
I do not understand why, when updating a balance from a CC transaction, you wouldn't be using transactions.
Start Transaction
Update Balances
Call CC Processor
Commit
That would eliminate "the billing system charged customer credit cards to increase account balances without being able to update the balances themselves" -- you don't go call a non-transactional CC processor until you've actually been able to process the update in your own system (which you can easily rollback).
If you're worried about Commits failing (due to not using pessimistic locking, for instance), then separate it into two transactions. That way when you go to process the CC the next time, you have a record stating there's already a transaction in-flight.
For financial records, I'd expect a bit more care. Sounds like they had proper records, but only as a backup/logging.
(Even for telecom, in which I work. There are fully ACID databases that have no problems handling millions of transactions/sec. In-flight balance information is trivial to handle.)
- superuser2 13y agoWhat databases are those?
- PommeDeTerre 13y agoGiven appropriate hardware, it's possible to get astounding performance, safety and reliability out of relational database systems like NonStop SQL, DB2, and Oracle.
- aphyr 13y agoThese ones, for starters: http://www.tpc.org/tpcc/results/tpcc_perf_results.asp?resulttype=undefined&version=5%&currencyID=1 http://www.tpc.org/tpcc/results/tpcc_perf_results.asp?result... On good server hardware, Postgres will happily push 100-200K small transactions per second. Naturally the definition of "transaction" varies, and you'll see vastly different performance depending on contention, locality, indices, etc. I'd expect logging independent events in a single table to be a good deal faster than multi-table transactions, especially those involving contended rows. On EC2, the story is (naturally) a good deal less heartening. I think you'd be hard-pressed to make it to 10K on TPC-B, given reports like http://www.palominodb.com/blog/2013/05/08/benchmarking-postgres-aws-4000-piops-ebs-instances http://www.palominodb.com/blog/2013/05/08/benchmarking-postg... Granted, single-node performance may not be the question to ask here, because this problem is readily shardable by customer ID, and operations can also be buffered in local memory to some extent. Remember: if it fits in Redis, the problem requires, at maximum, a single node's memory and a single core--and can tolerate network latencies.
- jessaustin 13y agoif it fits in Redis, the problem requires, at maximum, a single node's memory and a single core How many companies like Twilio are using an RDBMS for which this isn't the case? I mean, if people had enough money to buy an oracle cluster, they'd still probably buy something else?
- ironchef 13y ago"Remember: if it fits in Redis, the problem requires, at maximum, a single node's memory and a single core--and can tolerate network latencies." Not entirely true. A number of places out there use sharded redis. In which case, you're not limited by the memory or core in the same manner. A nit to pick, but hoping to keep the conversation on point (as you alluded to with the "shardable" comment)
- aphyr 13y agoIf you're using a sharded Redis, your problem is a collection of problems satisfying the above law. What I'm getting at is that if performance is seriously a problem, few things beat a dedicated service with concurrent, in-process memory--instead of pushing every operation to an external, fully serialized heap.
- MichaelGG 13y agoAs an example, VoltDB. The memory footprint required for balances and such is not very much, and VoltDB gives you near-linear scaleout to dozens of nodes. A few years ago I tried it for a CDR/balance system (insert record, update balance - single tx) and had no problem reaching 100K+ transactions/sec on a 3-way system (3x $500 servers).
- reissbaker 13y agoWhile transactions are generally important for, well, monetary transactions, they're not necessary in your example. You could just: Update Balances Call CC Processor And if updating balances threw an exception, you'd never reach the Call CC Processor statement. In fact, putting it inside of a transaction is more dangerous than not as the following example demonstrates: Start Transaction Update Balances Call CC Processor OH SHIT APPLICATION PROCESS DIES (or network partition, etc etc) DB connection is terminated Updated balances roll back But you still charged your customers' cards And destroyed your primary record of it Hope you didn't have any other work planned this week And unfortunately the above tends to happen more often than you'd expect.
- MichaelGG 13y agoHence, I mentioned if you're worried about commits failing (not a major recurring issue that I've seen but possible), the n you do two separate transactions.
- reissbaker 13y agoNope. You'd do at most one transaction, around the transactional part. You wouldn't wrap an external call in a transaction: if it's not transactional, you're literally doing nothing but adding load to your database. If your DB doesn't have access to the data, the transaction is meaningless: your database can't roll back the state. And if the Update Balances call is a single SQL statement, you actually wouldn't use any transactions at all. You'd just issue the write and have it be written. No point adding the overhead of a transaction if it isn't doing anything.