Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC364 Lecture 11

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

CSC364 Lecture 11

Introduction to Networked, Distributed, and Parallel Computing
Push and Pull Models
(202607)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

February 16, 2026

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 364 Introduction to Networked, Distributed, and Parallel Computing Lecture 11. Push vs Pull Models 1
  2. Distributed Computing • Multiple independent computers (often c a lled

    nodes) work together over a network to solve a problem th a t would be di ff icult, slow, or impossible for a single m a chine to h a ndle a lone. • T a sks a re divided into sm a ller pieces a nd distributed a cross di ff erent m a chines, which process them concurrently a nd coordin a te through mess a ge p a ssing or sh a red d a t a protocols. • Addresses ch a llenges such a s synchroniz a tion, f a ult toler a nce, consistency, communic a tion l a tency, a nd resource m a n a gement. • Distributed computing underlies m a ny modern technologies, including cloud computing pl a tforms, l a rge-sc a le web services, distributed d a t a b a ses, blockch a in networks, a nd p a r a llel scienti f ic simul a tions. 2
  3. • Producers • They run on it own thre a

    d - Cre a te one worker per CPU core. • Gener a tes Jobs consisting of a rithmetic oper a tions with r a ndomly gener a ted integers. • Let us a gree th a t + is 1, - is 2, * is 3 a nd / is 4 • Sleep 10 seconds jobObject System story :: Producer 4 1 5 7 #0 producerObject #0
  4. • Local workers • They run on it own thre

    a d - Cre a te one worker per CPU core. • E a ch worker repe a tedly t a kes a job a nd “solves” it, then gets paid 1 coin. • Sleep 10 seconds System story :: LocalWorker + 5 7 #3 #0 #3 1 jobObject 1 5 7 #0 = 12 +1
  5. • JobRepository: • A f ixed-c a p a city

    job bu ff er of size NCPU, protected with Semaphores a nd a ReentrantLock. System story :: JobRepository
  6. System story :: JobRepository Use the cl a ssic bounded-bu

    ff er p a ttern: - EmptySlots sem a phore st a rts a t c a p a city - Av a il a bleItems sem a phore st a rts a t 0 - A Reentr a ntLock protects the queue itself put(job) 1. EmptySlots. a cquire() 2. Lock → enqueue 3. Unlock 4. Av a il a bleItems.rele a se() t a ke() 1. Av a il a bleItems. a cquire() 2. Lock → dequeue 3. Unlock 4. EmptySlots.rele a se() 7
  7. • Treasury • The tre a sury rew a rds

    1 coin for e a ch completed job, independent of which worker solved it. • The tre a sury h a s a limited budget. • For this experiment, the initi a l b a l a nce will be set to 1,000 coins. System story :: Treasury
  8. System story :: Treasury • Producer deposits 2 coins per

    job into the tre a sury. • When job is completed: 2 coin is p a id to the solver (Worker or Outsourcer) • Outsourcer sent 1 coin to extern a l solvers a fter receiving the job done • C a n a n outsourcer “m a ke more money” by processing more jobs per minute? 9
  9. System story :: Outsourcer (contractor) • Outsourcer (contr a ctor)

    • Also consumes jobs from the repository. • It forw a rd the job to a n extern a l solver a nd w a it for the result. • Sleep 2 seconds • How the hiring process will work? 10
  10. Push Model publish(job) Workers p a ssively receive. Ch a

    r a cteristics: • Simple • Low coordin a tion • No control over distribution • No n a tur a l b a ckpressure 12 jobObject 1 5 7 #0
  11. Step 1 — Work Request Topic csc364/work/request { "workerId": "W1",

    "c a p a city": 1 } C a p a city could be: • number of free thre a ds • queue size rem a ining • simple “re a dy” 14
  12. Step 2 — Outsourcer Maintains Job Queue Outsourcer: • Subscribes

    to request topic • M a int a ins intern a l queue • Assigns jobs only when requested 15
  13. Step 3 — Direct Assignment Topic • Inste a d

    of: csc364/jobs • Use: csc364/work/ a ssign/{workerId} • Now job is sent only to th a t worker. 16
  14. Problem • Wh a t if worker cr a shes

    a fter requesting but before completing job? • Outsourcer m a int a ins: Map<JobId, WorkerId> inFlight; • If no result within timeout → re a ssign. 17
  15. CSC 364 Introduction to Introduction to Networked, Distributed, and Parallel

    Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC 364 at Cal Poly. They cannot be distributed or used for another purpose. 25