SlideShare a Scribd company logo
1 of 63
Scheduling in Linux
and Web Servers
Plan for Today
Scheduling in Linux (2002-today)
Scheduling Web Services
Submitting PS3:
- Schedule demo (sign up soon!)
- Web submission form (11:59pm tomorrow)
- Benchmark submission
- Post-demo assessment (teammate evaluation)
leaderboard.html
1
Scheduling
in Linux

2
Linux Scheduler before V2.6 (2002)
Three types of processes:
#define SCHED_OTHER 0 Normal user processes
#define SCHED_FIFO
1 Non-pre-ementable
#define SCHED_RR
2 Real-time round-robin
Not (fully) pre-emptive:
only user-level processes could be pre-empted
Select next process according to “goodness” function
3
/* linux/kernel/sched.c
* This is the function that decides how desirable a process is.
* You can weigh different processes against each other depending
* on what CPU they've run on lately etc to try to handle cache
* and TLB miss penalties.
*
* Return values:
* -1000: never select this
* 0: out of time, recalculate counters (but it might still be selected)
* +ve: "goodness" value (the larger, the better)
* +1000: realtime process, select this.
*/
static inline int goodness(struct task_struct * p, int this_cpu, struct
mm_struct *this_mm)
{
int weight;
/*
* Realtime process, select the first one on the
* runqueue (taking priorities within processes
* into account).
*/
if (p->policy != SCHED_OTHER) {
weight = 1000 + p->rt_priority;
goto out;
}
/*
* Give the process a first-approximation goodness value
* according to the number of clock-ticks it has left.
*
* Don't do any other calculations if the time slice is
* over..
*/

/* linux/kernel/sched.c
* This is the function that decides how desirable a process is.
* You can weigh different processes against each other depending
* on what CPU they've run on lately etc to try to handle cache
* and TLB miss penalties.
*
* Return values:
* -1000: never select this
* 0: out of time, recalculate counters (but it might still be selected)
* +ve: "goodness" value (the larger, the better)
* +1000: realtime process, select this.
*/
static inline int goodness(struct task_struct * p, int this_cpu,
struct mm_struct *this_mm)
{
…
4
static inline int goodness(struct task_struct * p, int this_cpu, struct mm_struct *this_mm)
{
int weight;
/* Realtime process, select the first one on the runqueue (taking priorities into account). */
if (p->policy != SCHED_OTHER) {
weight = 1000 + p->rt_priority;
goto out;
}
/* Give the process a first-approximation goodness value according to the number of clock-ticks it has left.
Don't do any other calculations if the time slice is over.. */
weight = p->counter;
if (!weight) goto out;
#ifdef __SMP__
/* Give a largish advantage to the same processor... (equivalent to penalizing other processors) */
if (p->processor == this_cpu) weight += PROC_CHANGE_PENALTY;
#endif
/* .. and a slight advantage to the current MM (memory segment) */
if (p->mm == this_mm) weight += 1;
weight += p->priority;
out:
This is the whole goodness function from V2.5
return weight;
scheduler (only edited formatting to fit on slide).
}

5
What is the running time of the
Linux 2.2-2.5 Scheduler?

6
What is the
running time of
the Linux 2.2-2.5
Scheduler?

7
8
Linux 2.6 Scheduler (2003-2007)
140 different queues (for each processor)
0-99 for “real time” processes
100-139 for “normal” processes

Bit vector keeps track of which queues have ready
to run process
Scheduler picks first process from highest priority
queue with a ready process
Given time quantum that scales with priority
9
Linux 2.6 Scheduler
(2003-2007)

struct runqueue {
struct prioarray *active;
struct prioarray *expired;
struct prioarray arrays[2];
140 different queues (for
};
each processor)
struct prioarray {
0-99 for “real time” processes
int nr_active; /* # Runnable */
100-139 for “normal” processes unsigned long bitmap[5];
struct list_head queue[140];
Bit vector of ready-to-run
};
Scheduler picks first process from highest-priority queue with a ready process
10
What is the running time of the
Linux 2.6 Scheduler?

11
(Sadly, O(1) scheduler has no Facebook page.)
12
Linux V2.6.23+ Scheduler

13
Rotating Staircase Deadline Scheduler

This is exactly stride scheduling (but with different terminology)!
14
15
16
17
18

Linux/kernel/sched/fair.c
What is the running time of the
Linux 2.6.23+ Scheduler?

Not called the θ(log N) scheduler – by Linux 2.6.23 marketing
matters: “Completely Fair Scheduler”
19
(In practice) What is log2 N?
20
What resources should scheduler
be maximizing utility of?

21
Key Resource: Energy!

Image from http://arstechnica.com/apple/2013/10/os-x-10-9/12/
22
Image from http://arstechnica.com/apple/2013/10/os-x-10-9/12/
23
Image from http://arstechnica.com/apple/2013/10/os-x-10-9/12/
24
Image from http://arstechnica.com/apple/2013/10/os-x-10-9/12/
25
Timer Coalescing

Images from http://arstechnica.com/apple/2013/06/how-os-x-mavericks-works-its-power-saving-magic/

26
OS Schedulers Recap
Use Resources Well
Limit unnecessary switching, Save Energy
Low cost of scheduler itself
Make good decisions
Locally: pick the most important process
Globally: provide good system performance
27
Scheduling Web Servers
28
Web Server Overload!

healthcare.gov

Rate of incoming requests > Rate server can process requests
29
Solutions

30
Strategy 0:
Measure

31
“When the meetings ended at a CMS outpost
in Herndon, Va., at about 7:00 p.m., the rescue
squad already on the scene realized they had
more work to do. One of the things that
shocked Burt and Park’s team most—“among
many jaw-dropping aspects of what we found,”
as one put it—was that the people running
HealthCare.gov had no “dashboard,” no quick
way for engineers to measure what was going
on at the website, such as how many people
were using it, what the response times were
for various click-throughs and where traffic
was getting tied up. So late into the night of
Oct. 18, Burt and the others spent about five
hours coding and putting up a dashboard.”
32
Developer Benchmarks
• Find bottlenecks: know what to spend time
optimizing
• Measure impact of changes
• Predict what resources you will need to scale
service
Goal is a benchmark that represents the actual usage
33
Strategy 1:
Shrink and Simplify Your Content

34
5 September 2001

11 September 2001

archive.org captures of New York Times (http://www.nytimes.com)
35
36
11 September 2001

5 September 2001

37
Strategy 2:
Cache to Save Effort

38
39

Norvig Numbers (2001)
“Looking over the dashboard that Park, Burt and the
others had rigged up the prior Friday night, Abbott and
the group discovered what they thought was the
lowest-hanging fruit--a quick fix to an obvious mistake
that could improve things immediately. HealthCare.gov
had been constructed so that every time a user had to
get information from the website's vast database, the
website had to make what's called a query into that
database. … The team began almost immediately to
cache the data. The result was encouraging: the site's
overall response time--the time it took a page to load-dropped on the evening of Oct. 22 from eight seconds
to two. That was still terrible, of course, but it
represented such an improvement that it cheered the
engineers. They could see that HealthCare.gov could be
saved instead of scrapped.”
40
Strategy 3:
Buy (or Rent) More Servers

41
Amazon’s
Elastic
Compute
Cloud
(EC2)
42
43
44
“A series of hardware upgrades had
dramatically increased capacity; the
system was now able to handle at least
50,000 simultaneous users and probably
more. There had been more than 400 bug
fixes. Uptimes had gone from an abysmal
43% at the beginning of November to 95%.
And Kim and her team had knocked the
error rate from 6% down to 0.5%. (By the
end of January it would be below 0.5%
and still dropping.)”
45
Using More Servers
Server 1

Dispatcher

Server 2

Server 3

46
Sharing State
Server 1

Dispatcher

Server 2

Database

Server 3

47
Distributed Database
Server 1

Dispatcher

Database

Database
Server 2
Database
Server 3
Database
48
Maintaining Consistency
Server 1

Dispatcher

Database

Database
Server 2
Database
Server 3
Database
49
1. Replication
Database
Reads are efficient
Server 1
Writes are complex and risky
2. Vertical Partitioning
Database
Dispatcher
Split database by columns Server 2
3. Horizontal Partitioning (“Sharding”)
Database
Split database by rows
Server 3
4. Give up on consistency and functionality
“NoSQL” (e.g., Cassandra, MongoDB, BigTable)
Database
50
Scalable Enough?
Server 1

Dispatcher

Database

Database
Server 2
Database
Server 3
Database
51
Distributed Denial-of-Service
Server 1

Dispatcher

Database

Database
Server 2
Database
Server 3

x 2000 machines
Botnet

Database
52
53
Example DDOS Attacks

54
Strategy 4:
Smarter Scheduling

55
What should the server’s goal be?

56
What is the bottleneck resource?
Zhtta

Disk (files)

Cache

57
Connecting to the Network

ISP
Router

zhtta
Cache

Disk (files)

58
Cisco Nexus 7000 (~$100K)
48 Gb/s per slot x 10

10 Gb/s x 4 per switch

Your server
250 Mbits/s
$20/month
59
Shortest Remaining Processing Time-first
60
How close to this can you get for PS3?

61
Charge
Measurement (“dashboard”) is essential for
improving performance
Important to measure the right things!

Scheduling policies:
Avoid wasting resources
Make trade-offs that align with system goals

PS3 Due tomorrow (Wednesday) at 11:59pm
If you haven’t already scheduled your demo, do so now!
62

More Related Content

What's hot

JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixCodemotion Tel Aviv
 
A Brief History of System Calls
A Brief History of System CallsA Brief History of System Calls
A Brief History of System Callsahl0003
 
Spying on the Linux kernel for fun and profit
Spying on the Linux kernel for fun and profitSpying on the Linux kernel for fun and profit
Spying on the Linux kernel for fun and profitAndrea Righi
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtDavid Evans
 
SSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingSSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingDavid Evans
 
Microkernels and Beyond
Microkernels and BeyondMicrokernels and Beyond
Microkernels and BeyondDavid Evans
 
Once Upon a Process
Once Upon a ProcessOnce Upon a Process
Once Upon a ProcessDavid Evans
 
Flash! (Modern File Systems)
Flash! (Modern File Systems)Flash! (Modern File Systems)
Flash! (Modern File Systems)David Evans
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual ExclusionDavid Evans
 
Linux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sLinux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sMydbops
 
Am I reading GC logs Correctly?
Am I reading GC logs Correctly?Am I reading GC logs Correctly?
Am I reading GC logs Correctly?Tier1 App
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaXKernel TLV
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bccViller Hsiao
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)Brendan Gregg
 
Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Unity Technologies
 
Input and Output Devices and Systems
Input and Output Devices and SystemsInput and Output Devices and Systems
Input and Output Devices and SystemsNajma Alam
 

What's hot (20)

Google Spanner
Google SpannerGoogle Spanner
Google Spanner
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, Wix
 
A Brief History of System Calls
A Brief History of System CallsA Brief History of System Calls
A Brief History of System Calls
 
Spanner
SpannerSpanner
Spanner
 
Spying on the Linux kernel for fun and profit
Spying on the Linux kernel for fun and profitSpying on the Linux kernel for fun and profit
Spying on the Linux kernel for fun and profit
 
Storage
StorageStorage
Storage
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
 
SSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and SchedulingSSL Failing, Sharing, and Scheduling
SSL Failing, Sharing, and Scheduling
 
Microkernels and Beyond
Microkernels and BeyondMicrokernels and Beyond
Microkernels and Beyond
 
Spanner (may 19)
Spanner (may 19)Spanner (may 19)
Spanner (may 19)
 
Once Upon a Process
Once Upon a ProcessOnce Upon a Process
Once Upon a Process
 
Flash! (Modern File Systems)
Flash! (Modern File Systems)Flash! (Modern File Systems)
Flash! (Modern File Systems)
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual Exclusion
 
Linux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sLinux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA's
 
Am I reading GC logs Correctly?
Am I reading GC logs Correctly?Am I reading GC logs Correctly?
Am I reading GC logs Correctly?
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
 
Bpf performance tools chapter 4 bcc
Bpf performance tools chapter 4   bccBpf performance tools chapter 4   bcc
Bpf performance tools chapter 4 bcc
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019Using Entity Command Buffers – Unite Copenhagen 2019
Using Entity Command Buffers – Unite Copenhagen 2019
 
Input and Output Devices and Systems
Input and Output Devices and SystemsInput and Output Devices and Systems
Input and Output Devices and Systems
 

Similar to Scheduling in Linux and Web Servers

Process Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelProcess Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelHaifeng Li
 
Building a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationBuilding a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationJonathan Katz
 
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSVTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSvtunotesbysree
 
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltd
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltdhbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltd
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., LtdMichael Stack
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performancePiotr Przymus
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming OverviewBrian Hughes
 
Consul administration at scale
Consul administration at scaleConsul administration at scale
Consul administration at scalePierre Souchay
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profilerIhor Bobak
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209mffiedler
 
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...ijceronline
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACKristofferson A
 
Monitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialMonitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialTim Vaillancourt
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedTim Callaghan
 
Introducing Cloudian HyperStore 6.0
Introducing Cloudian HyperStore 6.0Introducing Cloudian HyperStore 6.0
Introducing Cloudian HyperStore 6.0Cloudian
 
How should I monitor my idaa
How should I monitor my idaaHow should I monitor my idaa
How should I monitor my idaaCuneyt Goksu
 
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...Data Con LA
 

Similar to Scheduling in Linux and Web Servers (20)

Process Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelProcess Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux Kernel
 
Building a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management ApplicationBuilding a Complex, Real-Time Data Management Application
Building a Complex, Real-Time Data Management Application
 
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERSVTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
 
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltd
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltdhbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltd
hbaseconasia2019 Phoenix Practice in China Life Insurance Co., Ltd
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performance
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming Overview
 
Consul administration at scale
Consul administration at scaleConsul administration at scale
Consul administration at scale
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209Testing kubernetes and_open_shift_at_scale_20170209
Testing kubernetes and_open_shift_at_scale_20170209
 
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...
Efficient Resource Allocation to Virtual Machine in Cloud Computing Using an ...
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
 
Mastering Real-time Linux
Mastering Real-time LinuxMastering Real-time Linux
Mastering Real-time Linux
 
Monitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialMonitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_Tutorial
 
Performance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons LearnedPerformance Benchmarking: Tips, Tricks, and Lessons Learned
Performance Benchmarking: Tips, Tricks, and Lessons Learned
 
cpu scheduling in os
cpu scheduling in oscpu scheduling in os
cpu scheduling in os
 
Introducing Cloudian HyperStore 6.0
Introducing Cloudian HyperStore 6.0Introducing Cloudian HyperStore 6.0
Introducing Cloudian HyperStore 6.0
 
Intro to HPC
Intro to HPCIntro to HPC
Intro to HPC
 
How should I monitor my idaa
How should I monitor my idaaHow should I monitor my idaa
How should I monitor my idaa
 
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
Big Data Day LA 2016/ Big Data Track - Portable Stream and Batch Processing w...
 

More from David Evans

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!David Evans
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksDavid Evans
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeDavid Evans
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in BitcoinDavid Evans
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm ConfirmationsDavid Evans
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting TransactionsDavid Evans
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in ParadiseDavid Evans
 
Mining Economics
Mining EconomicsMining Economics
Mining EconomicsDavid Evans
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More ParanoidDavid Evans
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key SignaturesDavid Evans
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyDavid Evans
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?David Evans
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of ReserveDavid Evans
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!David Evans
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinDavid Evans
 

More from David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
 
Mining
MiningMining
Mining
 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
 
Silk Road
Silk RoadSilk Road
Silk Road
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
 

Recently uploaded

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Scheduling in Linux and Web Servers

  • 2. Plan for Today Scheduling in Linux (2002-today) Scheduling Web Services Submitting PS3: - Schedule demo (sign up soon!) - Web submission form (11:59pm tomorrow) - Benchmark submission - Post-demo assessment (teammate evaluation) leaderboard.html 1
  • 4. Linux Scheduler before V2.6 (2002) Three types of processes: #define SCHED_OTHER 0 Normal user processes #define SCHED_FIFO 1 Non-pre-ementable #define SCHED_RR 2 Real-time round-robin Not (fully) pre-emptive: only user-level processes could be pre-empted Select next process according to “goodness” function 3
  • 5. /* linux/kernel/sched.c * This is the function that decides how desirable a process is. * You can weigh different processes against each other depending * on what CPU they've run on lately etc to try to handle cache * and TLB miss penalties. * * Return values: * -1000: never select this * 0: out of time, recalculate counters (but it might still be selected) * +ve: "goodness" value (the larger, the better) * +1000: realtime process, select this. */ static inline int goodness(struct task_struct * p, int this_cpu, struct mm_struct *this_mm) { int weight; /* * Realtime process, select the first one on the * runqueue (taking priorities within processes * into account). */ if (p->policy != SCHED_OTHER) { weight = 1000 + p->rt_priority; goto out; } /* * Give the process a first-approximation goodness value * according to the number of clock-ticks it has left. * * Don't do any other calculations if the time slice is * over.. */ /* linux/kernel/sched.c * This is the function that decides how desirable a process is. * You can weigh different processes against each other depending * on what CPU they've run on lately etc to try to handle cache * and TLB miss penalties. * * Return values: * -1000: never select this * 0: out of time, recalculate counters (but it might still be selected) * +ve: "goodness" value (the larger, the better) * +1000: realtime process, select this. */ static inline int goodness(struct task_struct * p, int this_cpu, struct mm_struct *this_mm) { … 4
  • 6. static inline int goodness(struct task_struct * p, int this_cpu, struct mm_struct *this_mm) { int weight; /* Realtime process, select the first one on the runqueue (taking priorities into account). */ if (p->policy != SCHED_OTHER) { weight = 1000 + p->rt_priority; goto out; } /* Give the process a first-approximation goodness value according to the number of clock-ticks it has left. Don't do any other calculations if the time slice is over.. */ weight = p->counter; if (!weight) goto out; #ifdef __SMP__ /* Give a largish advantage to the same processor... (equivalent to penalizing other processors) */ if (p->processor == this_cpu) weight += PROC_CHANGE_PENALTY; #endif /* .. and a slight advantage to the current MM (memory segment) */ if (p->mm == this_mm) weight += 1; weight += p->priority; out: This is the whole goodness function from V2.5 return weight; scheduler (only edited formatting to fit on slide). } 5
  • 7. What is the running time of the Linux 2.2-2.5 Scheduler? 6
  • 8. What is the running time of the Linux 2.2-2.5 Scheduler? 7
  • 9. 8
  • 10. Linux 2.6 Scheduler (2003-2007) 140 different queues (for each processor) 0-99 for “real time” processes 100-139 for “normal” processes Bit vector keeps track of which queues have ready to run process Scheduler picks first process from highest priority queue with a ready process Given time quantum that scales with priority 9
  • 11. Linux 2.6 Scheduler (2003-2007) struct runqueue { struct prioarray *active; struct prioarray *expired; struct prioarray arrays[2]; 140 different queues (for }; each processor) struct prioarray { 0-99 for “real time” processes int nr_active; /* # Runnable */ 100-139 for “normal” processes unsigned long bitmap[5]; struct list_head queue[140]; Bit vector of ready-to-run }; Scheduler picks first process from highest-priority queue with a ready process 10
  • 12. What is the running time of the Linux 2.6 Scheduler? 11
  • 13. (Sadly, O(1) scheduler has no Facebook page.) 12
  • 15. Rotating Staircase Deadline Scheduler This is exactly stride scheduling (but with different terminology)! 14
  • 16. 15
  • 17. 16
  • 18. 17
  • 20. What is the running time of the Linux 2.6.23+ Scheduler? Not called the θ(log N) scheduler – by Linux 2.6.23 marketing matters: “Completely Fair Scheduler” 19
  • 21. (In practice) What is log2 N? 20
  • 22. What resources should scheduler be maximizing utility of? 21
  • 23. Key Resource: Energy! Image from http://arstechnica.com/apple/2013/10/os-x-10-9/12/ 22
  • 27. Timer Coalescing Images from http://arstechnica.com/apple/2013/06/how-os-x-mavericks-works-its-power-saving-magic/ 26
  • 28. OS Schedulers Recap Use Resources Well Limit unnecessary switching, Save Energy Low cost of scheduler itself Make good decisions Locally: pick the most important process Globally: provide good system performance 27
  • 30. Web Server Overload! healthcare.gov Rate of incoming requests > Rate server can process requests 29
  • 33. “When the meetings ended at a CMS outpost in Herndon, Va., at about 7:00 p.m., the rescue squad already on the scene realized they had more work to do. One of the things that shocked Burt and Park’s team most—“among many jaw-dropping aspects of what we found,” as one put it—was that the people running HealthCare.gov had no “dashboard,” no quick way for engineers to measure what was going on at the website, such as how many people were using it, what the response times were for various click-throughs and where traffic was getting tied up. So late into the night of Oct. 18, Burt and the others spent about five hours coding and putting up a dashboard.” 32
  • 34. Developer Benchmarks • Find bottlenecks: know what to spend time optimizing • Measure impact of changes • Predict what resources you will need to scale service Goal is a benchmark that represents the actual usage 33
  • 35. Strategy 1: Shrink and Simplify Your Content 34
  • 36. 5 September 2001 11 September 2001 archive.org captures of New York Times (http://www.nytimes.com) 35
  • 37. 36
  • 38. 11 September 2001 5 September 2001 37
  • 39. Strategy 2: Cache to Save Effort 38
  • 41. “Looking over the dashboard that Park, Burt and the others had rigged up the prior Friday night, Abbott and the group discovered what they thought was the lowest-hanging fruit--a quick fix to an obvious mistake that could improve things immediately. HealthCare.gov had been constructed so that every time a user had to get information from the website's vast database, the website had to make what's called a query into that database. … The team began almost immediately to cache the data. The result was encouraging: the site's overall response time--the time it took a page to load-dropped on the evening of Oct. 22 from eight seconds to two. That was still terrible, of course, but it represented such an improvement that it cheered the engineers. They could see that HealthCare.gov could be saved instead of scrapped.” 40
  • 42. Strategy 3: Buy (or Rent) More Servers 41
  • 44. 43
  • 45. 44
  • 46. “A series of hardware upgrades had dramatically increased capacity; the system was now able to handle at least 50,000 simultaneous users and probably more. There had been more than 400 bug fixes. Uptimes had gone from an abysmal 43% at the beginning of November to 95%. And Kim and her team had knocked the error rate from 6% down to 0.5%. (By the end of January it would be below 0.5% and still dropping.)” 45
  • 47. Using More Servers Server 1 Dispatcher Server 2 Server 3 46
  • 51. 1. Replication Database Reads are efficient Server 1 Writes are complex and risky 2. Vertical Partitioning Database Dispatcher Split database by columns Server 2 3. Horizontal Partitioning (“Sharding”) Database Split database by rows Server 3 4. Give up on consistency and functionality “NoSQL” (e.g., Cassandra, MongoDB, BigTable) Database 50
  • 53. Distributed Denial-of-Service Server 1 Dispatcher Database Database Server 2 Database Server 3 x 2000 machines Botnet Database 52
  • 54. 53
  • 57. What should the server’s goal be? 56
  • 58. What is the bottleneck resource? Zhtta Disk (files) Cache 57
  • 59. Connecting to the Network ISP Router zhtta Cache Disk (files) 58
  • 60. Cisco Nexus 7000 (~$100K) 48 Gb/s per slot x 10 10 Gb/s x 4 per switch Your server 250 Mbits/s $20/month 59
  • 62. How close to this can you get for PS3? 61
  • 63. Charge Measurement (“dashboard”) is essential for improving performance Important to measure the right things! Scheduling policies: Avoid wasting resources Make trade-offs that align with system goals PS3 Due tomorrow (Wednesday) at 11:59pm If you haven’t already scheduled your demo, do so now! 62

Editor's Notes

  1. http://www.linuxjournal.com/article/3910