News for hackers. Stuff that matters.
Re:Migrating a 40TB SQL Server Database by oneplane on Thursday July 30, 2020 @12:04PM (#23999723)
This reads like the most Microsoft or most legacy-on-prem problem ever. Why on earth would you do this, and even then not take the opportunity to do it right while you are migrating anyway? Are you mad?

Well, that was my first reaction anyway. It seems to me that this is more of a 'when all you have is a hammer, everything looks like a nail' to me; if you are a vendor shop (i.e. Microsoft-only) and you are a DBA and specifically just for MSSQL, then this is probably the best way you could come up with, based on the skills, experience and tools at hand. It does make me wonder if at any point someone thought to ask for help instead of keeping this going.

Re:Migrating a 40TB SQL Server Database by BrentOzar on Thursday July 30, 2020 @12:14PM (#23999871)
> Why on earth would you do this, and even then not take the opportunity to do it right while you are migrating anyway?

Because as a database administrator, you often have to solve hosting problems without telling your developers to rewrite all their code.

Re:Migrating a 40TB SQL Server Database by pc86 on Thursday July 30, 2020 @01:27PM (#24000777)
Which speaks to much more dire organizational issues - that nobody can throw up a red flag and say "hold the eff up, we've reached a scale where this is broken and we need to address it."
Re:Migrating a 40TB SQL Server Database by hn_acc_2 on Thursday July 30, 2020 @04:13PM (#24002381)
I would say this is actually the norm... In most orgs the leadership is not highly technical and this is always a hard sell.

The best you can hope for after a "hold the eff up" rewrite is for everything to keep working the same "but it's more hardened/scalable/modular/blah blah", and the worst you can hope for is to screw up some critical business process while the kinks are worked out.

Also, there is rarely any incentive for anyone from Joe Developer all the way up to C level to even call for this in the first place.

Re:Migrating a 40TB SQL Server Database by oneplane on Thursday July 30, 2020 @02:40PM (#24001529)
Unless the developers are HAProxy itself and made a module for HAProxy to log in to SQL databases (which it doesn't do by default) this is not even remotely related to the developers.
Re:Migrating a 40TB SQL Server Database by user5994461 on Thursday July 30, 2020 @05:57PM (#24003297)
Plot twist: it does support SQL out of the box!

HAProxy logs syslog messages, in a configurable format and to a destination of your choosing. All you have to do is to setup your favorite logging agent between fluentd/logstash/syslog-ng to listen on syslog and forward messages to a SQL database.

Re:Migrating a 40TB SQL Server Database by oneplane on Thursday July 30, 2020 @10:04PM (#24004954)
I know ;-) Hence my lawyer-ish choice of wording (default, module). HAProxy has some real nice features, especially the 1.8+ versions. We used to have configuration management tooling reconfigure and reload it, later on it get hot-reloads which was nice and then it got consul support so we could just feed consul and it all would work like magic. Love it.

My point was more about logging something straight in to a RDBMS wasn't much of a default at any point in time. Earlier on it was too expensive, and later on better systems came along. Some systems have built in text analysis and time series data specifics, but why would you worry about those when you have ElasticSearch and Kibana for most generic setups. Even before that you have syslog and a lot of log parsing libraries that worked great (well, unless you used windows event logs which has pros and a lot of cons).

Re:Migrating a 40TB SQL Server Database by polskibus on Thursday July 30, 2020 @03:47PM (#24002186)
How would you 'do it right'?
Re:Migrating a 40TB SQL Server Database by blyat on Thursday July 30, 2020 @04:44PM (#24002649)
I've only done a few 30+TB moves, largest being 50TB which had similar table structure - one table per machine holding calibration readings that were constantly streamed in from a MUCH beefier RabbitMQ instance. Old CPU, not a ton of cores, spinning disks, etc. Same base problem. I think the best thing to do here would be change the order of some things around.

1. Buy the hardware first with blazing drives and roaring CPUs and get it stood up before you start trying to change your schema on a potato

2. Do his last step now: set up an AG and let SQL Server do it's thing

3. Now go start planning your ETL/schema changes and writing scripts while you wait 1-3 days (or in my case 10 as we had to suspend during business hours) for data to migrate.

4. Fail-over and promote and start collecting data on your superbox

5. If the world didn't explode, you do the same thing at your other DC

6. Now, if you absolutely must, apply and test all your schema changes in production instead of dev first but enjoy the fact that those changes are exponentially faster!

You could also use log shipping, but with those restore times you'd have data loss I think. Haven't done that in years - I've been lucky enough to only have to deal with projects where we shutdown, restore, and do a full downtime migration. So much nicer...

Re:Migrating a 40TB SQL Server Database by idlewords on Thursday July 30, 2020 @07:32PM (#24003972)
Having step 1 of your solution be "eliminate the hardware constraints that made this job painful" is kind of a cheat. We can all do a better job on any problem if we lift those constraints.
Re:Migrating a 40TB SQL Server Database by LadyCailin on Friday July 31, 2020 @04:33AM (#24006827)
Hardware is way cheaper than 11 months salary + lost opportunity cost.
Re:Migrating a 40TB SQL Server Database by idlewords on Friday July 31, 2020 @04:55PM (#24013952)
I think we all agree on that, but the question was not whether this was an efficiently managed migration. I think we can assume OP made a similar argument up the chain (he got them to add SSD storage, at least).
Re:Migrating a 40TB SQL Server Database by oneplane on Thursday July 30, 2020 @05:44PM (#24003198)
We did it by removing all non first-party access and turning the only access into a single-owner API service. Then we started partitioning off certain calls in to a cache, i.e. when someone decides they want all possible header combinations over a time period they don't get instant results but instead get a job ID and they can either get an event trigger when the results are in or they can poll for status if that is what they like.

Next, we get the cache to write to ElasticSearch and on lookup it would first check if memcache has a pointer to ElasticSearch already and if not it would spawn the job, copy the input set to ES, run the query there and add a pointer in memcache.

This meant that in practise you'd retain the same functionality you had before while not having a hard dependency on the backend.

Next, we scaled op the API service and the cache service to a very high number and started querying for time ranges that were known to not have pointers in memcache. Depending on the amount of spot instances we could get for the price we wanted and the saturation of the 10GbE DirectConnect we could do up to 400MiB/s, 29TiB took us about 3 days because the DirectConnect was also used to other traffic that had a higher priority and the back pressure system would reduce the API request count accordingly (using Istio).

In the end the users had only two changes:

1. No more 'talking to the database', you have to use the API which started out rather restriced

2. Some analysis takes a little longer during migration due to the SQL-ES copy action; after the MSSQL stuff was all gone the queries were much faster than before