Sharding databases for performance
There are a few scenarios where it may be appropriate to partition data horizontally across several servers, with performance being the most obvious reason. The concept itself is known as sharding and is used in many large scale applications, such as Facebook.
In this recipe, we'll show you how to use NHibernate.Shards
to split our data set across three databases.
Getting ready
In SQL Server, create three new, blank databases named Shard1, Shard2, and Shard3. Complete the Getting Ready instructions at the beginning of Chapter 4, Queries.
How to do it...
- Add a reference to
NHibernate.Shards
using NuGet Package Manager Console:Install-Package NHibernate.Shards –Project QueryRecipes
- Add a new folder named
Sharding
Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.