6 Facts about Distributed Transactions That You May Not Know

Google this topic and you’ll likely find a lot about what distributed transactions are. How they work, and when to use them. Unfortunately, good examples of how they behave in the real world seem few and far between. If you’ve never worked with one before or just want some clarification on a particular detail then you’re in luck. We’ve done the research for you!

Here are 6 Facts about Distributed Transactions That You May Not Know:

1. They don’t automatically commit data across multiple databases/platforms

If your application talks to two different machines (or even servers). Chances are when it comes time to write the update there’s going to be an error saying that you can’t write both. At once because these pieces of data aren’t on the same machine. This isn’t necessarily a problem because you can always write everything to one side first, then the other. However, if you do these chances are your application will have some issues. After the fact because any changes made on. The “sending” side may not be recognized by the second machine unless they’re reapplied.

2. They don’t magically turn N-tier into 2-tier

A common misconception with distributed transactions is that it’s only necessary when your application needs to hit two or more different pieces of data in order to carry out an update. If you ever find yourself thinking this way then stop immediately. The name of the game here isn’t how many tiers your app actually has but instead whether or not there’s a possibility. That two/more data sources could be updated within the same unit of work.

3. They don’t save your data from network failure

One of the of-cited pros for using distributed transactions is that they’re capable of recovering from a failed network connection. By way of save points (locking down changes to each piece of data by timestamp). And then either rolling back or trying again later when the connection has been reestablished. This isn’t always true. For example, if you issue two commands in transaction A, one command in transaction B. And there’s a power outage before anything ever finishes then not only will all commands be rolled back. But also none of them will even be attempted until everything else has also finished downloading/uploading/etc over the network because your app once again has no idea what state things are in.

4. They do work with millisecond resolution

Another misconception about distributed transactions is that they only get an update. Every few seconds because the network’s too slow to give you anything else. This isn’t true either: SQL Server, for example, uses something called Snapshot Isolation. To lock records at a much lower level (generally 1ms or less). The result is that even if it takes several minutes for your app and the database to communicate over. The wire everything will still behave as if it happened instantaneously from your perspective (you’ll see all changes instantly) unless you happen to change another piece of data on a different server within the same millisecond window.

5. Save points can be turned off

If you’re going for a very high-throughput application, chances are you don’t want to use save points. If they’re not being used then why keep them around? In this case, SQL Server has a nifty little option called NOLOCK that can be applied to any query. Doing so will tell the server to return all data as-is regardless of how others might be using it. Basically turning off save points altogether across multiple machines. This is bad because it’s possible the same row could get read by two different servers. Which result in an update conflict each time (and even if there aren’t updates then there might still be insert conflicts). To prevent these issues try setting up sessions with unique transaction IDs. Or locking down everything en-masse instead of row by row.

6. They don’t require a ton of RAM

Another common misconception is that distributed transactions require heaps and heaps of RAM (on both servers) in order to work properly. This isn’t always true: SQL Server actually creates something called a virtual log file which. Thanks to the wonders of virtualization. Only takes up as much space as required at any given time (and all “extra” space goes back into your actual storage pool). In other words, if you’re worried about how much RAM you’ll need then stop worrying. It’s not as big an issue as everyone makes it out to be.

Conclusion:

Distributed transactions might not always be the best course of action depending on what you’re actually trying to accomplish. If you stick with the most basic data types (that’s text, numbers, and dates) then chances are everything will work out fine in your favor. If nothing else you won’t lose any sleep over the topic. To know more visit site – https://www.datanumen.com

John Mathew

John Methew is an experienced writer and editor, specializing in tech, gadgets, digital marketing, and SEO web development. He writes high-quality articles that resonate with readers and are easy to understand. With exceptional writing skills and unwavering commitment to excellence, John is a valuable asset to the team.

Related Articles

Back to top button