

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CMPSCI 377 Operating Systems
When modelling a concurrent problem using queue theory, we are basically interested in representing it as a sequence of tasks/jobs that have to be done. The general flow of items in a queue system is that one item into the queue, is eventually serviced, and the result of that processing eventually comes out on the other end of the queue. Typically, we model such systems by explicitly taking into account both the queue itself (a waiting line) and the server. For example, imagine a grocery store; most of the grocery stores nowadays have several different types of lines, such as the “regular lines”, one the “line for people with less than 15 items”. Why would a grocery store want to have multiple types of lines? Because of efficiency issues, of course; the grocery store basically tries to use less cashiers (because they cost money), and at the same time tries not to annoy the customers with long waiting times. The tradeoff here is delicate: if the lines grow too big, the grocery store might lose clients; but if we hire lots of cashiers to make the lines shorter, some of them might be idle, and then we’re also wasting money; and so on.
The usual way to model this type of activity involves calculating an arrival rate λ, which represents how often new items are inserted into the queue. Sometimes is also useful to know not only the average arrive rate, but the probability distribution of λ itself (e.g. is λ a constant rate, or is it given by a Poisson distribution, etc). Another interesting quantity, besides the arrival rate, is the servicing time: maybe the cashier always takes 1 minute to service an item, but with probability 20% the cashier can take up to 20 minutes. In general, the properties of the system as a whole depend on the size of the queue (“number of people in front of me on the line”), on how fast does the queue grow, on the type of data being processed (“how many items do the people in front of me they have in their carts”), on the speed of the server (“how fast is the cashier”), etc.
Notice that in the long run we expect the arrival rate (λ) to be equal to the departure rate; in this case, we’d have a stable queueing system. If the average arrival rate is greater, however, then the queue could keeping growing and the system would not be stable.
Typically, concurrent systems are not composed by only one queue; they might actually be formed by a chain of queues. For example, Google can implement a frontend that takes up the requests, sends them to another server that finds the relevant pages, and then this server sends those relevant pages to yet another server that renders the output; notice that each of these stages in the processing can be seen as a queueing system itself. In other words, it is possible to model this type of system as a system of connected servers. In this type of system, we care about two quantities: the latency, which is the time for one item to get through a server; and the throughput, which is the service rate, i.e., the measure of how many items the system can process per second.
For example, imagine a network with 3 nodes, each node being able to process 5 items per second. The throughput of the system in this case would be 5 items/sec. The latency, which is the time for one single item to get through, would be 3 × 15 = 35 of a second. Now, suppose that all nodes are still able to process 5 items per second, but that the second node only processes 1 item per second; in this case, the throughput would be the lowest throughput, i.e., would represent the bottleneck of the system (1 item/sec).
9-2 Chapter 9: Queueing Systems
Little’s law is a useful mathematical result which says that the long-term average size of a queue in a stable system (N ), is equal to the long-term average arrival rate (λ), multiplied by the long-term average time a item spends in the server (average latency T ):
N = λT.
Suppose that the arrival rate is of 10 items per second, and that the latency (time to process each item) is 0.5 seconds per item. This means that, on average, there will be 5 items on the queue. Now, suppose that the system changes and that suddenly the arrival rate doubles, ie, goes up to 20 items per second. In order to deal with this, either the system has to be able to cope with a queue of size 10, or it has to somehow improve the latency to 0.25 seconds of service time per item. For more details on this subject, please check the slides or visit the Wikipedia entry for the Little’s Law: http://en.wikipedia.org/wiki/Little’s_law.
When designing concurrent applications, it is hard to use threads, locks, etc, in a way that guarantees that our parallel code works correctly in all cases.
In order to simplify the design of this type of application, one can use the Flux programming language. Flux is a domain-specific programming language for building high-performance server applications. It’s a clean and simple language that lets you build fast, concurrent, and correct servers out of sequential, off-the-shelf C code. Flux abstracts away issues like threads, events, and synchronization, yielding code that runs fast and is free from deadlock or race conditions; Flux allows the programmer to separate the logic of the problem (e.g. fetching pages, parsing them, etc) from the concurrency control. Finally, Flux also makes profiling and performance prediction easier.
Now, let us discuss how Flux separates the logic of the program and the concurrency control. The approach taken by the developers of Flux is to allow the programmer to write a set of components, in a language like C or Java, and then “plug-in” those components in a graph which gives the specification of the possible concurrent flows. Therefore, each of te components represents a high-level description of one of the “step” the program can take; the graph of components, or program flow, when used together with the piece of code associated with each component, is compiled (translated) by Flux into a “real” program (i.e., binary code). This “real” program is such that it is a deadlock-free, runtime-independent server which makes full use of threads. Notice that the user didn’t write any concurrent code; all he had to do was to put the components together in a graph, in a way to specify the intended program flow.
To summarize, Flux is composes by components + flow + atomicity:
In other words, Flux takes a graph and translates that graph into a parallel program. We can think of each node as having its own queue of items it has to process; then, if we decide to analyse the throughput of the system, we can make some simple measurements on the size of the queues, etc. This would allow the programmer, for instance, to identify botllenecks, which would be much harder in case the concurrency specification was not given independently of the actual programming logic. Flux also makes it easier for