How long does it take to lose $440 million?
The answer is… 45 minutes.
In July 2014, a company called Knight Capital was preparing for a new trading market open.
Just a week before the big day, a Knight engineer manually deployed a new automated trading code on their SMARS servers.
This code was designed to accelerate the trading process and could perform thousands of orders per second.
This sounded like a great plan, but the engineer made a mistake and only copied the new code to 7 out of the 8 SMARS servers, leaving the 8th SMARS server with the old, erroneous code.
Even worse, Knight didn’t have an automated system to prevent such discrepancies.
When the market opened on August 1st, Knight’s SMARS servers started sending thousands of incorrect orders per second that would buy high and sell low.
When the engineers finally found out and shut down the SMARS servers, they had already performed 4 million erroneous executions and lost $440 million. Ouch!
So what’s the lesson here?
There are many things Knight’s engineers could’ve done to avoid this tragedy. And one of them is to create tests that prevent the discrepancy.
In this case, Knight should have implemented automated deployment pipeline with end-to-end tests that invoke all the production servers before releasing a new version.
Most likely, just querying the version of the application deployed in production would have been enough.
So what can you learn from this event?
Well, it comes back to the importance of having well-written tests (and automated deployment pipeline, for that matter).
Even if it’s more time-consuming in the short term, it’s going to save you a lot of headaches and, as you could see in Knight Capital’s case, a lot of money.
If you follow my 4 pillars structure in my book Unit Testing Principles, Practices, and Patterns, writing unit testing becomes simple and clear.
This book is a culmination of my over 15 years of research, trial, and error — compiled, refined, and distilled.
You’ll not only see the nuts and bolts of writing tests but also learn specific strategies about different aspects of unit testing.
It goes much beyond the "how" and trivial examples. You’ll also understand how the overall design of your code impacts the unit tests.
If you want to write unit tests with minimum pain and avoid all the trial and error that I’ve gone through…
(Again, the discount code is nwsentr40.)
Take care,
Vlad.
P.S. After you grab the book, I’ll give you another bonus.
It’s my course, 5 Non-Obvious Tips for Writing Better Unit Tests.
All you need to do is forward the book purchase receipt to my email book@enterprisecraftsmanship.com, and I’ll enroll you in the course as a bonus.
P.P.S. If you really like the book and want to consult with me, reply to this email with the word "consult", and we can chat more.