Databases Reference
In-Depth Information
Table 9-2. Technologies Used to Build the Shard
Technology
Requirement
Comment
Configuration file
1
The configuration file stores the list of databases that make up the shard,
keeping the shard definition transparent to the code.
Multithreading
2
Using the TPL lets the library spawn multiple threads to use computers
with multiple CPUs, allowing parallel execution of SQL statements and
thus improving performance.
SqlClient
Using SqlCommand objects allows the shard to connect to both SQL
Database and SQL Server databases.
3
Caching
4
Caching lets the library store results temporarily to avoid unnecessary
roundtrips.
Breadcrumbs
5
The library creates a virtual column for each record returned that stores
a breadcrumb identifying the database a record it came from, which
supports selective writes.
DataTable
The library returns a DataTable object that can be bound to objects easily
and serve as a data source.
6
Designing the Shard Library Object
The library accepts requests directly from client applications and can be viewed as an API. Note that you're using
extension methods to make this API blend in with the existing SqlCommand class; this in turn minimizes the amount of
code on the client and makes the application easier to read.
Figure 9-1 shows where the library fits in a typical application design. It also shows how the library hides the
complexity of parallel processing and caching from the client application. Finally, the shard library abstracts the client
code from dealing directly with multiple databases.
Figure 9-1. Shard library object diagram
 
 
Search WWH ::




Custom Search