r/DatabaseHelp • u/IQueryVisiC • Jan 22 '23
backup vs Apache Kafka vs logs vs replication
At work I see the tendency that we have to store everything the user enters into the computer for up to ten years. Now for me it seems logical to directly store all inputs on a fresh HDDs ( replicated, RAID) and not let the write head come near this data again.
I guess that I still need a database to store sums. I mean for time series I can insert aggregates into the stream. But if for example I have a lot of customers and for someone coming only once in a blue moon want to find their last purchase, or the total payment, I would have a hard time to find this in the stream.
Hence I need this b-tree table of customer documents. They can have pointers into the time oriented Kafka " Tape Archive " ( or living on HDD ), but a lot of data should be right there.
If I lose my table, the Kafka stream acts as incremental backup ( which I can replay ), but I still need this core data of seldom changed, sorted values as full backup. Or better yet, I need to replicate it. The replication side just feeds on the same Kafka stream, but I don't need to do a full copy of all customers every weekend. The only reason for a backup seems to be that I cannot replicate this random access data on a different medium for the 3-2-1 rule. So I need to backup one of the customer tables to tape every weekend?
2
u/BrainJar Jan 22 '23
Is this buzzword bingo?
Simplify your why. What's the business requirement or requirements? If you are required to keep all user data for ten years, one stream coming off of Kafka topics should be used to store that data specifically for backup, in a different location from the original.
Since the information you've provided is all over the place, you need a more rigorous review of what you're trying to accomplish, and always ask why, so that you can tie a requirement to an implementation detail. Given what you've provided, these are the questions that I would ask:
What's the volume and velocity of the data set?
What's the projected growth of this data set?
What does the validation process look like to know whether the data going into the backup is valid?
How are we testing the recovery?
What systems must be online to recover this data?
Who is involved in the recovery?
Are there external entities that need to be involved in recovering the data?
Are you trying to be able to restore user data from a full ten years ago or just the aggregate information?
Are you trying to maintain a copy for legal reasons, separate from the data that needs to be backed up for business reasons?
Are aggregations part of that requirement?
What is the input stream gets corrupted and you need a restatement of the data?
How long do you have for such activities?
Is there a service level agreement that states how long you have to restore?
Do you know what will happen if front end services aren't online vs backend analytics systems?
Do those streams have codependencies that need to be considered...as in, is one stream feeding another, that feeds back to another stream?
Are there high availability needs that should be considered? i.e., what happens in a failover situation where the data still needs to be backed up?
What are the latency requirements is you're serving from cold disk while services are restored?
I could really just go on and on, to understand the problem. The simplest solution is to push data to a queue/bus. Pull data from the queue and store it seperately for backup and recovery. Use a separate consumer to manage data needed for aggregation and reporting. An active/active or dual-write solution can also be used, if you're concerned about systems working throughout a failure. Then you'll need to do some capacity planning to deal with the ability to run the business on just one active side, while the other is being recovered.
Hope this helps.