Writing your own distributed system shouldnâ€™t be a task you undertake lightly. Too often, Iâ€™m seeing teams create their own distributed system. In my experience, this is because they donâ€™t know or think about all of the ramifications of creating their own distributed system.
I say all of these things as someone whoâ€™s created 3 distributed systems from scratch. Iâ€™ve also taught and mentored teams whoâ€™ve created their own system. As part of my research, I always ask them â€œKnowing what you know now, would you write your own?â€ The answer is always a resounding no. They had too many unknown unknowns to make an informed decision. Iâ€™m writing this post to remove these unknown unknowns.
Check Yourself â€“ Before You Wrickity-Wwreck Yourself
Letâ€™s first consider the reasons why youâ€™re even considering writing your own distributed system. These reason will give you an initial gut check of the real reasons youâ€™re even considering this. Letâ€™s consider some poor reasons to write your own.
One reason is that you donâ€™t like how a particular system dotted its iâ€™s or crossed its tâ€™s. Every system in Big Data has to cheat in some way or another. You might not like the way a system cheats or that cheat prevents you from accomplishing a use case. There are many different systems out there and I strongly suggest you keep looking for one that lets you accomplish a use case.
Another reason is that you are really smart and could do it better. Your distributed system would be better adapted to your use case because youâ€™re smarter and could write it better. You might have written some code in university that gives you a background in distributed systems. You might think your use case is so special that it requires your own distributed system. You might think that a general purpose distributed system is overkill for a problem and yours would elegantly handle it better. These thoughts often come from a lack of production experience with distributed systems.
Still another reason is that you donâ€™t feel you have enough time to look around at the different systems out there to make a choice. There are soooo many out there that you think you could write it quicker yourself. My rule of thumb is that nothing is quick and easy with distributed systems. Itâ€™s foolish to think youâ€™re going to do it faster or better.
A final reason, is that your masterâ€™s or PhD thesis was around a distributed system. Thereâ€™s this thought that you could simply improve their code a little to make it production worthy. There is a massive difference between production code and PhD thesis code. There is a massive difference between a system that works in production and a system that works in theory or academically.
The manifestations of problems writing your own distributed system will vary depending on phase of development youâ€™re in. Letâ€™s talk a little about what happens at each phase.
This is the stage where you make the fateful mistake of writing your own distributed system. It starts out simple. This system calls that system. It divides up the work…and done. Jesse must not know what heâ€™s talking about after all. That was relatively simple.
Then you pass it off to QA and they start testing. They find this edge condition and you fix it. You find another exception and you fix it. Wash, rinse, and repeat. Things are getting more difficult. Your code is looking like a bunch of if statements and exception handling.
Thatâ€™s just the beginning. QA wonâ€™t be able to find or test for everything.
Production and Operations
This is the stage where your distributed system is put in production. Things are handed off to the operations team. Your part in this is doneâ€¦or so you think.
One of the first questions the Ops teams asks is how they should support this new system. You say â€œDonâ€™t worry. Weâ€™ve tested this extensively and it should run without any issues.â€
Then comes the first support call at 3 AM. â€œThings are blowing up and we donâ€™t know why.â€ the ops person says. You roll out of bed, turn on your laptop, and start looking at the problem. Looking at the stack trace, you say to yourself â€œHuh, I didnâ€™t think of that error.â€
You realize that problem can only be fixed with a new code push. Your company has draconian rules on quick releases and you know this will be a fight. You leave for the office to get the patch ready. Tired. Very tired.
The next support call comes a few days later at 2 AM. â€œThings are blowing up and we donâ€™t know why.â€ the ops person says. You roll out of bed, turn on your laptop, and start looking at the problem. This time, there isnâ€™t enough logging to figure out what happened. You really have no idea what broke or why it broke.
Trying to replicate the problem doesnâ€™t work. There is some kind of interplay or state issue. This is going to take days to figure out and fix. You go back to bed. Tired. Very tired.
Every time there is a problem, it gets escalated to you. The Ops team has no other resource for figuring out problems than you. Youâ€™ve given them some steps to run before they call you, but those steps rarely work.
All of the knowledge about the system is tribal. It has to be transmitted directly from you to each member of the team. Thereâ€™s no way that an Ops person can Google it or find a solution on Stack Overflow. There is no outside course or book that Ops can leverage to support themselves. You are the bottleneck to everything.
You are now spending your time figuring out and fixing problems. You donâ€™t create features or write new code. Youâ€™re spending your time plugging holes.
Your code is now an unreadable mess. Itâ€™s 80% error and edge case handing. No one else can read it but you. Itâ€™s now difficult to make fixes because that fix may affect another workaround/fix. This system is so brittle you can barely keep it going.
This is the stage where youâ€™ve handed off the code to the Operations team. The project should have went into a maintenance mode while you work on the next version or another project.
The problem is that you havenâ€™t moved on. Months down the line, youâ€™re still patching and fixing. Anytime you start working on the next version, youâ€™re pulled back into a problem. At some point you stop trying to even start a new thing because youâ€™re just waiting for the next operational problem.
The entire teamâ€™s productivity goes down as youâ€™re not coding. It become a vicious cycle of not being able to QA everything, which makes a problem in production, which takes developers off coding, which takes time away from fixing the actual problem or creating new features.
Your roadmap looks like nothing but delays. Management is starting to ask questions. The salespeople are having to explain to customers why this or that product is so delayed. Thereâ€™s lots of unhappiness to go around.
Itâ€™s incredibly difficult to break yourself out of this downward cycle. It only comes after months of concerted effort and maybe a complete rewrite.
Will This Happen to You?
Maybe, maybe not. The preceding story is directly based on my personal experience at one company. This isnâ€™t hypothetical or academic; this is the real world.
Does This Apply to You?
You might be thinking this is a great blog post for other people. Iâ€™m unique, different, and smarter than others and this doesnâ€™t really apply to me.
You might think your use case is simple and would never grow to the monstrosity Iâ€™m talking about. A distributed system framework would be over kill for me.
Writing a distributed system is high experience-based. Unless you and your team have extensive experience writing your own system from scratch and put it in production, you probably donâ€™t have the requisite skills to write your own.
What You Should Do
You should use existing distributed systems whenever possible. There are many different systems out. Each one is appropriate for different use cases. You should spend as much time as necessary looking at frameworks. With distributed systems, an ounce of prevention isnâ€™t worth a pound of cure â€“ itâ€™s more like a metric ton of cure.
As you look through frameworks, donâ€™t immediately discount a framework as unable to work or handle your use case. You may not have the background to know for certain if it will or wonâ€™t work. As part of your project plan or Gandtt chart, there should be an entire piece or chunk of time allocated to choosing a distributed system. Coming from non-distributed systems or small data can give you a false sense of easy or trivial difficulty. Donâ€™t make this mistake and skip this vital step or put enough time into it.
When You Should Write You Own
There is a time and a place for you to write you own distributed system. These times, however, are few and far between. You should take an honest look at your team and skills before embarking on this project.
I strongly suggest you get a second opinion from an outside expert. This person should help you work through any preconceived notions before advising on the right path. This is often the purview of a qualified Data Engineer.
Letâ€™s say youâ€™ve exhausted all of the other routes. No one sells a system similar to what you need. There isnâ€™t an open source or closed source project that does what you need. Go back and look again!
Only after fully exhausting all other avenues and talking with an outside expert should you do it yourself.
Where to Go From Here
The most common cause for a team to write their own distributed system is a lack of knowledge of whatâ€™s out there. If youâ€™re doing a Big Data project, I have an entire course dedicated to teaching these skills. I donâ€™t just cover the APIs; I cover how to use it and why a technology is the right tool for the job. Save yourself some time and heartache. Get some help before you write your own distributed system.