Monday, December 20, 2010

Speed ServiceContext.SaveChanges() Execution with the SaveChangesOptions.Batch Argument

My (@rogerjenn) Adding Trace, Event, Counter and Error Logging to the OakLeaf Systems Azure Table Services Sample Project of 11/22/2010 described a set of load tests of a  Windows Azure Table Services demo app. The following table from the above article described the execution time in seconds for Count Customers, Delete All Customers, Create Customers, and Update Customers operations with three deployment configurations and the default ServiceContext.SaveChanges(SavechangesOptions.None) argument:

Table 1: Default execution times for 91 Customers records (seconds)

Fabric/ Storage

Display Default

Count Customers

Delete All Customers

Create
Customers

Update Customers 1

Update Customers 2

Dev/Dev

0.237

0.051

2.154

2.107

2.517

1.985

Dev/Prod

1.291

0.188

14.281

30.146

31.219

33.909

Prod/Prod

0.045

0.270

3.987

19.477

21.325

20.191

  • Dev/Dev = Development Fabric and Development Storage
  • Dev/Prod = Development Fabric and Production Storage
  • Prod/Prod = Production Fabric and Production Storage (fully deployed, single instance)

DELETE, INSERT and UPDATE load (POST) operations against the underlying Windows Azure Customer table were taking much longer to complete than expected when deployed to the Production Fabric, which has a high-speed (local) connection to Windows Azure storage.

Executing the ServiceContext.SaveChanges() method with the SavechangesOptions.Batch option resulted in substantially improved performance, as shown here:

Table 2: Batch execution times for 91 Customers records (seconds)

Fabric/ Storage

Display Default

Count Customers

Delete All Customers

Create
Customers

Update Customers 1

Update Customers 2

Dev/Dev

0.240

0.053

0.534

0.289

0.556

0.591

Dev/Prod

1.287

0.192

2.447

3.191

4.709

4.598

Prod/Prod

0.032

0.195

1.013

1.019

0.763

0.722

Performance improvement ranges from about 4:1 for deleting 91 customer entities to almost 30:1 for bulk UPDATE operations on these entities.

The OakLeaf Systems Azure Table Services Sample Project at http://oakleaf.cloudapp.net has been updated with a Batch Updates check box so users can compare batch versus conventional update operations:

image

Source code for the SampleWebCloudService.sln project will be uploaded to my Windows Live Skydrive account shortly. Stay tuned for an update.

0 comments: