Recently when I saw a notification come out of re:Invent about a new AWS service called Babelfish my interest was piqued. At first I assumed it was a new language translation service, since that is the task the babel fish performed in Douglas Adam’s famously nerdy book The Hitchhiker’s Guide to the Galaxy.
The Babel fish is small, yellow and leech-like, and probably the oddest thing in the Universe. It feeds on brainwave energy received not from its own carrier but from those around it . . . The practical upshot of all this is that if you stick a Babel fish in your ear you can instantly understand anything said to you in any form of language.
– Douglas Adams in The Hitchhiker’s Guide to the Galaxy
When I started to look more into it though, I realized that it was a translation service, but not for spoken languages. It was a translation layer that allowed you to run applications built for Microsoft SQL Server against Amazon Aurora PostgreSQL, performing query translation in real-time. It doesn’t just parse T-SQL, it also implements the underlying protocols, so you can continue to use SQL Server tools against PostgreSQL while you migrate.
This all sounded quite intriguing, so I dug in a bit further, and this is what I found out…
Faster, and less risky, migrations
Many enterprises have built their applications to run on Microsoft SQL Server or Oracle, so there’s a ton of inertia to staying on those platforms. Moving away from a database is a monumental amount of effort. Not only do you have to move all of your data, but you also have to rewrite every SQL statement in your application.
This is where Babelfish really shines. Instead of having to rewrite large portions of your application, Babelfish promises to allow you to run your application against PostgreSQL largely without modification. It is hard to understate how much this could reduce the time it takes to migrate.
You’ll still need to leverage a separate tool such as Amazon’s Database Migration Service, to migrate your schema and move all of your data, but you won’t have to also rewrite your entire application at the same time.
Upgrade at your own pace
When Babelfish is enabled, you don’t have to swap out database drivers or rewrite all of your application’s database requests, but that doesn’t mean you’re tied to using T-SQL queries forever. Babelfish will allow you to simultaneously build new functionality using native Postgres functionality while still supporting your old queries. The goal is to allow a slow and smooth transition over to Postgres.
When your application connects through Babelfish to your database, all of your queries will be translated, but when you connect with a native Postgres driver, everything will continue to work exactly as you expect it. Sure, there are some limitations here, but in most cases the tradeoff in complexity at the application layer will be more than worth it.
A focus on “correctness”
When considering a SQL translation tool like this, you might be thinking that it sounds like a huge opportunity for introducing subtle bugs into your systems. Different databases often operate in subtly different ways. A nightmare scenario would be a situation where Babelfish translates a query successfully, but there is some small semantic difference between how SQL Server operates and how Postgres operates which could cause a serious bug that can’t easily be detected.
Matt Asay gives an example of this in his AWS blog post of rounding differences between datatypes in SQL Server and Postgres (see aside). In order to minimize this type of subtle issue being introduced, one of their core goals with Babelfish is to ensure “correctness”. The idea being that it won’t just translate your queries and ensure they run, but they want your application to behave in exactly the same way as it would running against SQL Server. Easier said than done, right? Amazon realizes this is an audacious goal, and so all of the work done on Babelfish will be in the open on Github to hopefully draw the community support that will be needed to reach this milestone.
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
– Douglas Adams in The Hitchhiker’s Guide to the Galaxy
A healthy skepticism
We are excited about the possibilities of what AWS is attempting with Babelfish. We hope they are able to fully realize their goal of running an application designed for SQL Server against a Postgres database with very little modification. But at the same time we are a little skeptical. Once the tool is out on Github, it will become clear in the coming months just how successful the project will be.
In a future post, we’ll go into more detail on how Babelfish works and help you decide whether it is something you’d like to explore further.
Loved the article? Hated it? Didn’t even read it?
We’d love to hear from you.