Demo Script - TSP

Embed Size (px)

Citation preview

  • 8/17/2019 Demo Script - TSP

    1/26

    Demo Script

    Parallel Computing on Azure - Travelling Salesman Demo

    Demo version: 1.0.0

    Last updated: 4/29/2016

  • 8/17/2019 Demo Script - TSP

    2/26

    Content

  • 8/17/2019 Demo Script - TSP

    3/26

    OVERVIEW................................................................................................................................................. 3

    Key Messages......................................................................................................................................... 4Key Technologies.....................................................................................................................................4

    Prerequisites............................................................................................................................................ 4

    Time Estimates........................................................................................................................................ 5

    SETUP AND CONFIGURATION............................................................................................................... ..6

    DEMO FLOW..................................................................................................................................... ......... 7

    OPENING STATEMENT..............................................................................................................................9

    STEP-BY-STEP WALKTHROUGH......................................................................................................... ..10Segment #1: Scaling-U !in"os $%ure $lications using a Single &nstance.......................... ..........1'

    Segment #(: Scaling-)ut !in"os $%ure $lications using Multile instances..................................1*

    SUMMARY.............................................................................................................................................. .. !

    http://var/www/apps/conversion/tmp/scratch_7/HYPERLINK%23_Toc311038884http://var/www/apps/conversion/tmp/scratch_7/HYPERLINK%23_Toc311038884

  • 8/17/2019 Demo Script - TSP

    4/26

    Overview

     This demo highights how to scale-up !e" #ppi$ations on !indows #%ure& using the .'(T Tas) *arae Li"rar+ ,T*L-

    $asses rom .'(T ramewor) 4.0. This i"rar+ e$ient+ utii%es mutipe pro$essors within !indows #%ure roes&

    where the si%e o the irtua a$hine instan$e is greater than Small ,i.e. where there are mutipe pro$essors

    avaia"e-. #dditiona+& the demo shows how to scale-out  appi$ations ta)ing advantage o Te$hni$a Computing

    a$ross mutipe roe instan$es& using a 3o" s$heduing agorithm. The wor) is distri"uted to a the avaia"e

    instan$es& maimi%ing the C*5 pro$essing o ea$h.

     Traveing aesman demo is using a 7geneti$8 agorithm to ui$)+ sove the pro"em that woud ordinari+ reuire

    ver+ man+ $onventiona intera$tions to sove. The pro"em and its reaie appi$ations are wide+ do$umented ,or

    eampe& see http://www.tsp.gate$h.edu/inde.htm-.

     The agorithm used in this demo was ta)en rom http://www.heatonresear$h.$om/onine/introdu$tionneuranetwor)s$sedition2/$hapter6 whi$h epains that the num"er o steps to sove a pro"em with ' $ities is '; ,'

    a$toria- ,' < ,'1- < ,'2-

  • 8/17/2019 Demo Script - TSP

    5/26

    3 /0(22'

    1' /0(22''

    11 /33102''

    1( 4*3''10''

    1/ 0((*'('2''

    ... ...

    5' /.'41 1'04

    or $omparison& the >0 $ities pro"em that reuires ?.041 < 10@64 oops $onventiona+ $an "e soved in

    approimate+ 1>0 to 200 geneti$ oop iterations within this demo.

    Key Messages

    An this demo +ou wi see severa )e+ eatures and toos:

    1. .'(T Tas) *arae Li"rar+ ,T*L-

    2. $aingB5p on !indows #%ure using T*L

    ?. $aingBOut on !indows #%ure with utiBAnstan$e !or)er oe *ro$essing

    Key Technologies

     This demo uses the oowing te$hnoogies:

    4. #*.'(T

    >. !indows #%ure D and !indows #%ure Toos or i$rosot isua tudio 2010

    6. Tas) *arae Li"rar+ ,T*L-

  • 8/17/2019 Demo Script - TSP

    6/26

    Prerequisites

    !indows #%ure su"s$ription

    Time Estimates

    (stimated time or setting up and $onEguring the demo: 20 minutes

    (stimated time to $ompete the demo: ?0 minutes

  • 8/17/2019 Demo Script - TSP

    7/26

    etup and ConEguration

    a)e sure +ou have $he$)ed a the dependen$ies or this demo "eore running the setup.

    An order to show a $omparison "etween Te$hni$a Computing with T*L and mutiBnode pro$essing& two instan$es o

    the sampe appi$ation are reuired.

     The setup and $onEguration or this demo invoves the oowing tas)s:

    • Create 2 hosted servi$es in +our su"s$ription.

    • Create a storage a$$ount in +our su"s$ription.

    • et *owerhe s$ripts ee$ution poi$+ to unrestri$ted.

    • un provided s$ripts to "uid and depo+ the sampe appi$ation& and to add sampe data into +our storage

    a$$ount.

     The oowing steps epains how to perorm the previous tas)s:

    F. Growse to http://windows.a%ure.$om.

    H. Create two storage a$$ounts.

    9. Create two hosted servi$esI use a diJerent storage a$$ount or ea$h servi$e.

    Note: The present demo in$udes a isua tudio oution that must "e $ompied and depo+ed to a !indows

    #%ure a$$ount. To simpi+ the pro$ess& etup.$md s$ript wi automati%e this tas). *ease ta)e the oowing

    $onsiderations a"out the depo+ s$ript "eore running it:

    K The management $ertiE$ated $reated "+ this too shoud not "e shared with others.

    K The hosted servi$e provided must not $ontain an+ *rodu$tion depo+ment& "e$ause this sot wi "e

    used to upoad the $ompied soution.

    http://windows.azure.com/http://windows.azure.com/

  • 8/17/2019 Demo Script - TSP

    8/26

    K The storage a$$ount provided wi not "e $eaned. #n+ eisting "o"& ta"e or ueue wi remain inta$t.

    10.Growse to the root oder o this demo and $i$) the Setup.cmd s$ript. The s$ript wi "uid the soution and

    generate the pa$)age to depo+.

    11.!hen prompted to $reate a $ertiE$ate press Y  to generate a new $ertiE$ate or N i +ou have a $ertiE$ate

    instaed in +our o$a ma$hine and have it upoaded as a management $ertiE$ate in the management

    porta.

    12.A +ou $hoose to generate a new $ertiE$ate& the s$ript wi pause to et +ou upoad the generated $ertiE$ate

    to the management porta. 5poad the $ertiE$ate to the management porta in the management

    $ertiE$ates se$tion and ta)e note o its thum"print.

    1?.Open the confguration.xml  Ee o$ated in the scripts oder o this demo. 5pdate a the entries in the

    Ee:a. our #%ure su"s$ription id.

    ". our $ertiE$ate thum"print ,the one +ou upoaded to the #%ure *orta-.

    $. The hosted servi$e name& storage a$$ount name and )e+ or the Small and arge instan$es.

    14.Continue with the s$ript. !ait unti the pa$)age is depo+ed to +our hosted servi$e and started up.

    Demo ow

     The oowing diagram iustrates the highBeve Mow or this demo and the steps invoved:

  • 8/17/2019 Demo Script - TSP

    9/26

    !igure "

    Demo Flow

  • 8/17/2019 Demo Script - TSP

    10/26

    Opening tatement

    An this session& we are going to earn how to ta)e advantage o Te$hni$a Computing on !indows #%ure& using the

     Tas) *arae Li"rar+ ,T*L-& whi$h was in$uded in the .'(T ramewor) 4 and aso how to ta)e advantage o mutiB

    node pro$essing to maimi%e our pro$essing usage. This demo $overs:

    1>.Now to s$aeBup +our appi$ation using T*L and $ompare the pro$essing resuts "etween a singe $ore

    instan$e ,small- against a mutiB$ore one ,Large-.

    16.Now to s$aeBout +our appi$ation using a 3o" $heduing agorithm to spit wor) "etween a the nodes

    ,Anstan$e $ount greater than 1-.

  • 8/17/2019 Demo Script - TSP

    11/26

    tepB"+Btep !a)through

     This demo is $omposed o the oowing segments:

    $aingB5p !indows #%ure #ppi$ations using a inge Anstan$e.

    $aingBOut !indows #%ure #ppi$ations using utipe instan$es.

    Segment #": Scaling$%p &indo's ()ure (pplications using a Single *nstance

    A"#$%& S"'$(# S"'))&*+%#

    1*. )en the S, &/ L')

    VM S$) A(($"#$%&* in

    "ierent ,roser ta,s.

    &n this "emo & ill sho you ho to

    use Parallel omuting on !in"os

     $%ure. 6or this & ha7e alrea"y

    "eloye" to instances o the same

    alication. )ne using a Small 8M

    Si%e an" the other using 9arge 8M

    Si%e.

    12. Sho the S, VM S$) 

    A(($"#$%& an" elain

    ho it or;s.

    !e

  • 8/17/2019 Demo Script - TSP

    12/26

    algorithm.

    !eoute Points ollection

    in or"er to ha7e the laces e ant

    to 7isit mar;e" on the ma.

    ('. hoose a re"eine"

    En"oint ollection an" clic;

    L%/ or generate a ne one

    using the >an"om >oute Points

    generation eature. 6or "emo

    uroses e ill use ?Visit Every 

    State Capital @ re"eine"

    collection.

    &n this age e ill ,e a,le to

    create as many routes as e ant

    using the >an"om >oute Points

    generation eature.

    !e also ha7e re"eine" en"oints

    collections ith seciic >oute

    Points alrea"y loa"e".

    6or this "emo e

  • 8/17/2019 Demo Script - TSP

    13/26

    (1. )nce the Ma shos the

    en"oints clic; S#'#

    C"2#$& to start calculating

    the routes ,eteen the shonoints.

    ((. Bou ill ,e re"irecte" to

    the V$) E4)"2#$%& S##2* age

    to see the current Ao,s an" their

    status.

    +o you ill see ho the ma

    oulates ith the oints e ha7e

     Aust loa"e".

    )nce e ha7e the >oute Points

    locate" in the ma e can start

    calculating the route ith the

    genetic algorithm.

    This may ta;e some time "een"ing

    on ho many oints e ha7e

    chosen to generate the route.

    To see the route generation

    rogress e ill sitch to the

    E4)"2#$%& S##2* age.

    (/. &n the ta,le locate your

    request ?Visit Every State

    Capital @. lic; the >equest title to

    see the calculation rogress

    &n this ta,le you ill see all the

    alication Ao,s an" their states.

    Bou can restart a Ao, cancel it or

    simly see the result or rogress inthe ma ,y clic;ing the Ao,

  • 8/17/2019 Demo Script - TSP

    14/26

    (4. !ait until the rocess

    S##2* change to Completed .

    (5. Cighlight in the ta,le theT%# D2'#$%& 7alue.

    +o e ill ait until the rocess

    status changes to omlete".

    +otice that the algorithm ma;esse7eral iterations until ha7ing the

    ,est-otimi%e" route ith the gi7en

    >oute Points.

    Meanhile you ill see the

    temorary calculations in the ma.

    +o that the calculation inishe"

    e see the ,est-otimi%e" route"ran in the ma.

    )n the let ane you ill notice

    some inormation regar"ing the

    recently calculate" route li;e Total

    Duration o the rocess PU

    Statistics Start time etc.

    Ta;e note o the Total Duration ittoo; ith one Small 8M Si%e

    instance.

    (0. Sitch to the L') VM

    S$) A(($"#$%& oene" in the

    secon" ta,.

    +o e

  • 8/17/2019 Demo Script - TSP

    15/26

    (*. >eeat stes / to 3 an"

    notice the "ierences ,eteen

    the T%# D2'#$%& 7alues.

    (2. Ta;e note o ,oth T%#

    D2'#$%& 8alues to comare ith

    the results you ill o,tain "uring

    net segment.

    (3.   C%*) the ,roser.

    the one e ha7e ,een using ,eore.

    The only "ierence ,eteen them is

    that this one has a larger 8M Si%ethat contains our rocessor cores

    hile the Small only contains a

    single core.

    +o e ill reeat the stes e "i"

    ,eore to calculate the same route

    an" comare the Total  Duration or

    ,oth alications.

    The $lication ith the 9arger 8M

    Si%e comlete" the rocess in a

    shorter time than the other one.

    This is not simly "ue to the si%e

    "ierence ,eteen 8Ms it is also

    "ue to the ay the alication as

    co"e".

    +o & ill sho you the iece o

    co"e that ma;es the "ierence.

  • 8/17/2019 Demo Script - TSP

    16/26

    /'. )en 8isual Stu"io ('1'

    ith $"ministrator ri7ileges.

    /1. )en the TCP.A2').*&  solution locate" in the C%/) 

    ol"er o this "emo.

    /(. )en

    G)&)#$"A%'$#+,."* ile

    locate" in TSP.A%'$#+, 

    roAect.

    & ill oen the same solution & ha7e

    "eloye" an" e ha7e ,een using

    "uring the "emo.

    Don

  • 8/17/2019 Demo Script - TSP

    17/26

    iterations through multile threa"s

    i the comuter has multile

    rocessors or cores.

    This co"e uses Parallel.For() 

    sentence hich is art o the

    System.Threading.Tasks 

    namesace.

    !ith this sentence you can

    aralleli%e tas;s in threa"s as many

    cores you ha7e ta;ing a"7antage o 

    multirocessing.

    6or that reason e sa a ,ig

    imro7ement in the same

    alication running the same

    rocess ,ut in "ierent 8M Si%es.

    This is ,ecause the 8M Si%e an"

    the amount o cores it has. $s the

    8M Si%e increases the amount o

    a7aila,le cores you ha7e increases

    too. This lets you aralleli%e more

    tas;s.

    /5. Cighlight the olloing

    eatures you shoe" "uring the

    "emo.

    Using the 8M si%es that $%ure oer

    e can escalate our alication

    ithout changing any co"e itting

    ith the rocessing erormance

  • 8/17/2019 Demo Script - TSP

    18/26

    you nee".

    &t is quite easy to ugra"e your

    alication si%e you only nee" tochoose a "ierent 8M Si%e in the

    coniguration settings an" re-"eloy

    it.

    This concet is ;non as Scaling-

    U hich means that hen you a""

    resources to a single no"e system

    your alication is a,le to ta;e

    a"7antage o it. &n this case e areincreasing the num,er o a7aila,le

    cores an" the alication

    automatically slits tas;s in threa"s

    as cores are a7aila,le.

    Coe7er the TP9 cannot ta;e

    a"7antage o the multi-instances

    that $%ure oers. This is ,ecause

    TP9 can aralleli%e tas;s in a single

    no"e ,ut is not aare o other

    instances or the same alication.

    &n the net segment & ill sho you

    ho to o7ercome this.

  • 8/17/2019 Demo Script - TSP

    19/26

    Segment #+: Scaling$,ut &indo's ()ure (pplications using Multiple instances

    A"#$%& S"'$(# S"'))&*+%#

    /0. &ntro"uce the Scale-)ut

    concet to the au"ience.

     $s the Scale-U a,ility is limite"

    no e ill intro"uce the Scale-)ut

    concet.

    Scaling-)ut a system means to a""

    more no"es to it an" use all the

    resources as a common ool. 6or

    this to or; you ill nee" a system

    reare" or "istri,uta,le or;.

    +o & ill sho you ho this

    alication can "istri,ute Ao,s in

    or"er to Scale-)ut using $%ure

    !or;er >oles.

  • 8/17/2019 Demo Script - TSP

    20/26

    /*. & not alrea"y oen oen

    8isual Stu"io ('1' ith

     $"ministrator ri7ileges.

    /2. )en the TCP.A2').*&  

    solution locate" in the C%/) 

    ol"er o this "emo.

    /3. )en W%'5)'R%)."* ile

    locate" in TSP.A2').W%'5)'  

    roAect

    & ill sitch ,ac; to the 8isual

    Stu"io Solution to sho you ho to

    create a Ho, Sche"uling algorithm

    to "istri,ute or; among !or;er>oles.

    +o & ill oen the W%'5)'R%)."*

    ile ithin TSP.A2').W%'5)'  

    roAect.

    &nsi"e the !or;er >ole class you

    ill in" the necessary co"e to

    manage multile Ao,s runningsimultaneously.

    4'. 9ocate P'%")**R)2)*#* 

    metho".

    41. Cighlight co"e shon.

    !e ill ocus on this

    P'%")**R)2)*#* metho". This

    metho" iterates through all the

    a7aila,le Ao,s assigning a time

    in"o o 0' secon"s to rocess

    each chun; o a Ao,.

    !hen the !or;er >ole starts

    rocessing the Ao,s it selects those

    that are not Completed  or Loked  

    ,y another !or;er >ole instance.

  • 8/17/2019 Demo Script - TSP

    21/26

    4(. Cighlight co"e shon. )nce it has all the a7aila,le Ao,s it

    ta;es the irst one an" Loks it to

    a7oi" other !or;er >ole instance

    ta;ing it.

    4/. Cighlight co"e shon. !ith the Ao, in han"s e ill start

    rocessing it "een"ing on its

    current state.

    & the Ao,ole initiali%es it an"

    unloks it so another !or;er >ole

    can ta;e it later.

    & the state is "nitiali#ed  or

    E$euting  the !or;er >ole sen"s it

    to the R2&A%'$#+, metho".

    +o & ill sho you this metho" in

    or"er to un"erstan" ho to manage

    each Ao,.

  • 8/17/2019 Demo Script - TSP

    22/26

    44. 9ocate the R2&A%'$#+, 

    metho" ithin W%'5)'R%)."* 

    class.

    45. Cighlight co"e shon.

    Cere e ha7e the R2&A%'$#+, 

    metho" ithin W%'5)'R%)."* ile.

    +otice that the !or;er >ole or;sith each Ao, only or 0' secon"s

    For less i it is comlete"G. $ter that

    time it rees the Ao, so another

    !or;er >ole can ta;e it.

    Doing this you ma;e sure that all

    !or;er >oles are ,eing use" an"

    or;ing at the same time

    maimi%ing their PU usage.

    This is 7ery helul in those cases

    here you ha7e more requests than

    a7aila,le !or;er >oles so you can

    tac;le all o them almost

    simultaneously a7oi"ing a

    sequential rocessing FqueueG.

  • 8/17/2019 Demo Script - TSP

    23/26

    46. )en a ,roser an"

    ,rose to

    htt:IIin"os.a%ure.comI.

    4*. & romte" login ith your  

    !in"os 9i7e &D cre"entials.

    To sho ho the sche"uling

    unctionality or;s e ill nee" to

    increase the num,er o !or;er

    >oles instances.

    To "o this e ill na7igate to the

     $%ure Portal an" u"ate the

    num,er o !or;er >ole instances in

    the "eloyment coniguration

    settings.

    42. lic; H%*#)/ S)'$")*8

    S#%') A""%2* CDN.

    43. lic; H%*#)/ S)'$")* lin;

    in the let ane.

    5'. 9ocate the Coste"

    Ser7ices you create" or the

    Small an" 9arge $lications.

    +o e ill na7igate to the Coste"

    Ser7ices section an" locate the

    "eloye" alications.

    !in"os $%ure lets you u"ate the

    Coste" Ser7ice

  • 8/17/2019 Demo Script - TSP

    24/26

    51. >ight-clic; in the P')

    TSP - L') "eloyment.

    5(. Select C%&:$2').

    5/. Select E/$# "2'')

    "%&:$2'#$%& otion.

    54. 9ocate the I&*#&")* no"e

    ithin TSP.A2').W%'5)'  no"e

    an" set the "%2 7alue to 3.

    55. lic; OK.

    !e ill start u"ating the P')

    TSP ; L') "eloyment.

    )nce e are in the onigureDeloyment section e nee" to

    select Edit urrent on%iguration an"

    u"ate the &nstances count 7alue o

    the TSP.A2').W%'5)' role.

    6or this "emo e ill use three

    instances ,ut you can a"" as many

    instances as you nee".

    +o ater ressing OK the u"ate

    rocess ill start.

    50. 9ocate the P') TSP -

    S, "eloyment an" reeat

    the stes 10 to (' to increase the

    num,er o instances.

    5*. !ait until ,oth u"ates

    inish.

    +o e ill u"ate the num,er o

    instances in the P') TSP ;

    S, "eloyment.

    !e ha7e to reeat the same stes

    e "i" in the P') TSP ; L')

    "eloyment in or"er to increase the

    num,er o !or;er >ole instances.

    +o that e ha7e ,oth

    "eloyments ugra"e" e can

    start testing their erormance.

  • 8/17/2019 Demo Script - TSP

    25/26

    52. )en the to re-"eloye"

    alications in "ierent ,roser

    ta,s.

    53. alculate again the ?Visit

    Every State Capital& in ,oth

    9arge an" Small $lications.

    0'. Cighlight the erormance

    "ierences ,eteen ,oth Small

    an" 9arge $lications an"

    comare each T%# D2'#$%&

    ith the o,taine" rom Single-

    &nstance $lications in Segment

    #1.

    01. )tionally you can reeat

    the re7ious calculation stes

    ,ut a""ing more than one Ao, to

    sho ho multi-rocessing

    or;s.

    & ill no reeat the same stes &

    "i" to calculate the Visit Every State

    Capital  route ,eore increasing the

    !or;er >ole instances.

    & ill calculate this route in ,oth

    9arge an" Small instances in or"er

    to comare erormance results.

    The results no shos that the

    calculation as e7en aster than the

    re7ious comarison as e are

    maimi%ing the PU rocessing o

    each !or;er >ole instance an"

    "istri,uting uniormly the rocess

    among them.

    !e can reeat these stes to

    calculate multile routes at the

    same time.

    This is a ractical eamle o ho

    to Scale-)ut alications ,y a""ing

    more no"es an" Scale-U

    maimi%ing the PU usage.

  • 8/17/2019 Demo Script - TSP

    26/26

    ummar+

    An this demo& +ou have earned how to use the Tas) *arae Li"rar+ to ta)e advantage o mutiB$ore instan$es. An

    #ddition& +ou earned how to maimi%e the C*5 usage o +our mutiBnode instan$es app+ing a 3o" $heduing

    agorithm in a !or)er oe.