Live data from Hacker News

Migrating a 40TB SQL Server Database

tarynpivots.com

21–30 of 126 posts

Re: Migrating a 40TB SQL Server Database

#21
post #7
post #3

Storing web logs in a SQL database is a pretty bad plan.

Combined with "The database was initially designed to have a single table for each day." Oy.

Yeah, if they do that they might as well shard databases and not have this problem in the first place (not that there aren’t better tools)

Re: Migrating a 40TB SQL Server Database

#22

> "We realized that the original daily table structure wasn’t ideal. If we needed to query something over several days or months, it was terrible — lots of UNION ALLs or loops to crawl through days or even months at a time was slow." Seems to me rather storing traffic logs in an SQL database is a very bad idea, especially if you have 40TB of it. Anybody can explain why SQL database makes sense for large time series d…

Because you've already paid the licensing cost for the SQL database and have salaried DBAs taking care of it. And building an alternative solution (including HA, backups etc.) would cost more than $0.

> I fully expected the process to take months, and it did — after hitting delays in getting new servers the entire project took about 11 months.

This doesn't sound like it cost $0

Re: Migrating a 40TB SQL Server Database

#23

> "We realized that the original daily table structure wasn’t ideal. If we needed to query something over several days or months, it was terrible — lots of UNION ALLs or loops to crawl through days or even months at a time was slow." Seems to me rather storing traffic logs in an SQL database is a very bad idea, especially if you have 40TB of it. Anybody can explain why SQL database makes sense for large time series d…

>storing traffic logs in an SQL database is a very bad idea, especially if you have 40TB of it I get this question asked a lot of times in the interview. Why is it a bad idea to store logs in a SQL database? It has the ACID properties baked in and it is pretty reliable. What is the better alternative? I guess I have never worked on anything that would require keeping track of 40TB of data because of which the drawbac…

ACID properties are not useful here. Unless every single piece of data is required, which I highly doubt, then ensuring that every single log is written correctly doesn't matter. These are traffic logs, so if the server or application is down, how do these logs get written? I'm assuming that they don't. Have these databases never had outages as well, because if they did then the traffic would be lost as well. I would wager a guess that there are probably lots of gaps in their data that they just don't know about or don't care about.

So given that not every single log is required, then you can step back from ACID requirements and find a solution that is easier to maintain. Taking 11 months to migrate a database is not reasonable for most projects.

Re: Migrating a 40TB SQL Server Database

#25
post #24

I'm baffled with the fact that they were toying with the production database in the production machine. That sounds incredibly dangerous

> I'm baffled with the fact that they were toying with the production database in the production machine. That sounds incredibly dangerous

As Taryn stated repeatedly in the post, they simply didn't have enough infrastructure to have development spare copies of this. They didn't even have enough infrastructure to take a backup.

Re: Migrating a 40TB SQL Server Database

#26

> "We realized that the original daily table structure wasn’t ideal. If we needed to query something over several days or months, it was terrible — lots of UNION ALLs or loops to crawl through days or even months at a time was slow." Seems to me rather storing traffic logs in an SQL database is a very bad idea, especially if you have 40TB of it. Anybody can explain why SQL database makes sense for large time series d…

> Anybody can explain why SQL database makes sense for large time series data? Let's say, just to say, that you have effectively free licensing for Microsoft SQL Server (because you already own the licenses in question), and you have staff who know that platform well. Sometimes it's easier to use the tools you already have rather than go acquire a new platform to achieve a goal. As with anytime you choose a persisten…

>and you have staff who know that platform well.

People often ignore how important this is, especially for a small team like Stack Overflow appears to have. A new platform requires training and/or a lack of productivity as employees learn the new system. It requires developer time to convert over any work designed to use the old system. It makes hiring more difficult because now you will either want someone with the knowledge of both your systems which greatly shrinks down your pool of potential hires or new employees will need to learn a new system on the job which increases the ramp time up for any hires. Maybe this doesn't fit the textbook definition of technical debt, but it is still a real and ongoing cost that comes with making a decision to switch tools.

Re: Migrating a 40TB SQL Server Database

#27
> There were lots of reasons this needed to be done, one being tech debt. We realized that the original daily table structure wasn’t ideal. If we needed to query something over several days or months, it was terrible — lots of UNION ALLs or loops to crawl through days or even months at a time was slow.

Maybe i'm missing it, but there doesn't seem to be any discussion of the result. _How_ much faster was it after the change? Was it 11-months-worth-of-dev-time faster?

Re: Migrating a 40TB SQL Server Database

#28
post #3

Storing web logs in a SQL database is a pretty bad plan.

At this scale and amount of data, definitely. I have however dumped short term data into an unlogged temp Postgres table to query data using Metabase/psql. Worked surprisingly well enough for me to debug something. I'm sure another index on ES would've worked well too, but I'm more familiar with SQL than ES syntax and it's cheaper too.

Re: Migrating a 40TB SQL Server Database

#29
post #24

I'm baffled with the fact that they were toying with the production database in the production machine. That sounds incredibly dangerous

Actually if you read the article this is not actually critical infrastructure.

All the data is duplicated in both DCs and the source of data still has a copy of the data.

I imagine is not a problem if it goes down for some moments. Developers may be unable to review traffic logs, that's it.

Re: Migrating a 40TB SQL Server Database

#30
I found this article useful, mostly for people who don't have similar experience dealing with large databases. It gives so many reasons on why following this path is such a bad idea. Please people, stop writing custom scripts and then run them untested on the production db. If the company doesn't pay to give you enough disk space to take a proper backup to test just quit or buy it yourself. It will save you 11 months and many hours of sleep.
Post reply on HN