Showing posts with label Azure Storage Analytics. Show all posts
Showing posts with label Azure Storage Analytics. Show all posts

Monday, February 06, 2012

Introducing Microsoft Research’s Excel Cloud Data Analytics

Microsoft Research’s eXtreme Computing Group (XCG) introduced Excel Cloud Data Analytics—then called Excel DataScope—at its TechFest 2011 conference in Redmond, WA on 3/8/2011. According to XCG’s Excel DataScope page:

Cloud-Scale Data Analytics from Excel

imageFrom the familiar interface of Microsoft Excel, Excel DataScope enables researchers to accelerate data-driven decision making. It offers data analytics, machine learning, and information visualization by using Windows Azure for data and compute-intensive tasks. Its powerful analysis techniques are applicable to any type of data, ranging from web analytics to survey, environmental, or social data.

Complex Data Analytics via Familiar Excel Interface

Excel DataScope

We are beginning to see a new class of decision makers who are very comfortable with a variety of diverse data sources and an equally diverse variety of analytical tools that they use to manipulate data sets to uncover a signal and extract new insights. These decision makers want to invoke complex models, large-scale machine learning, and data analytics algorithms over their data collection by using familiar application, such as Microsoft Excel. They also want access to extremely large data collections that live in the cloud, to sample or extract subsets for analysis or to mash up with their local data sets.

Seamless Access to Cloud Resources on Windows Azure

imageExcel DataScope is a cloud service that enables data scientists to take advantage of the resources of the cloud, via Windows Azure, to explore their largest data sets from familiar client applications. Our project introduces an add-in for Microsoft Excel that creates a research ribbon that provides the average Excel user seamless access to compute and storage on Windows Azure. From Excel, the user can share their data with collaborators around the world, discover and download related data sets, or sample from extremely large (terabyte sized) data sets in the cloud. The Excel research ribbon also presents the user with new data analytics and machine learning algorithms, the execution of which transparently takes place on Windows Azure by using dozens or possibly hundreds of CPU cores.

Extensible Analytics Library

The Excel DataScope analytics library is designed to be extensible and comes with algorithms to perform basic transforms such as selection, filtering, and value replacement, as well as algorithms that enable it to identify hidden associations in data, forecast time series data, discover similarities in data, categorize records, and detect anomalies.

Excel DataScope Features
  • Users can upload Excel spreadsheets to the cloud, along with metadata to facilitate discovery, or search for and download spreadsheets of interest.
  • Users can sample from extremely large data sets in the cloud and extract a subset of the data into Excel for inspection and manipulation.
  • An extensible library of data analytics and machine learning algorithms implemented on Windows Azure allows Excel users to extract insight from their data.
  • Users can select an analysis technique or model from our Excel DataScope research ribbon and request remote processing. Our runtime service in Windows Azure will scale out the processing, by using possibly hundreds of CPU cores to perform the analysis.
  • Users can select a local application for remote execution in the cloud against cloud scale data with a few mouse clicks, effectively allowing them to move the compute to the data.
  • We can create visualizations of the analysis output and we provide the users with an application to analyze the results, pivoting on select attributes.
Analytics Algorithms Performed in the Cloud

Excel DataScope is a technology ramp between Excel on the user’s client machine, the resources that are available in the cloud, and a new class of analytics algorithms that are being implemented in the cloud. An Excel user can simply select an analytics algorithm from the Excel DataScope Research Ribbon without concern for how to move their data to the cloud, how to start up virtual machines in the cloud, or how to scale out the execution of their selected algorithm in the cloud. They simply focus on exploring their data by using a familiar client application.

Excel DataScope is an ongoing research and development project. We envision a future in which a model developer can publish their latest data analysis algorithm or machine learning model to the cloud and within minutes Excel users around the world can discover it within their Excel Research Ribbon and begin using it to explore their data collection.

People:

Roger Barga Roger Barga

Jaliya Ekanayake Jaliya Ekanayake

Jared Jackson Jared Jackson

Wei LuWei Lu

Downloadable Excel CDA Binaries and Source Code

Microsoft Research released a downloadable open-source version of Excel CDA for non-commercial use under a Microsoft Research license (MSR-LA) on 11/29/2011:

Excel Cloud Data Analytics is a Microsoft Excel add-in that enables users to execute a variety of data-centric tasks on Windows Azure through a custom Ribbon in Excel. This add-in can be used to connect to data stored in the Windows Azure cloud and can be extended to connect to a variety of other data sources. It also provides a general framework in which the user can create data-analytics methods and run them in Windows Azure.

imageThe current code base supports the execution in Windows Azure via built-in access to Daytona, an iterative MapReduce runtime for Windows Azure. Using Excel Cloud Data Analytics, users can upload data to Windows Azure, select and run registered data-analysis algorithms in the cloud through Windows Azure, monitor the execution of the data analysis, and retrieve results for display or further processing.

imageThe source code consists of a Visual Studio 2010 ExcelCloudDataAnalyticsRibbon.sln solution, which requires .NET Framework 4.0 and Visual Studio Tools for Office (VSTO.) The source code lets you customize Cloud Data Analytics ribbon, shown here without having installed support for Project “Daytona” or specifying a local workgroup or Windows Azure Storage account during installation:

image

Note: I missed the availability of this download because I was expecting it to be announced on XCG’s Excel DataScope page but it wasn’t. To find the download independently, you must click the Downloads button at the top right of the page, and then click the E link in the Filter by Name navigation group:

image


Project “Daytona” for Scheduling MapReduce Functions in Windows Azure

From the XCG’s Daytona Page:

Iterative MapReduce on Windows Azure

Daytona

Microsoft has developed an iterative MapReduce runtime for Windows Azure, code-named "Daytona." Project Daytona is designed to support a wide class of data analytics and machine learning algorithms. It can scale out to hundreds of server cores for analysis of distributed data.

Project Daytona was developed as part of the eXtreme Computing Group’s Cloud Research Engagement Initiative, and made its debut at the Microsoft Research Faculty Summit. One of the most common requests we have received from the community of researchers in our program is for a data analysis and processing framework. Increasingly, researchers in a wide range of domains—such as healthcare, education, and environmental science—have large and growing data collections and they need simple tools to help them find signals in their data and uncover insights. We are making the Project Daytona MapReduce Runtime for Windows Azure download freely available, along with sample codes and instructional materials that researchers can use to set up their own large-scale, cloud data-analysis service on Windows Azure. In addition, we will continue to improve and enhance Project Daytona (periodically making new versions available) and support our community of users.

Overview

imageThe project code-named Daytona is built on Windows Azure and employs the available Windows Azure compute and data services to offer a scalable and high-performance system for data analytics. To deploy and use Project Daytona, you need to follow these simple steps:

  • Develop your data analytics algorithm(s). Project Daytona enables a data analytics or machine learning algorithm to be authored as a set of Map and Reduce tasks, without in-depth knowledge of distributed computing or software development on Windows Azure. To get you up and running quickly, the release package includes sample data analysis algorithms to provide you with examples for building a data analysis library, as well as a developer guide with step-by-step instructions for authoring new algorithms, and source code for a sample client application for integrating your existing applications with Project Daytona on Windows Azure.
  • Upload your data and library of data analytics routines into Windows Azure. Windows Azure blob storage provides reliable, scalable, easy-to-use storage for your data and library of analysis routines. Our documentation clearly outlines the steps for doing this.
  • Deploy the Daytona runtime to Windows Azure. By following the steps in the deployment guide, deploy the Daytona runtime to your Windows Azure account. You can configure the number of virtual machines for the deployment, specify and configure the storage account on Windows Azure for the analysis results, and then start and verify that the service is operational. Project Daytona enables you to use as many or as few virtual machines as you wish. When you are finished with your data analysis, you can follow the steps in the deployment guide to shut down the running instances and tear down your deployment.
  • Launch data analytics algorithms. The Daytona release package provides you with source code for a simple client application that you can use to select and launch a data analytics model against a data set on Project Daytona. This client application is merely one example of how to integrate Project Daytona with a client application—perhaps one already in use in your lab—or you can author a Windows Azure service interface for job submission and monitoring.

Properties of Project DaytonaProject Daytona will automatically deploy the iterative MapReduce runtime to all of the Windows Azure virtual machines (VMs) in the deployment, sub-dividing the data into smaller chunks so that they can be processed (the “map” function of the algorithm) in parallel. Eventually, it recombines the processed data into the final solution (the “reduce” function of the algorithm). Windows Azure storage serves as the source for the data that is being analyzed and as the output destination for the end results. Once the analytics algorithm has completed, you can retrieve the output from Windows Azure storage or continue processing the output by using other analytics model(s). Project Daytona demonstrates the power of taking advantage of Windows Azure cloud services for application design.

Key Properties

Project Daytona features the following key properties.

  1. imageDesigned for the cloud, specifically for Windows Azure. Virtual machines, irrespective of infrastructure as a service (IaaS) or platform as a service (PaaS), introduce unique challenges and architectural tradeoffs for implementing a scale-out computation framework such as Project Daytona. Out of these, the most crucial are network communications between virtual machines (VMs) and the non-persistent disks of VMs. We have tuned the scheduling, network communications scheduling, and the fault tolerance logic of Project Daytona to suit this situation.
  2. Designed for cloud storage services. We have defined a streaming based, data-access layer for cloud data sources (currently, Windows Azure blob storage, but we will extend to others), which can partition data dynamically and support parallel reads. Intermediate data can reside in memory or in local non-persistent disks with backups in blobs, so that Project Daytona can consume data with minimum overheads and with the ability to recover from failures. We use the automatic persistence and replication that is provided by the Windows Azure storage services and, therefore, do not require a distributed file system.
  3. Horizontally scalable and elastic. Computations in Project Daytona are performed in parallel, so to scale a large data-analytics computation, you can add more virtual machines to the deployment and Project Daytona will take care of the rest. By using Project Daytona on Windows Azure, you can instantly provision as much or as little capacity as you need to perform data-intensive tasks for applications such as data mining, machine learning, financial analysis, or data analytics. Project Daytona lets you focus on your data exploration; without having to worry about acquiring compute capacity or time-consuming hardware setup and management.

  4. Optimized for data analytics. We designed Project Daytona with performance of data analytics in mind. Algorithms in data analytics and machine learning are often iterative and produce a sequence of answers of improving quality until they converge. Project Daytona provides support for iterative computations in its core runtime; it caches data between iterations to reduce communication overheads, different scheduling and relaxed fault tolerance mechanisms, and a natural programming API to author iterative algorithms.

Use Cases

There are a number of use cases for Project Daytona, such as for data analysis, machine learning, financial analysis, text processing, indexing, and search. Almost any application that involves data manipulation and analysis can take advantage of Project Daytona to scale out processing on Windows Azure.

We are actively exploring a specific use case for Project Daytona, as outlined below.

Data analytics as a service on Windows AzureData analytics as a service on Windows Azure, accessible to a host of clients, is about turning utility cloud computing into a service model for data analytics. In our view, this service is not limited to a single data collection or set of analytics, but the ability to upload data and select from an extensible library of models for data analysis. Powered by Project Daytona, the service will automatically scale out the data and analytics model across a pool of Windows Azure VMs without the overhead that is usually associated with typical business intelligence (BI) and data analysis projects. The analytic application possibilities are limited only by your imagination.

We have implemented one such application, which we call Excel DataScope. From the familiar interface of Microsoft Excel, Excel DataScope enables researchers to accelerate data-driven decision making. Our DataScope analytics service offers a library of data analytics and machine learning models, such as clustering, outlier detection, classification, and machine learning, along with information visualization—all implemented on Project Daytona. Users can upload data in their Excel spreadsheet to the DataScope service or select a data set already in the cloud, and then select an analysis model from our Excel DataScope research ribbon to run against the selected data. Project Daytona will scale out the model processing by using possibly hundreds of CPU cores to perform the analysis. The results can be returned to the Excel client or remain in the cloud for further processing and/or visualization. The algorithms and analysis techniques are applicable to any type of data, ranging from web analytics to survey, environmental, or social data.

  • See Overview for information about what is included in the release package.
Related Work

While Daytona is a novel Iterative MapReduce runtime, designed for Microsoft Windows Azure and optimized for data analytics, the concepts in Daytona have several related works in the literature. Followings are some of the notable ones.

imageMapReduce[1] and Dryad[2] introduced simplified programming abstractions for large scale data processing on commodity clusters. Daytona adopts this strategy by providing a simple programming model for large scale data analytics based on MapReduce. Iterative MapReduce for distributed memory architectures was first introduced by the Twister project [3-4] and the Twister4Azure project [5-6] introduced iterative MapReduce on Windows Azure. HaLoop [7] and i-MapReduce[8] are related research efforts which optimize iterative MapReduce computations. Similar to other iterative MapReduce runtimes, Daytona also provides additional optimizations to enhance the performance of iterative computations on Windows Azure.

[1] J. Dean and S. Ghemawat, "MapReduce: simplified data processing on large clusters," Commun. ACM, vol. 51, pp. 107-113, 2008.

[2] M. Isard, M. Budiu, Y. Yu, A. Birrell, and D. Fetterly, "Dryad: distributed data-parallel programs from sequential building blocks," presented at the Proceedings of the 2nd ACM SIGOPS/EuroSys European Conference on Computer Systems 2007, Lisbon, Portugal, 2007.

[3] Twister: Iterative MapReduce

[4] Jaliya Ekanayake, Hui Li, Bingjing Zhang, Thilina Gunarathne, Seung-Hee Bae, Judy Qiu, and Geoffrey Fox, “ Twister: a runtime for iterative MapReduce,”oceedings of the 19th ACM International Symposium on High Performance Distributed Computing (HPDC '10). ACM, New York, NY, USA, 810-818. DOI=10.1145/1851476.1851593

[5] Twister 4 Azure : A Decentralized Iterative MapReduce Runtime For Windows Azure Cloud

[6] Thilina Gunarathne, BingJing Zang, Tak-Lon Wu and Judy Qiu. Portable Parallel Programming on Cloud and HPC: Scientific Applications of Twister4Azure, In Proceedings of the forth IEEE/ACM International Conference on Utility and Cloud Computing (UCC 2011) , Melbourne, Australia. Dec 2011.

[7] Yingyi Bu, Bill Howe, Magdalena Balazinska, and Michael D. Ernst. 2010. HaLoop: efficient iterative data processing on large clusters. Proc. VLDB Endow. 3, 1-2 (September 2010), 285-296.

[8] Yanfeng Zhang; Qinxin Gao; Lixin Gao; Cuirong Wang; , "iMapReduce: A Distributed Computing Framework for Iterative Computation," Parallel and Distributed Processing Workshops and Phd Forum (IPDPSW), 2011 IEEE International Symposium on , vol., no., pp.1112-1121, 16-20 May 2011, doi: 10.1109/IPDPS.2011.260

What’s Next for Project Daytona?

Project Daytona is part of an active research and development project in the eXtreme Computing Group of Microsoft Research.

Open dataThe current release of Project Daytona is a research technology preview (RTP). We are still tuning the performance of Project Daytona and adding new functionality, and we will fix any software defects that are identified (see our email link below).

Our research on Project Daytona and its use for cloud data analytics is far from complete. In the summer of 2011 three PhD candidates joined our group, Romulo Goncalves (CWI), Atilla Balkir (University of Chicago), and Chen Jin (Northwestern University), to work with our team on data streaming support in Project Daytona, optimizations to the core runtime, support for incremental processing, and data services to minimize latency and data movement. We look forward to sharing these results in our technical papers and improved versions of Project Daytona that will be released in Spring 2012.

Please report any issues you encounter when using Project Daytona to xcgngage@microsoft.com, or contact Roger Barga with suggestion for improvements and/or new features. …

Articles and Papers

Team members are the same as those for Excel CDA.

Excel CDA interacts with Project Daytona via the Scheduler Bridge:

image

(Graphic from Microsoft Research’s Excel Cloud Data Analytics (CDA) Design Document.docx.)

Following are the *.docx documentation files included with the release:

  • Excel Cloud Data Analytics (CDA) Design Document
  • Excel Cloud Data Analytics (CDA) Developer Guide
  • Excel Cloud Data Analytics (CDA) Installation Guide
  • Excel Cloud Data Analytics (CDA) User Guide
Downloadable Project Daytona MapReduce Runtime for Windows Azure CTP 1.2 Refresh

The Project Daytona MapReduce Runtime for Windows Azure replaces the Dryad and DryadLINQ runtimes, which are facing retirement before being widely deployed. From the Project Daytona MapReduce Runtime for Windows Azure download page of 11for the Daytona-CTP-1.2-Refresh:

Microsoft has developed an iterative MapReduce runtime for Windows Azure, code-named Daytona. Project Daytona is designed to support a wide class of data analytics and machine-learning algorithms. It can scale to hundreds of server cores for analysis of distributed data. Project Daytona was developed as part of the eXtreme Computing Group’s Cloud Research Engagement Initiative.

image

(Graphic from the Daytona - Runtime Developer guide documentation.))
News

On July 26, 2011, we released an updated Daytona community technical preview (CTP) that contains fixes that are related to scalability. … Learn more about this release...

image

(Graphic from Microsoft TechFest 2011 presentation.)
Overview

Project Daytona on Window Azure is now available, along with a deployment guide, developer and user documentation, and code samples for both data analysis algorithms and client application. This implementation of an iterative MapReduce runtime on Windows Azure allows laboratories, small groups, and individual researchers to use the power of the cloud to analyze data sets on gigabytes or terabytes of data and run large-scale machine learning algorithms on dozens or hundreds of compute cores.

Included in the CTP Refresh (July 26, 2011)

This refresh to the Daytona CTP contains the following enhancements:

  1. Updated
    1. Binaries
    2. Default Medium package
    3. Hosting project source
    4. API help reference file (CHM)
  2. Content not updated (remains same from previous package)
    1. Documentation
    2. Samples for Kmeans, Outlier, Wordcount

Included in the CTP Release (July 18, 2011)

This CTP release consists of a ZIP file (Daytona_on_Windows_Azure.zip) that includes our Windows Azure cloud service installation package along with the documentation and sample codes.

  • The Deployment Package folder contains a package to be deployed on your Windows Azure account, a configuration file for setting up your account, and a guide that offers step-by-step instructions to set up Project Daytona on your Window Azure service. This package also contains the user guide that describes the user interface for launching data analytics jobs on Project Daytona from a sample client application.
  • The Samples folder contains source code for sample data analytics algorithms written for Project Daytona as examples, along with source code for a sample client application to invoke data analytics algorithms on Project Daytona. The distribution also includes a developer guide for authoring new data analytics algorithms for Project Daytona, along with user guides for both the Daytona iterative MapReduce runtime and client application.

About Project Daytona

The project code-named Daytona is part of an active research and development project in the eXtreme Computing Group of Microsoft Research. We will continue to tune the performance of Project Daytona and add new functionality, fix any software defects that are identified, and periodically push out new versions.

Please report any issues you encounter in using Project Daytona to XCG Engagement or contact Roger Barga with suggestion for improvements and/or new features.

The download page doesn’t report any updates to the CTP 1.2 Refresh of 11/28/2012. Following are the *.pdf documentation files included with the release:

  • Daytona - Client Application User Guide
  • Daytona - Deployment guide
  • Daytona - K-means algorithm user guide
  • Daytona - Outlier Detection algorithm user guide
  • Daytona - Runtime Developer guide
  • Daytona API documentation Help file (pictured below)
  • Daytona API documentation chw file

image

Note: Right-click the Daytona API documentation.chm file, choose properties, and click the Unblock button to activate the help files before use.

imageMy (@rogerjenn) Windows Azure and Cloud Computing Posts for 11/21/2011+ post, updated 11/24/2011, (scroll up) covered the November 2011 Daytona API release in detail.


Relationship of Excel CDA to Apache Hadoop on Windows Azure and SQL Azure Labs’ Codenames “Social Analytics” and “Cloud Numerics”

Excel CDA is an alternative to using Apache Hadoop on Windows Azure for parallel processing of MapReduce functions. Both use Windows Azure storage for input data and MapReduce implementations for data processing and provide an Excel add-in for data analysis. (Hadoop on Azure provides a Hive add-in.) Hadoop on Azure uses Windows HPC clusters while Excel CDA employs Windows Azure Worker roles for scheduling. Hadoop on Azure offers a UI for setting parameter values for sample MapReduce applications. Both offer a WordCount MapReduce example. The Hadoop on Azure CTP provides small to large HTC clusters on Windows Azure without charging your credit card. You must pay for Daytona resources you deploy to Windows Azure.

Excel CDA shares some features in common with other recent big-data incentives from SQL Azure Labs. For example, Codename “Cloud Numerics” also requires C# programming for running matrix operations (other than examples) on HPC clusters you upload to Windows Azure. Like Excel CDA, “Cloud Numerics” makes you pay for the resources you consume. Cloud Numerics works primarily with dense numeric matrices, while Excel CDA’s MapReduce functions most commonly deal with strings or text documents.

“Social Analytics” performs sentiment analysis primarily on Twitter tweet streams, but also Facebook posts and StackOverflow questions but has limited data analysis features. “Social Analytics” might be a good candidate for supplying data for MapReduce analysis. I wrote a sample Winform client that downloads and analyzes trends in sentiment of tweets about Windows 8:

image

imageIt probably would be a relatively simple task to perform similar operations and use Excel CDA to display the result in Excel worksheets and graphs. The Codename “Data Explorer” posts in the list below describe emulation of the Winform client sample with a “Data Explorer” mashup:

image

The following OakLeaf Systems blog posts (in reverse chronological order) describe Microsoft’s alternative approaches to big-data analytics when this post was written:


Wednesday, January 18, 2012

Adding Missing Rows to a SQL Azure Federation with the SQL Azure Federation Data Migration Wizard v1

My Loading Big Data into Federated SQL Azure Tables with the SQL Azure Federation Data Migration Wizard v1.0 post of 1/12/2012 described a problem uploading part of the data for a federation member database in its “Auto-sharding Larger Data Batches” section near the end. This post describes the process I used to determine which of the 398,000 source rows were missing so I could restart the upload process with data for the correct row. The correct data is that which doesn’t cause a primary key constraint conflict and doesn’t result in any missing rows in the resultset.

Update 1/18/2011 9:30 AM PST: Added another 7,958,995 rows to the WADFederation with SQLAzureFedMW v1.2 to reach about 80% full on members 1 and 2. See end of post.

Update 1/16/2012 9:15 AM PST: Completed an 8-million row upload in 10 hours without errors. “See the Investigating Strange Storage Values Reported by Federation Member Pop Ups” section at the end of the post.

Update 1/14/2012 8:45 AM PST: My initial approach wasn’t successful, but executing a MERGE operation succeeded in replacing the missing rows. See the “Executing a MERGE Command to Add Missing Rows” sections near the end of this post.


Background

The Loading Big Data into Federated SQL Azure Tables with the SQL Azure Federation Data Migration Wizard v1.0 post described initially loading 1,000 rows to the federation root database (AzureDiagnostics1), splitting that database into five additional federation members based on CounterId values of 1 through 6. This was limited to 1,000 rows so as to minimize the time required for partitioning but still deliver a reasonable number of rows (166 or 167) to each partition member. The initial Timestamp value of that rowset, created from a WADPerformanceCountersTable-1000rows.txt tab-delimited text file, was 2011-07-25 10:33:21.9432881.

After creating the six-member federation, I uploaded a second rowset created from a WADPerformanceCountersTable-Page-79.txt file with 398,000 rows of data for the time period that immediately preceded the 1,000 row upload. It’s last timestamp value was 2011-07-25 10:33:21.9432881, the same as that for the 1,000-row rowset. (There are several successive rows with identical Timestamp values.) This addition failed for imagefederation member 4 after adding 50,000 rows.

The reason for adding batches of data in reverse chronological order is that I had previously downloaded approximately 8 GB of Windows Azure diagnostic data in 1-GB increments for bulk loading into an SQL Azure 2008 R2 SP1 database in ascending date order. This database was intended for testing uploads on scale similar to that which might be common for large enterprises. Adding later values assured that primary key constraint conflicts wouldn’t occur.


Determining the Federation Member with Missing Rows

SQLAzureFedMW reported Communication link failure errors for only one of the six federation members but didn’t identify the CounterId for offending member. Therefore, I executed the following query in the SQL Azure Management Portal’s query editor (opened by clicking the New Query button in the page header) to count the number of rows in each member:

USE FEDERATION [WADFederation] ([Id] = n) WITH FILTERING = OFF, RESET
GO

SELECT COUNT(*) FROM WADPerfCounters
GO

where n equaled 1, 2, 3, 4, 5 and 6. This resulted in the following row counts:

CounterId Row Count
1 66,501
2 66,500
3 66,500
4 50,167
5 66,500
6 66,499

The member with CounterId = 4 was the obvious culprit. SQLAzureFedMW adds rows in batches of 10,000, as specified by the -b 10000 parameter of:

image

The first addition contributed 167 rows.


Determining the Starting PartitionKey and RowKey Values

I believed that there would be a significant difference in Timestamp values in the rows that represented the junction of the two data sets, so I issued the following query in the query editing window for the member with Id = 4:

SELECT TOP(170) * FROM WADPerfCounters ORDER BY PartitionKey DESC, RowKey DESC

so as to include several rows of both resultsets in the grid, which appeared as follows:

image

The two selected rows had significant differences in PartitionKey and Timestamp values:

image

This led me to the conclusion that I could use the Timestamp value to insert rows into a new SQL Server table and then delete the first few rows whose PartitionKey and RowKey values overlapped existing values in the federation member.

The query grid truncates decimal fractions of Datetime2, 7 values, which it should not, so I executed the same query in SQL Server Management Studio (SSMS) 2008 R2 SP1:

image

The initial constraint is Timestamp >= 2011-07-24 23:12:33.9906722.

I then executed the following SELECT … INTO query in SSMS to create the source table for SQLAzureFedMW:

SELECT * 
INTO WADPerfCounters4
FROM WADPerfCounters
WHERE CounterId = 4

which inserted 16,336 rows into the new table. 50,167 + 16,336 = 66,503, which is close to the 66,499 to 66,501 rows of the other five members.

Next, I executed

DELETE TOP(16323) FROM WADPerfCounters4

to remove all but a few rows uploaded to the federation member prior to the error.

I right-clicked the WADPerfCounters4 table icon and selected Edit First 200 Rows, which displayed the following:

image

The 20th row (highlighted above) corresponds to the second selected row in the preceding capture. I confirmed that the resultset was correctly ordered by PartitionKey and RowKey values by observing the values uniformly increased by 6. Thus, deleting the first 20 rows and repeating the upload operation should solve the problem.

I selected and deleted the first 20 rows for a row count of 33,667 and repeated the upload process with the 4th federation member selected in the SQL Azure Federation Target page:

image

I was surprised to encounter a primary key constraint conflict after a few seconds:

image

The problem might be due to this limitation noted in SQL Server 2008 R2 Books Online’s DELETE (Transact-SQL) topic:

The rows referenced in the TOP expression used with INSERT, UPDATE, or DELETE are not arranged in any order.


Interim Conclusion

It would probably be easier and safer to simply delete the rows added by the process that failed and then attempt addition of the entire rowset for the individual member.

To do so for this case, I wanted to delete the last 50,000 rows, which should leave the 167 rows added by the first 1,000-row upload to the initial member with the following statement:

USE FEDERATION [WADFederation] (Id = 4) WITH FILTERING = OFF, RESET
GO

DELETE TOP(50000) FROM WADPerfCounters ORDER BY PartitionKey DESC, RowKey DESC
GO

However, DELETE … FROM doesn’t support an ORDER BY clause. Even if it did, the rows deleted might not be those expected because they “are not arranged in any order.”

I then asked the SQL Azure Federations Team for their recommendations for solving this problem.


Executing a MERGE Command to Add Missing Rows

imageUpdate 1/14/2012 8:45 AM PST: Cihan Biyikoglu (@cihangirb) of the SQL Azure Federations team recommended that I try the new MERGE (Transact-SQL) statement to eliminate the conflicts incurred with the preceding procedure. One of the statement’s options is to add new rows from a reference table to an existing federation member that don’t conflict with the member’s existing rows having the same primary key value.

MSDN’s Inserting, Updating, and Deleting Data by Using MERGE topic explains SQL Server 2008 R2 new command as follows:

In SQL Server 2008, you can perform insert, update, or delete operations in a single statement using the MERGE statement. The MERGE statement allows you to join a data source with a target table or view, and then perform multiple actions against the target based on the results of that join. For example, you can use the MERGE statement to perform the following operations:

  • Conditionally insert or update rows in a target table. If the row exists in the target table, update one or more columns; otherwise, insert the data into a new row.

  • Synchronize two tables. Insert, update, or delete rows in a target table based on differences with the source data.

The MERGE syntax consists of five primary clauses:

  • The MERGE clause specifies the table or view that is the target of the insert, update, or delete operations.

  • The USING clause specifies the data source being joined with the target.

  • The ON clause specifies the join conditions that determine where the target and source match.

  • The WHEN clauses (WHEN MATCHED, WHEN NOT MATCHED BY TARGET, and WHEN NOT MATCHED BY SOURCE) specify the actions to take based on the results of the ON clause and any additional search criteria specified in the WHEN clauses.

  • The OUTPUT clause returns a row for each row in the target that is inserted, updated, or deleted.

For complete details on the syntax and rules, see MERGE (Transact-SQL).

This MERGE option requires:

  1. Adding a reference (source) table with the same structure as the federation member (target)
  2. Using SQLAzureFedMW to upload the rows from the original upload’s source table that have matching CounterId values (4)
  3. Executing the appropriate MERGE statement

Creating an Empty WADPerfCounters4 Reference Data Table in WADFederation Member 4

I navigated to federation member 4, opened a new query and then added a WADPerfCounters4 reference table to the member with the following query:

CREATE TABLE [WADPerfCounters4](
    [PartitionKey] [bigint] NOT NULL,
    [RowKey] [varchar](100) NOT NULL,
    [Timestamp] [datetime2](7) NOT NULL,
    [EventTickCount] [bigint] NOT NULL,
    [DeploymentId] [varchar](50) NOT NULL,
    [Role] [varchar](20) NOT NULL,
    [RoleInstance] [varchar](20) NOT NULL,
    [CounterName] [varchar](100) NOT NULL,
    [CounterValue] [decimal](16,8) NOT NULL,
    [CounterId] [int] NOT NULL,
    CONSTRAINT [PK_WADPerfCounters] PRIMARY KEY CLUSTERED
    (
    [PartitionKey] ASC,
    [RowKey] ASC,
    [CounterId] ASC
    )
)

The above is the same query as that of Creating a SQL Azure Federation in the Windows Azure Platform Portal’s step 15 without the FEDERATED ON (Id = CounterID) instruction:

image


Uploading Data to a Reference Table with SQLAzureFedMW v1

I launched SQLAzureFedMigWiz and specified the local AzureDiagnostics database’s WADPerfCounters4 as the Data Source table, which has 66,333 rows:

image

I selected the Id (4 to 5) member as the SQL Azure Federation Target table:

image

Note: The destination table is specified by the name of the source table in all cases.

Here’s the data for the download from the local database:

image

and for the upload:

image

Here are the first few rows and columns of the table in the Portal’s UI:

image


Executing the MERGE Statement

Cihan Biyikoglu provided me with the the following MERGE statement:

MERGE INTO [WADPerfCounters] as target
USING WADPerfCounters4 as source
ON (target.[PartitionKey]=source.[PartitionKey]
    AND target.[RowKey]=source.[RowKey]
    AND target.[CounterId]=source.[CounterId])
WHEN NOT MATCHED BY TARGET THEN
INSERT ([PartitionKey], [RowKey], [Timestamp], [EventTickCount],
    [DeploymentId], [Role], [RoleInstance], [CounterName], [CounterValue],
    [CounterId])
VALUES(source.[PartitionKey], source.[RowKey], source.[Timestamp],
    source.[EventTickCount], source.[DeploymentId], source.[Role],
    source.[RoleInstance], source.[CounterName], source.[CounterValue],
    source.[CounterId]);

image

Executing the statement produced in a few seconds the following message indicating a successful result:

image

I then verified that the total row count included the 167 rows added by the first operation with 1,000 total rows:

image

All other federation members have 66,500 +/- 1 rows, so correct recovery is confirmed.


Investigating Strange Storage Values Reported by Federation Member Pop Ups

I noticed a strange variation in the space data reported by the pop ups for the boxes representing federation members:

image

The following table reports the row count, used space, free space and % filled values for each of the six presumably identically sized members:

CounterId Row Count Used Space, GB Free Space, GB % Filled
1 66,501 0.0204 0.9796 2.0386
2 66,500 0.0203 0.9797 2.0302
3 66,500 0.0174 0.9826 1.7395
4 66,500 0.0319 0.9681 3.1860
5 66,500 0.0159 0.9841 1.5892
6 66,499 0.0171 0.9829 1.7075

Part of the variation might be due to the relatively small size of the uploaded data, so I’m starting a 2 GB WADPerfCounters upload of 7,959,000 rows on 1/15/2012 at 8:30 AM PST in a single 10-hour batch. I’ve reported the results below.

SQLAzureFedMW created six BCP text files, each containing 1,326,500 rows with the same federation ID, in 00:01:24 and started uploading in parallel at 8:37 AM:

image

Here’s a capture of the federation member 1’s completion of the first batch of 500,000 rows on 1/15/2012 at 1:03 PM PST:

image

and the upload’s completion at 7:05 PM PST at a rate of 65.57 rows/sec:

image

The federation detail window’s member buttons show about 40% filled

image

The following table shows a similar pattern of differences in space statistics:

CounterId Row Count Used Space, GB Free Space, GB % Filled
1 1,393,001 0.4057 0.5943 40.5724
2 1,393,000 0.4057 0.5943 40.5716
3 1,393,000 0.3427 0.6573 34.2659
4 1,393,000 0.3378 0.6672 33.7830
5 1,393,000 0.3131 0.6869 31.3148
6 1,392,999 0.3321 0.6679 33.2146

The only varchar(n) field in the table that varies significantly in length is CounterName:

CounterID CounterName Length
1 \Network Interface(Microsoft Virtual Machine Bus Network Adapter _2)\Bytes Sent/sec 84
2 \Network Interface(Microsoft Virtual Machine Bus Network Adapter _2)\Bytes Received/sec 88
3 \ASP.NET Applications(__Total__)\Requests/Sec 46
4 \TCPv4\Connections Established 31
5 \Memory\Available Mbytes 25
6 \Processor(_Total)\% Processor Time 36

The pattern of Used Space and % Filled data follows the relative length of the CounterName, which might explain the differences. It’s clear that differences in average lengths of rows could play an important part in designing a sharding strategy that minimizes monthly cost.

Update 1/18/2011: Added another 7,958,995 rows to the WADFederation with SQLAzureFedMW v1.2 to reach about 80% full on members 1 and 2:

image

Note: The second group of 20 tab-separated values files used for this upload didn’t have the uniform 398,000 rows per page of the first group, as described in the Generating Big Data for Use with SQL Azure Federations and Apache Hadoop on Windows Azure Clusters post of 1/8/2012. The reason for this difference is clear at present.

The federation is now ready for performance testing of fan-out queries with the online Fan-Out Query Utility as described in Cihan Biyikoglu’s Introduction to Fan-out Queries (PART 1): Querying Multiple Federation Members with Federations in SQL Azure post of 12/29/2011. Stay tuned for a new post on this topic.