Making Your Database Highly Available
Making Your Database Highly Available
4 Share
If you aren’t subscribed yet, join 600+ curious developers looking to expand their knowledge
by subscribing to this newsletter.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 1/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
You can make the application highly-available with multiple instances. But if your
database still resides on a single node, you are in a vulnerable situation.
There are two main factors that control the high availability of a database.
Redundancy
Isolation
Redundancy
Redundancy is all about having options.
If you’ve one database server and it goes down, that’s the end of the show.
Clearly, no business looking to thrive would want a database going down. A study
claims that the cost of a database outage is an average of $7900 per minute.
Backups are more about keeping a copy of the data safe in case of catastrophic loss.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 2/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
If you have only one database server with a backup strategy in place, it’s still going to
cost your business big time to make the backup data available to the actual users and
for normal operations to resume.
Plus, there are chances that the backup copy is way behind the actual data so you
might have to deal with loss of data.
There are 3 main patterns that help achieve this level of redundancy:
Active Passive
Active Active
Multi Active
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 3/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Isolation
Isolation is all about reducing the impact radius of a disaster on your database
system.
The more physically separated your redundant components are, the less likely that all
of them will fail at the same time.
Here are the various degrees of separation you can opt for:
Server
Rack
Data-center
Availability Zone
Region
As you move right on the below isolation scale, you get greater physical separation
and potentially higher availability in case of unforeseen circumstances.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 4/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Systems that can extend with any requirement you throw at them.
Usually, this thought process leads to products that try to do much at the same time
and usually end up failing.
However, Notion is one of the few products that has bucked the trend.
Over the years, it has managed to support many different requirements and
applications. The community around Notion has exploded and many secondary
products have been built using the core platform.
A large part of this success goes to the incredibly flexible data model built by
Notion’s team.
Blocks in Notion are a unit of information. There are multiple types of Blocks:
Text
Image
List
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 5/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Row
Page
Despite their multiple uses, each Block has some key attributes:
These attributes basically control how a Block is displayed within the Notion editor.
Each Block also has other attributes meant for linking it to other Blocks in the
system. For example:
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 6/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Content - Array of block IDs for nesting content within a block such as items in
a list.
If you’ve used Notion in a collaborative mode, you must have noticed that it provides
a concurrent interface.
It means you and your friend can update a page together in real time.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 7/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Unique ID
Block Type
Properties
The parent Block is also updated to keep track of the position of the new block in the
overall hierarchy.
Data is saved in the local state (in-memory) and the editor is re-rendered to show
the new Block.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 8/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Load all blocks and their parents that are part of the transaction.
The “success” response is returned to the client so that it can continue with the
next transaction.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 9/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
However, in a collaborative setup, this update should make its way to your friend’s
screen as well.
After saving the Block to the database in Step 2, the API also notifies the
MessageStore service.
The API notifies the MessageStore service of the new versions for the updated
blocks.
MessageStore finds all the client connections that are subscribed to those
changes and passes the notifications to the client via the WebSocket connection.
The client receives the version update notification and verifies it with the
version of the block in its local cache.
On encountering the difference, it makes a call to the API for the latest record
data, updates its local copy and re-renders the view.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 10/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
As you may have noticed by now, Blocks are the foundation of Notion’s tremendous
flexibility.
It allows the users to tailor the software for their own purposes without additional
burden on the Notion engineers to support varied requirements.
They can focus on building the core product and focus on providing additional tools
to the users.
In my view, this is a great approach to follow if you also want to build software that’s
highly flexible.
Instead, think of how you can empower your users to solve their own problems with your
software.
P.S. This post is inspired by the explanation of Notion’s Data Model on their
engineering blog. You can find the original article over here.
🍔
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 11/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
https://x.com/Franc0Fernand0/status/1697481663318577275?s=20
But we often commit a fatal flaw while putting in the efforts for promotion.
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 12/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
I feel that teaming up with the manager’s mission is a far better approach to getting
the coveted promotion and making allies along the way.
https://x.com/ProgressiveCod2/status/1697859692117012515?s=20
4 Likes
Comments
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 13/14
28/01/2024, 10:07 SDC#5 - Making Your Database Highly Available
Write a comment...
https://newsletter.systemdesigncodex.com/p/making-your-database-highly-available 14/14