Skip to main content

SQL Server Replication

I had an interesting problem come up recently that I thought I would share. We had an immediate need to create a support site for customer service to support our stores directly.


Our requirements:
  • Cannot use production for queries

  • Cannot change schema

  • Development must be minimal

  • No new equipment will be purchased

  • Data must be able to be changed on either server and distributed to the other server near real time.
Normally I would want to crucify the people that came up with these requirements, but we did it to ourselves. Knowing we couldn't ask for more equipment, we didn't have time to develop a solution, and the developers would scream if we changed production schema, we had to try to solve the problem this way.


So we started exploring options:

Log Shipping - Quick and easy with only one fatal problem for us. We need the data to be near real time *snap*.

Data Mirroring - We cannot buy new equipment *snap*

Custom ETL - The best option IF we could spend some time doing development but we could not *snap*



And then we came to replication:

At first this seemed like a no brainer...transactional replication yay! But when we dove a little deeper we found that this would create unique identifier columns on every table. Doh! So we looked for another form of replication: merge, no; snapshot, nope.


So we thought we were at an impass. No solution. But then we came across a little known form of replication - Peer to Peer. Aha!


If you read about peer to peer replication you will see the main benefits being load distribution. Here are the benefits we found with it:
  • No schema changes: This is big. All other forms of replication require unique identifiers.

  • Near real time

  • No development

  • No 3rd party software

  • Very easy to implement

So the moral of the story is: Spend some time researching alternate solutions. What you already know will not fit every problem.

Find out more about peer to peer replication here.

Comments

Popular posts from this blog

Why fragmentation occurs and how to avoid/fix it.

Let's suppose you have this table: We have made last name the primary key in this table Now lets import some rows into the table and check the fragmentation Notice the fragmentation at 96.48% and all we did was one import of 16426 records. So now we have several questions: How bad is this? Fragmentation causes SQL Server to skip around to read data from your tables. For a one time read on a small table this is virtually meaningless. In a job that may need to read millions of records, this could tear apart your performance. Ok this is bad. How did it happen? The primary key on a table is clustered. This means the data will be stored according to the primary key. In our case, last name. When data doesn't come in the same way you store it (i.e. Customer names are not coming in alphabetically, but rather randomly) SQL Server must constantly split pages to store the data correctly. This causes data to be "fragmented" into multiple areas of the disk instead of one continuou...

SQL Server ETL for Data Lineage

What is data lineage? Ok let us suppose you built a wonderful database with loads of data coming from source files from your vendors, your own AS400, and different departments of your own organization. All of this data has been imported into 200 tables in this database producing a plethera of information that is used for reporting purposes. One day a department head comes to you and says, "I think this number here on this report is wrong. Where did you get it from?" Do you escort that person to the computer room and show him/her your server? No, I didn't think so. So how do you come up with where the information came from? Likely you find a data load expert in your IT department and have him/her spend the next several minutes/hours/days rummaging through stored procedures, ssis packages, dts packages, custom applications, etc trying to find this information. However, if you had this: you could simply pull up the history of how that data came to be loaded and point. How us...

DBA 101 - Connecting to an unresponsive SQL Server

I will attempt, over the course of many blogs, to tackle troubleshooting for a beginning to intermediate DBA. Troubleshooting is like an octopus with a hundred arms. There is no silver bullet but at least I can give you some tools for your belt to help determine the next steps in troubleshooting many common problems that you will see. So where do we begin? I don't know. Let's dive in and see where we end up. Problem - Nobody can connect to the SQL Server and it is not responding to any requests. Wow this seems like an impossible problem and is in reality two problems. Lets address the most critical problem which is you cannot even address why the SQL Server isn't responding to requests because nobody can connect to it to see what is going on. A weak solution - Often times an inexperienced DBA or what is often called an "accidental" DBA would pull the plug on the server, wait ten seconds, and then power it back on. Now this isn't the worst possible solution.....