Beruflich Dokumente
Kultur Dokumente
1.0.0
Last updated:
4/29/2016
Content
OVERVIEW................................................................................................................................................. 3
Key Messages......................................................................................................................................... 4
Key Technologies..................................................................................................................................... 4
Prerequisites............................................................................................................................................ 4
Time Estimates........................................................................................................................................ 5
SETUP AND CONFIGURATION................................................................................................................. 6
DEMO FLOW.............................................................................................................................................. 7
OPENING STATEMENT.............................................................................................................................. 9
STEP-BY-STEP WALKTHROUGH........................................................................................................... 10
Segment #1: Scaling-Up Windows Azure Applications using a Single Instance....................................10
Segment #2: Scaling-Out Windows Azure Applications using Multiple instances..................................17
SUMMARY................................................................................................................................................ 24
Overview
This demo highlights how to scale-up Web Applications on Windows Azure, using the .NET Task Parallel Library (TPL)
classes from .NET Framework 4.0. This library efficiently utilizes multiple processors within Windows Azure roles,
where the size of the Virtual Machine instance is greater than Small (i.e. where there are multiple processors
available). Additionally, the demo shows how to scale-out applications taking advantage of Technical Computing
across multiple role instances, using a Job scheduling algorithm. The work is distributed to all the available
instances, maximizing the CPU processing of each.
Travelling Salesman demo is using a genetic algorithm to quickly solve the problem that would ordinarily require
very many conventional interactions to solve. The problem and its reallife applications are widely documented (for
example, see http://www.tsp.gatech.edu/index.html).
The algorithm used in this demo was taken from http://www.heatonresearch.com/online/introductionneural
networkscsedition2/chapter6 which explains that the number of steps to solve a problem with N cities is N! (N
factorial) (N * (N1) * (N2) * * 2 * 1):
Number of Cities
Number of Steps
24
120
720
5,040
40,320
362,880
10
3,628,800
11
39,916,800
12
479,001,600
13
6,227,020,800
...
...
50
3.041 * 10^64
For comparison, the 50 cities problem that requires 3.041 * 10^64 loops conventionally can be solved in
approximately 150 to 200 genetic loop iterations within this demo.
Key Messages
In this demo you will see several key features and tools:
1. .NET Task Parallel Library (TPL)
2. Scaling-Up on Windows Azure using TPL
3. Scaling-Out on Windows Azure with Multi-Instance Worker Role Processing
Key Technologies
This demo uses the following technologies:
4. ASP.NET
5. Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio 2010
6. Task Parallel Library (TPL)
Prerequisites
Windows Azure subscription
Time Estimates
Estimated time for setting up and configuring the demo: 20 minutes
Estimated time to complete the demo: 30 minutes
Run provided scripts to build and deploy the sample application, and to add sample data into your storage
account.
The management certificated created by this tool should not be shared with others.
The hosted service provided must not contain any Production deployment, because this slot will be
used to upload the compiled solution.
The storage account provided will not be cleaned. Any existing blob, table or queue will remain intact.
10.Browse to the root folder of this demo and click the Setup.cmd script. The script will build the solution and
generate the package to deploy.
11.When prompted to create a certificate press Y to generate a new certificate or N if you have a certificate
installed in your local machine and have it uploaded as a management certificate in the management
portal.
12.If you choose to generate a new certificate, the script will pause to let you upload the generated certificate
to the management portal. Upload the certificate to the management portal in the management
certificates section and take note of its thumbprint.
13.Open the configuration.xml file located in the scripts folder of this demo. Update all the entries in the
file:
a. Your Azure subscription id.
b. Your certificate thumbprint (the one you uploaded to the Azure Portal).
c. The hosted service name, storage account name and key for the Small and Large instances.
14.Continue with the script. Wait until the package is deployed to your hosted service and started up.
Demo Flow
The following diagram illustrates the high-level flow for this demo and the steps involved:
Figure 1
Demo Flow
Opening Statement
In this session, we are going to learn how to take advantage of Technical Computing on Windows Azure, using the
Task Parallel Library (TPL), which was included in the .NET Framework 4 and also how to take advantage of multinode processing to maximize our processing usage. This demo covers:
15.How to scale-up your application using TPL and compare the processing results between a single core
instance (small) against a multi-core one (Large).
16.How to scale-out your application using a Job Scheduling algorithm to split work between all the nodes
(Instance count greater than 1).
Step-by-Step Walkthrough
This demo is composed of the following segments:
Scaling-Up Windows Azure Applications using a Single Instance.
Scaling-Out Windows Azure Applications using Multiple instances.
Segment #1: Scaling-Up Windows Azure Applications using a Single Instance
Action
Script
Screenshot
algorithm.
Were now going to use this
application to calculate some routes
and see the performance
comparison between different VM
Size Applications.
20.
Choose a predefined
Endpoint Collection and click
Load or generate a new one
using the Random Route Points
generation feature. For demo
purposes we will use Visit Every
State Capital predefined
collection.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
Open
GeneticAlgorithm.cs file
located in TSP.Algorithm
project.
33.
Locate Parallel.For()
sentence within Iterate method.
34.
you need.
It is quite easy to upgrade your
application size, you only need to
choose a different VM Size in the
configuration settings and re-deploy
it.
This concept is known as ScalingUp which means that when you add
resources to a single node system,
your application is able to take
advantage of it. In this case, we are
increasing the number of available
cores and the application
automatically splits tasks in threads
as cores are available.
However, the TPL cannot take
advantage of the multi-instances
that Azure offers. This is because
TPL can parallelize tasks in a single
node but is not aware of other
instances for the same application.
In the next segment, I will show you
how to overcome this.
Action
36.
Script
Screenshot
37.
38.
39.
40.
41.
Locate ProcessRequests
method.
Highlight code shown.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
Select Configure.
53.
54.
55.
56.
Click OK.
57.
58.
59.
60.
61.
Summary
In this demo, you have learned how to use the Task Parallel Library to take advantage of multi-core instances. In
Addition, you learned how to maximize the CPU usage of your multi-node instances applying a Job Scheduling
algorithm in a Worker Role.