Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate with Sql Azure and Sharding

Does anyone have any good sources of information of using NHibernate with Sql Azure with the implications of sharding (because of the 10gb cap)? I know there are posts on the internet that reference a sharding project for NH but they are from 3rd quarter 09 and I haven't found any much more relevant on google.

Related does anyone have information about manually implementing sharding if the sharding project isn't viable to use yet? Would it just be as simple as creating a session factory for each shard and keep a collection of factories? That seems like it would be problematic reproducing the ISession calls through each factory however I suppose it could be achieved by passing operations as Funcs that get invoked on the ISession from each factory but seems more like the wrong path to be going down.

like image 531
Chris Marisic Avatar asked Mar 02 '10 15:03

Chris Marisic


People also ask

Does Azure SQL support sharding?

A set of SQL databases is hosted on Azure using sharding architecture. The Elastic Database client library is used to manage a shard set.

Which Azure SQL Database feature uses sharding?

To easily scale out databases on Azure SQL Database, use a shard map manager. The shard map manager is a special database that maintains global mapping information about all shards (databases) in a shard set. The metadata allows an application to connect to the correct database based upon the value of the sharding key.

Is Azure SQL horizontally scalable?

Azure SQL Database supports two types of scaling: Vertical scaling where you can scale up or down the database by adding more compute power. Horizontal scaling where you can add more databases and to shard your data into multiple database nodes.

Is Azure SQL faster than on premise?

This is part of performance testing Azure vs On Premise. Running one transaction with 400 changes runs faster in Azure than on Prem. But running 400 transactions with one change or 10 changes is slower in Azure.


1 Answers

I wrote a proof of concept about a month ago using NHibernate on SQLAzure/Sharding. As you've pointed out, there are aspects that just do not feel right about it. Until the NH support has evolved, you may have to try a few things to find out what works best for you. I can tell you a general flow of how it worked for us.

We implemented a simple sharding strategy factory that provides strategies that decide which shard to place you in based on our needs. Your needs may vary here. The key is creating strategies that process, merge and order your query results. From there, session creation and usage is all the same as any other session usage, which is highly desirable.

EDIT: I know this post by Ayende is a few months old, but it's exactly how we implemented it and it works. The rumor is better support in nHibernate will be coming.

like image 166
Kilhoffer Avatar answered Oct 22 '22 07:10

Kilhoffer