3. introduction to data buffering and disk scheduling for ...enpklun/eie552/buffering.pdf · –...
TRANSCRIPT
1
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
3. Introduction to Data Buffering and Disk Scheduling for
Multimedia Servers
via Network to Clients
buffers
:
:: empty
filled
Disks
2
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
ReferencesD.J. Gemmell, “Disk Scheduling for Continuous Media”, Chapter 1, Multimedia Information Storage and Management, Kluwer Academic Publishers, 1996.K.K. Ramakrishnan, L. Vaitzblit, C. Gray, U. Vahalia, D. Ting, P. Tzelnic, S. Glaser, and W. Duso, “Operating System Support for a Video-on-demand File Service”, Multimedia Systems, pp.53-65, No.3, 1995.D.J. Gemmell and J. Han, “Multimedia network file servers: multichannel delay-sensitive data retrieval”, Multimedia Systems, pp.240-252, No.1, 1994.
3
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
ContentsIntroduction to On-demand Media ServersMulti-stream Scheduling– Disk placement policy for multi-stream– Buffer conservation– Admission control– Disk scheduling– Data replication and striping
4
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
3.1 Introduction to On-demand Media Server
5
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
A simplified model for Internet multimedia system
Clients
bufferbuffer
bufferbuffer
bufferbuffer
buffer
bufferbuffer
bufferbuffer
bufferbuffer
DISKs
buffer
Media Server
Internet
DISKs
buffer
Media Server
Proxy
Proxy
Other networks
6
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
On-demand multimedia servicesProvide high quality on-demand multimedia services is the goal of current Internet multimedia streaming research Critical components in the design of multimedia services are – Multimedia storage servers
Able to support efficient multimedia data retrieval and storage
– Network infrastructureEnable multimedia data delivery with quality of service
– Client support (critical only in some environments, e.g. mobile)
Playback the received multimedia data in the best quality
7
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Design consideration of on-demand multimedia servers
Video and audio are continuous media (CM)– Convey meaning only when presented in time
– Interaction between media streams further require accurate timing when presenting the data
– Hence multimedia servers need real-time response
On-demand multimedia servers may receive enormous requests for service at any instance of time – Servers need to cater for worst case situation
– Need effective schedule in using the resource
8
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Ideal on-demand multimedia servers
An ideal on-demand multimedia server should have the following attributes:– Have enough storage capacity for all on-line multimedia items– Can respond to user request with minimum latency– Can deliver multimedia services in time– Require the least amount of memory storage for buffering– Impose the lowest buffer requirement to the clients – Impose the lowest processing power requirement to the clients
Usually trade-off is required to makeTo keep a good balance is the objective of current research
9
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
How about using the conventional file server?
Conventional file server cannot achieve the task since– does not guarantee real-time delivery of data
Retrieve and store data in a best effort manner
– does not consider the continuous nature of media dataMedia data can be fragmented in the hard disk hence unnecessary disk arm movements are introduced
– does not aware of the huge file size and enormous request of services in worst case
Can lead to starvation due to inefficient use of resource
10
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Disk bandwidth is one of the major concerns
Mbytes/sec Growing very fastHow about serving 1000 customers each with 2.5Mbps (MPEG-2)?⇒ 312 Mbytes/sec!
Besides, does the disk bandwidth can be fully exploited?– Decrease by seek time,
rotational latency, and othersExtracted from www.adaptec.com
Resource constraints within a server
11
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Seek time and rotational latencyDelay is introduced for the disk arm to locate at the required position on the diskSeek time - time to move the read-write head to the new radial positionRotational latency - time it takes for the target sector to rotate under the headFor example– Seagate Cheetah 73 : 73.4GB SCSI Ultra160
10033RPM (worst case rotational latency 5.98ms), seek time 5.85ms avg
The delay is enough to transfer 1.8Mbytes of data!
12
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Disk storage capacity needs to be carefully considered– Total size of video files kept on-line cannot exceed disk space
– Depend on the quality, multimedia file can require a very large disk storage
Digital Video (DV) - 10GB per hourMPEG-2 - 1.1GB per hourMPEG-1 - 450 MB per hour
– To improve the redundancy and performance, items may be replicated in a disk
– Can be expensiveSeagate Cheetah 73 : 73.4GB SCSI Ultra160 costs USD1,070
– Disk storage should be hierarchical so that only popular items are kept on-line
Other resource constraints - Storage
13
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Other resource constraints - Memory
via Network to Clients
buffers
:
:: empty
filled
Disks
• To support multiple clients, need buffers to read-ahead• All buffers receives a chance of being refilled in each
round of service (time = service period)• Disk overheads(seek and rotation) are incurred• Must refill buffers before under-run; must not over-run
buffers (i.e. do not read more than the buffer can store) • Need an efficient scheduling algorithm
14
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
3.2 Multi-stream Scheduling
15
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Disk access model
via Network to Clients
buffers
:
:: empty
filled
Disk
• Each buffer has its turn to be read or to be filled• A server is said to complete a round of service by giving one
service to refill the buffers of each stream• Such process are repeated periodically• Depend on the disk scheduling policy, each buffer will be filled
in a specific order (i.e. may not be sequentially)
16
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
A. Disk placement policy for multi-streamContiguous Non-Contiguous
Trackno.
0
n• Avoid excessive seek time• Can fully utilize disk storage for
write-once-read-many access• Will have fragmentation problem
if the file is frequently updated• May need off-line defragmentation
• Reduce greatly the disk bandwidth due to the increase of seek time
• Can fully utilize disk storage for write-many-read-many access
• Use in traditional file systems
17
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
admission playing startsservice starts service ends
Buffered data
time
playing endsstarvation
d1 d2 d3
• The time to refill can change from time-to-time• Depend on the number of clients admitted and the disk
scheduling policy• To avoid starvation, the buffer size and admission control
are important
B. Buffer conservation
18
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
pmax and dmax
p1 p2 p3
d2d1
time
• pi is the time for each round• controlled by the number of clients admitted
• di is the time for two successive read• controlled by the number of clients admitted and the disk
scheduling policy • The maximum possible p and d are called pmax and dmax
• dmax ≤ 2 pmax and pmax ≤ dmax
19
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
A simple algorithm to avoid starvation - Buffer conservation algorithmAssumptions• Data of all streams are placed in the contiguous mode on the disk• The consumption rate of the network to the buffer is constant and
is denoted as rc
AlgorithmPre-fetch rcdmax bytes of data into the buffer before the serviceFor each round
Let the current content in the buffer is fif (rcdmax - f) > rcpmax
read rcpmax from disk and add to buffer else
read rcdmax- f bytes from the disk and add to buffer
20
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
p1 p2 p3
d2d1time
Buffered data
time
no need
rcdmaxrcpmax
f1
f2
p4
d3
21
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Explanation• To the worst case, dmax = 2pmax
• Case 1
pmax
d2d1 = dmaxtime
Buffered data
time
rcdmax rcpmaxf1
pmax pmax pmax
No starvation at anytime
f2
22
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Explanation• To the worst case, dmax = 2pmax
• Case 2
pmax
d2d1 = dmax
time
Buffered data
time
rcdmax rcpmaxf1
pmax pmax pmax
No matter when the maximum data consumption is required, no starvation is occurred
d3 = dmax
f2
rcpmax
f3
23
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Since the average data consumption to the buffer is rcpmax, the refill of rcpmax in each round achieves buffer conservation
⇒ operations in a reading period never lead to a net decrease in data buffered for any channel
The only condition that the refill cannot achieve rcpmax
is when there is not enough free space in the buffer
In this case, the buffer storage is top-up to rcdmax, which is the maximum data consumption of the buffer
Hence starvation is not possible
24
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
It seems from the result above that the lower bound of buffer size is rcdmax
Unfortunately, for most hard disks, basic unit of disk access is a sector
Assume the sector size of a particular disk is s, the minimum buffer size is
It indicates that extra space is required to store the whole sector although only 1 byte is required
Buffer size lower bound
Minimum buffer size = rcdmax + s -1
25
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
C. Admission control
Since pmax is directly determined by the no. of clients in the system, admission control is very important
where N is the no. of clients and α is the time to serve each client
pmax = α N
α = disk overhead + disk read timedisk overhead = seek time (ts ) + rotational latency (tr )
disk read time = rc pmax / disk data rate (rd )* Here we assume that the bottleneck is on fetching data
from disk but not pushing data to the network
26
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
It is seen that the relationship between pmax and N is
recurrent N ⇑ ⇒ pmax ⇑ ⇒ α ⇑ ⇒ N ⇓
N
Buffer size
Typical relationship between buffer size and N
When α is dominated by the disk overhead
When α is dominated by the
disk read time
d
crs r
prtt
pNmax
max
++=It can be shown
that(a)
α
27
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
N is limited by the total memory available (M) for buffer
Here we assume that all streams have the same rate rc
It is seen that, again, it is a recurrent relationship
M ⇑ ⇒ N ⇑ ⇒ pmax ⇑ ⇒ dmax ⇑ ⇒ N ⇓
Hence increase memory does not necessarily increasenumber of clients
N(rcdmax+ s - 1) < M
M
N
Typical relationship between M and N
(b)
28
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Combine eqns.a and b and assume the worst cases
dmax = 2pmax, tsmax = the maximum seek time, trmax = the maximum rotational latency, we have
( ) Ms
rNr
ttNrN
d
c
rsc <
−+−
+ 11
2 maxmax(c)
Here we need to ensure that total consumption rate rcN should be smaller than the disk data rate rd
29
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
A Simple Algorithm for Admission Control
Given M, ts , tr , rc , rd and sFor a new request from client such that the total number of clients is N
if rcN > rd
reject request else if eqn.c is satisfied
admit request else
reject request
30
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
D. Disk schedulingThe disk overhead can greatly reduce the number of clients in the system
The disk overhead can be reduced by using a good disk access schedule
Disk scheduling ≡ ordering of service
Approaches– Control the order of service (refilling) and reduce the seek-
length incurred between reads.– Avoid seeks that can occur within a disk read.– Reduce rotational latencies between reads.
31
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Round robin scheduling
Append service of new stream at the end of recurrent scheduleRetrieve data from disk in the same order of requestCan lead to a great disk overhead due to many track seeking
time
Head position
RR
32
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
SCAN schedulingRefill stream buffers according to cylinder positions on both inward and outward sweeps of the disk-armOptimized to minimize the seek timeMay require large buffer since worst case inter-service time can be 2*service period
time
Head position
SCAN
AB
C
D
E
AB
C
D
E
worst case
33
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
CSCAN schedulingRefill stream buffers according to cylinder positions only on inward sweep (or outward sweep) of the disk-armA balance to seek time and buffer size
time
Head position
CSCAN
34
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Maximum seek time of schedulesIt is given that the seek time may be approximated by the following linear function
ε+−
−−+=
1)1(
max
minmaxmin S
TTstTts
whereTmax and Tmin are the maximum and minimum seek time as shown in the specification of the disk drivest is the number of tracks to be soughtSmax is the maximum number of seeking trackε is a constant depend on the drive
(d)
35
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Consider in each round, j streams are to be read that leads to j seeks (assume one seek per stream and the data of each stream are located at different track)Assume for the i th seek, sti tracks are to be soughtThe total seek time is
ε
ε
jjstS
TTjT
STTstTt
i
j
i
j
iistotal
+−−
−+=
+
−−
−+=
∑
∑
=
=
)(1
1)1(
1max
minmaxmin
1 max
minmaxmin
36
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
For Round Robin scheduling method, the number of tracks to be sought is random. Consider the worst case
222)1)(2(2
)1)))(1(()1(()1(
))1((...)2()1(2max
maxmax
maxmaxmax
maxmaxmax1
−+−−=
−−−+−+−=
−−++−+−≈
∑=
SjjS
jjSSS
jSSSstj
ii
Trackno.
1
Smax
Always swing to the opposite end
time
37
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
For SCAN, the maximum total number of tracks to be sought in each round is bounded to be Smax
1max max1
−=
∑=
Sstj
ii
For CSCAN, the maximum total number of tracks to be sought in each round is bounded to be 2Smax
)1(2max max1
−=
∑=
Sstj
ii
38
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
εjjSjjSS
TTjTtRRs +−
−+−−−
−+= )
222)1)(2((
1maxmax
max
minmaxminmax
Hence the maximum seek time for each scheduling method is as follows:
εjjSS
TTjTtSCANs +−−
−−
+= )1(1 max
max
minmaxminmax
εjjSS
TTjTtCSCANs +−−
−−
+= )22(1 max
max
minmaxminmax
39
E. Data replication and stripingWhen multiple disks are available, titles can be replicated according to their popularity
Title A Title A Title A Title A
Title C Title B Title C Title C
Title D Title E Title F Title G
Data replication increases the number of clients in the system with the cost of using up more storageRequire prior information about the title popularityShould update constantly
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
40
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Striped Retrieval
Not all clients are watching the same part of a titleTitle can be striped and placed on different drives
A1
A2
A3
A4
Provide same of amount of bandwidth and serve same amount of clientsThe storage is much reduced
41
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
If the size of each stripe is large, it is highly possible that a large no. of clients will make request to a single disk
To achieve better load balancing, each stripe should be further divided into smaller unit, e.g. disk block and distributed to different disks, known as cyclic striping
A1
A2
A3
A4
Large stripe Small stripe
0 to 1 hr 1 to 2 hr
2 to 3 hr 3 to 4 hr
All requests in the first
hour will be sent to the first disk
0 to 10 sec10 to 20 sec
20 to 30 sec
30 to 40 sec
40 to 50 sec
42
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Time(A,1)
(B,1) (A,2)
(C,1) (B,2) (A,3)
(D,1) (C,2) (B,3) (A,4)
(x,y) = title x block y
=Seek time
To minimize the seek time between read, the SCAN or CSCAN scheduling may be applied to each diskThat is, data on nearby track should be read first
(A,5) (D,2) (C,3) (B,4)
1 round
43
DEPARTMENT OF ELECTRONIC AND INFORMATION ENGINEERING
Internet Technology for Multimedia Applications
Final comments• Much research is doing to cater for different practical
situations• Streaming with variable consumption rate•Disks with variable disk data rate• Supporting hypermedia• Supporting VCR function • and many other
• Even built correctly, a streaming server can only deliver 60% to 80% of the aggregated disks’ raw bandwidth• Anything done wrong, may get as little as 10%