Todays Objec4ves Threads and Synchroniza4on Wrap up Services Sept - - PDF document

today s objec4ves
SMART_READER_LITE
LIVE PREVIEW

Todays Objec4ves Threads and Synchroniza4on Wrap up Services Sept - - PDF document

9/25/17 Todays Objec4ves Threads and Synchroniza4on Wrap up Services Sept 25, 2017 Sprenkle - CSCI325 1 Review What is the goal of TCP? What are some of the approaches it uses to meet these goals? Compare and contrast


slide-1
SLIDE 1

9/25/17 1

Today’s Objec4ves

  • Threads and Synchroniza4on Wrap up
  • Services

Sept 25, 2017 1 Sprenkle - CSCI325

Review

  • What is the goal of TCP?

Ø What are some of the approaches it uses to meet these goals?

  • Compare and contrast threads and processes
  • What problem is caused by light-weight threads?

Sept 25, 2017 Sprenkle - CSCI325 2

slide-2
SLIDE 2

9/25/17 2

Review: Threads and Processes: Execu4on Environments

  • Execu4on environments

Ø address space (memory) Ø thread synchroniza4on and communica4on resources (sockets) Ø higher-level resources likes open files

  • Each process has its own separate execu4on environment
  • Threads share a single execu4on environment

Sept 25, 2017 Sprenkle - CSCI325 3

code data files registers stack code data files registers stack registers stack

Process

Main thread:

Mul+ple Threads

Threads vs. Processes

  • Benefits of using threads instead of processes

Ø Low communica4on/context switching overhead since execu4on environment/address space is shared Ø Easy to take advantage of parellelism mul4-processor computers

  • Disadvantages of threads

Ø Shared resources can lead to synchroniza4on problems Ø Need to be careful to avoid deadlocks Ø Need to provide atomic opera4ons

Sept 25, 2017 4 Sprenkle - CSCI325

slide-3
SLIDE 3

9/25/17 3

Exploring Issues with Shared Data

  • Shared Data: an array list (representa4on: Deck
  • f Cards)
  • Discussion

Ø What are the problema4c situa4ons? Ø What causes them? Ø How can you prevent problema4c situa4ons?

  • Mo4vates synchroniza4on mechanisms

Sept 25, 2017 Sprenkle - CSCI325 5

Cri4cal Sec4ons and Synchroniza4on Mechanisms

  • Cri(cal sec(on: Sec4ons of code that have to

happen uninterrupted or atomically

Ø Only one thread can execute at a 4me Ø O^en issue of writes among reads

  • Synchroniza(on mechanism: Lock

Ø Prevent more than one thread from accessing cri4cal sec4on at same 4me Ø If thread is interrupted while in the synchronized cri4cal sec4on, no other thread can start on the (synchronized) cri4cal sec4on

Sept 25, 2017 Sprenkle - CSCI325 6

slide-4
SLIDE 4

9/25/17 4

Problems

  • Interrupted writes to shared data

Ø Allows threads to access inconsistent data

  • (Not an issue if the data is local to the thread)
  • Example: Mul4ple threads run the following code
  • n the shared variable deck

Sept 25, 2017 Sprenkle - CSCI325 7

myCard = deck.peek() // check, do I want that card? deck.pop() print(myCard)

Interleaving Example Problem

Sept 25, 2017 Sprenkle - CSCI325 8

myCard = deck.peek() deck.pop() print(myCard) myCard = deck.peek() deck.pop() print(myCard) Threads interleaved: myCard = deck.peek() myCard = deck.peek() deck.pop() print(myCard) deck.pop() print(myCard) What card does the blue thread pop? What is the critical section? (i.e., what code needs to executed atomically (without interruption)?)

slide-5
SLIDE 5

9/25/17 5

Interleaving Example Problem

Sept 25, 2017 Sprenkle - CSCI325 9

myCard = deck.peek() deck.pop() print(myCard) Critical Section: Atomic operation that needs to be done together Printing does not need to be part of the critical section. Why? While deck is a shared variable, myCard is a local variable.

Synchroniza4on in Java

Sept 25, 2017 Sprenkle - CSCI325 10

// Only one thread can execute at a time. // The thread executing the block is said // to hold the lock/monitor of the deck // object synchronized(deck) { // Access shared variables and other // shared resources myCard = deck.peek() deck.pop() } System.out.println(myCard)

slide-6
SLIDE 6

9/25/17 6

210 in 325

  • Even if only one Java statement in cri4cal

sec4on, synchronize it!

  • One high-level Programming Language

statement probably translates into mul4ple VM language statements

Ø Prevent interrup4on at low level

Sept 25, 2017 Sprenkle - CSCI325 11

count++; Retrieve count Add 1 to count Store count High-level: Virtual Machine level: Is there shared data in the web server?

How does this relate to the Web Server?

  • We have mul4ple threads
  • Is there shared data? Is that data ever wrieen?

Sept 25, 2017 Sprenkle - CSCI325 12

slide-7
SLIDE 7

9/25/17 7

INTERNET SERVICES

Sept 25, 2017 Sprenkle - CSCI325 13

Discussion

  • What is the focus of the paper?

Ø What isn’t?

  • What is the author’s experience?
  • What did the author iden4fy as challenges to

giant-scale services?

  • What are the benefits of networked solu4ons?
  • What are the components of the network service

system?

Sept 25, 2017 Sprenkle - CSCI325 14

slide-8
SLIDE 8

9/25/17 8

Benefits of Network Services

  • Access anywhere, any4me

Ø This is even more true now than it was in 2001 Ø Cloud compu4ng?

  • Availability via mul4ple devices

Ø Also more true…

  • Groupware support

Ø Calendaring, teleconferencing, messaging, etc.

  • Lower overall cost

Ø Mul4plex infrastructure over ac4ve users Ø Dedicated resources are typically at least 96% idle Ø Central administra4ve burden, simplified end devices

  • Simplified service updates

Ø Update the service in one place, or 100 million?

Sept 25, 2017 Sprenkle - CSCI325 15

Giant-Scale Services

  • Paper does not address

Ø Service monitoring, configura4on, QoS, security, logging, and log analysis Ø Wide-area replicated services Ø Write-intensive services Ø Database management systems

  • Challenges for network services:

Ø High availability

  • Cri4cal in today’s Internet-dependent society
  • Each second of down4me = lots of lost money and revenue

Ø Evolu4on Ø Growth

Sept 25, 2017 Sprenkle - CSCI325 16

slide-9
SLIDE 9

9/25/17 9

Buzzword Bingo: ISP

  • + Net Neutrality

Sept 25, 2017 Sprenkle - CSCI325 17

ISP: Internet Service Provider

  • Provides connec4ons to the rest of the Internet
  • Net neutrality

Ø Providers want to give preference to certain types of traffic

  • Ex: Slow down Nenlix traffic on Comcast network so

that people will prefer Comcast On-Demand

Ø Net neutrality advocates want all traffic to be seen as equal – no dis4nc4on

  • Way it has always been, your expecta4on

Sept 25, 2017 Sprenkle - CSCI325 18

slide-10
SLIDE 10

9/25/17 10

Cluster Discussion

  • What is the case for clusters?

Ø Is it s4ll true?

  • What do they consist of?

Sept 25, 2017 Sprenkle - CSCI325 19

Buzzword: Commodity Components

  • Defn: [rela4vely] cheap components, widely

available, interchangeable

Ø “Off-the-shelf” components

  • Allow crea4on of [rela4vely] cheap clusters of

machines that work together

  • In contrast to specialty hardware, e.g.,

supercomputers

Sept 25, 2017 Sprenkle - CSCI325 20

slide-11
SLIDE 11

9/25/17 11

Network Service Components

1 2 3 4

Server

5 6

Sept 25, 2017 Sprenkle - CSCI325 21

Clusters as Building Blocks

  • No alterna4ve to clusters for building network

services that can scale to global use

  • Cluster benefits:

Ø Incremental scalability

  • Adding one machine typically linearly improves

performance

Ø Independent components Ø Cost and performance

Sept 25, 2017 Sprenkle - CSCI325 22

slide-12
SLIDE 12

9/25/17 12

Looking Ahead

  • Web Server Project!

Sept 25, 2017 Sprenkle - CSCI325 23