MSSQL Performance

How to transfer 3 million of rows or 1.5GB of data per one minute

Saulius Baškevičius 1 min read

Recently, I tackled a significant challenge – improving an ETL process between MS SQL servers to transfer nearly a billion rows daily in real-time. This meant that whenever the master SQL server received new rows, they needed to be instantly transferred to 8 satellite MS SQL servers.

Infrastructure Setup

The backend infrastructure consists of MS SQL servers, each equipped with:

  • Intel Xeon E5-2690 2.9GHz 8-core CPU
  • 384GB of memory
  • Enterprise SSD storage with separate RAID10 for data, index, and log files
  • TempDB running on RAM drive (in memory)
  • Main database tables separated into file-groups by day

Initial State

Before optimization, the system achieved approximately 800,000 rows per minute throughput. With daily increasing data volumes, this performance was insufficient. The initial method used a stored procedure to transfer rows in chunks of up to 1,000,000 rows to satellite servers.

Optimization Solution

To improve throughput, we implemented two key changes:

  1. Replaced the stored procedure with an SSIS package, as SSIS excels at ETL processes
  2. Implemented multi-threading

SSIS package Data Flow diagram showing Balance Data Distributor

SSIS package Data Flow

SSIS Implementation

The most crucial component was the Balanced Data Distributor (https://www.microsoft.com/en-us/download/details.aspx?id=30147). This component enabled the SSIS package to write to a single table using 4 separate threads. The performance improvements were significant:

  • Single thread without the distributor: ~1,000,000 rows per minute
  • Each additional thread: +500,000 rows per minute
  • Final throughput: up to 3 million rows (1.5GB of data) per minute in real-time from master to satellite servers

This solution provides a highly efficient method for moving large volumes of data between servers in real-time. The implementation can be completed relatively quickly while maintaining excellent performance characteristics.

Feel free to reach out for additional implementation details.

Comments on the original post

Ilan, 2016-10-27

Nice! Thanks Sauliau.

Dung Dinh, 2016-11-05

Nice! How does DefaultBufferMaxSize setting impact? For example, we change 10MB to 1GB then timing process will be decrease?

Saulius, 2016-11-08

Good point! At the moment it’s left as a default value, but this will be reviewed and tested latter.

Carlo, 2016-11-11

What did you use to get the tempdb into ram?

Saulius, 2016-11-12

Currently we are using Primo Ramdisk.

Melih, 2016-11-28

Today. I learned a new knowledge from you. Thanks.

Credo Junior, 2016-12-19

Thanks Saulius. I aspire to become a Senior database administrator, and even if i still a very junior for the moment. I’ve thought to read this article anyway hoping it will bring me something and it was eventually the case, although i don’t deeply understand it. So thanks for that. I really need advices to well handle my career. So i’ll be very glad if i sometimes get some of you. Good job, thanks again.

Roberto, 2017-01-12

Información excelent

Rishi D, 2017-01-19

Good article. Is the Balanced data distributor component available for free or is it made available via some third party?

rick willemain, 2017-01-19

Question please, this shows 4 destination connections, and each branch will yield thru 500k rows per minute (rpm), or are you saying the 0 branch runs at 1000K rpm, and 1, 2, 3 run at a steady 500k rpm to their destinations ? You say output is distributed to 8 target servers from a single source server, via a local connect abd ssis is running on that source server ?

Saulius, 2017-01-19

The component is free and you may download it directly from microsoft site: https://www.microsoft.com/en-us/download/details.aspx?id=30147 AFAIK the component included in the standard components list starting from SQL2016

Saulius, 2017-01-19

Balance data distributor (BDT) split incoming amount of rows in equal chunks to all destinations. This means, when running with 4 destinations the data goes at the same speed to all branches. Of course, if you will compare one destination which may run at 1000K rpm without BDT to one of 4 destinations branch 0 for example, which will run at around 500-800K rpm, this will look like BDT slowing down the speed. But since with BDT we are running with 4 destinations, so we run at 4 times 500-800K rpm and this are ways faster compare to single destination. In other words, we are able to multi thread insert to the same table. SSIS I’m running stored on completely separate server, this means non on local (source) or abd destination servers.

Facing something like this?

Get in touch and we will find a solution.