On Performance Evaluation

Evaluating performance of a system , another fancy name being benchmarking X, is as much of an art as a science. An art because there are many things to measure and report, and because visualizing the results is a creative endeavor. A science, or more of an engineering nature, because it involves designing, implementing, executing and collecting experiment results. Any computer scientist worth his salt would also want to automate the above process with complex scripts.

Many textbooks are written in this subject, the classic one being “The art of computer performance analysis”. However, there is a big gap between what are covered in books and what are being practiced (or field wisdom). I truly admire people from systems communities who polish their art through countless practice and real project experiences. If you are working on a mature field, for example databases or operating systems, chances are high that there are well established tools and benchmarks, to which you simply add your system as a new backend. Let’s take LevelDB as an example. It is storage engine implementing a log structure merge (LSM) tree. It comes with a well written tool, , that tests various properties of the storage. Suppose you are designing a new LSM storage that significantly improves LevelDB, you simply modify and run it with LevelDB and with your system back-to-back. The result is a clear, clean, and scientifically sound comparison.

Here I include a few notes on how to conduct sound evaluation of systems offering services over the network. Some of these are drawn from my own experience, some are learned from papers such as [1] (the fact that papers about experiment methodlogies and frameworks are still being published at top-tier venue goes to show that people are still struggling with doing evalution right). Given a server, we are going to write benchmarking tools running at clients and issuing requests to it, then measure and report two metrics: throughput and latency distribution. For online service, we do not want latency summaries like mean or median, but the entire distribution because what happening at the tail are very important. When designing evaluation experiments, there are many variables: number of clients, types of clients (open vs. closed loop), threads per client, connections per client, request rates, request distribution. How to navigate this space? And that’s not it. Another challenge is how to implement data collection efficiently to avoid interference with the experiments.

I want to emphasize one thing first. The following is true, at least from my experience, whether or not is a single machine or a distributed systems of many nodes.

Most of the resources, in terms of number of machines, are spent on running clients. For example, if you’re paying for machines on AWE to run your experiments, the clients eat up almost all the budget.

The above insight did not come to me naturally. I spent most of my PhD time on distributed simulation, and when you want to evaluate a system with simulation, normally you don’t even need a separate client. Also, I may be forgiven for thinking that the client’s tasks are so cheap compared to server’s that one is client is enough to saturate the server. This is true when the server is doing CPU-heavy stuff, for example a HPC server. But for a server offering network services, it’s an entirely different story.

Variables

A rule of thumb when doing experiments is: vary one variable, keep the rest. If results are plotted against more than one variables, people will invariably ask which variable is responsible for changes. It is your job to avoid people asking that question.

Now, in our setting, here are the variables:

Variable Description
Application logics, e.g, uniform, skewed, read-heavy or write-heavy
Number of client machines
Type of client, e.g., open or closed loop
Number of threads per client
Number of global connections (or clients)
Number of outstanding request per connection
Mean arrival rate (time between two requests)

Given an experiment configuration , Figure 1 below depicts how the variables are implemented. This is the implementation in [1] and [2], but I believe other tools have similar designs.

Figure 1 - Client implementation

is easy to deal with by having some switches in the client.

  • Each client (each of the clients) launches threads. There is one control thread (which is the main thread) that coordinates others.
  • Each client starts connections to the server per thread.
  • Each client has a number of outstanding requests , and can send only when (it is called available).
  • Each thread does the following in an infinite loop:
    • It pick a connection that is available, send, and decreases that connection’s .
    • If a response is received in a connection, it updates the corresponding .

Load vs. Workload

One of my ah-ha moments is to realize that load is different to workload.

  • Load: the number of requests received at the system. This should be varied. Note that I consider load as what the client generates, which may differ to what the system experiences. The latter is called offered load. Sometimes, the client may think it generates a high load, but what received is actually very small.

  • Workload: the characteristics of requests, plus the mechanics of generating load. This is fixed (per set of experiments). In the past, when people say read-heavy vs. write-heavy workload, they refer to characteristics of the request distribution. But when they say Visa workload vs. cryptocurrency workload, what they mean is load.

Load Generator

We want to generate load such that it approximates how the system would be used in practice. Therefore, a load generator typically falls into two categories. In this section, I use “clients” and “connections” interchangably. I will revert to their original meaning when discussing experiment design (next section).

  • Closed-loop: there are clients, each sends a request, blocks until it receives a response, then thinks for time , then sends again. This model resembles what happens at (deep) backend servers, like databases or key-value stores. As will be made clear later, these servers have strict admission control, and their utilization/loads are carefully monitored.

  • Open-loop: the is an infinite number of clients, . An open-loop client first sends a request, wait for appropriate inter-arrival timeout, then sends a new request. Note how it doesn’t wait for the request to finish before issuing a new one. This model reflects what happen to a user facing service, like a web server, which does not want to reject users.

So the question is: which model do you choose? Beside These models have a number of interesting properties.

Both models can issue the same load

People have been analyzing these two models with queue theory. An excellent note on the theory is by Donald Krossmman [5], so good that it’s worth making a digression here.


\begin{digression}

Queue theory

Let be the mean arrival rate, be the server’s mean service rate (how many requests leave the system per second, or throughput), be the response time which includes both service time and queueing time. Note here that is different to service time which is . Gil Tene gave a good rant on the distinction in [4]. Then Little’s Law says that, regardless of the distribution of any of the random variables:

where is the mean number of requests in the system. includes both requests being queued and ones being serviced.

Operational laws

Little’s Law is remarkably simple, given the number of hidden details that need to be satisfied before one can use that beautiful equation.

  1. All and are random variables. That is, they are outputs of certain stochastic processes.

  2. Such stochastic processes are stationary, i.e., distributions of these random variables are unchanged. They are also ergodic: they converge to some value over time.

  3. The request are from a Markov process.

  4. The system is at equilibrium. I’m not hundred percent sure what it is, but would guess that it is at that converged state of the stochastic processes.

To use Little’s Law in its original form in practice, one must justify all these five condition holds for the system under consideration, which is a hard ask. Even if these are true, the law only holds over infinitly observed sequence of values. It means for a finite period of observation, the law is almost always useless.

What a mortal scientist actually does in practice is to observe the system for time and measure some quantities (or variables). And what he cares most is to derive precise mathematical equations between these variables. Precise as opposed to probabilistic. These equations are called operational laws, and they are considered fundamental laws of computer performance [6]. We are probably using it all the time without ever realizing.

Variable Description Value
Observation period Fixed
Number of arriving requests Measured
Amount of time the system is busy Measured
Number of completions (requests leaving the system) Measured
Arrival rate
Throughput
Service time
Utilization
Response time per request Measured
Number of requests in the system

For example, suppose we observe that a disk can service requests per second, and that each requests takes , then the utilization is . Suppose that an user observes a response time of , then there are in average requests in the systems.

Reconciling operational laws with Little’s law

The last law above looks strikingly similar to Little’s law. We can reconcile them by making a simple assumption.

Flow balance assumption:

This assumption is easy to test: just measuring them during T. And you can easily choose long enough that it is true with a very high probability. So this is considered true by default. With this, we have

Another direct mapping from an operational law to Little’s is the utilization law. Suppose there is no queue, the number of requests in the system is either (when the system is not busy), or when it is busy. Furthermore, because of no waiting time. Then utilization, being the average time when the system is busy, is exactly . In other words:

.

Important use of operation laws. They are extremely useful as a consistency check: whether the measurements reported are consistent with each other. For example, a paper describes an experiment with clients, then reports some numbers for throughput and latency. A sanity check is that the values satisfy . If not, clearly something is wrong. Another popular use of operational laws is to compute value of a third value givens the other two. For instance, service time and throughput may be easier to measure than utilization, but we can apply to compute utilization.

What is load?

Recall that load is the number of requests sent to the systems, or . Under the flow balance assumption (which is true by default, or by careful selection of ), . can be interpreted as scaled offered load (normalized by ). The system is only interesting when . When , meaning that , the system is unstable because the queue grows to infinity. is a possibility, but it is a bad idea pushing the system to this state [4], because by randomness some values will push the systems over the edge.

It is useless to study how the system behaves when it saturates, you only want to push that saturation point further, or to make sure that performance before saturation is good enough.

\end{digression}


Now with this fundamental law, , the load is . However, its interpretation is different based on whether the system is open or closed loop.

  • For closed loop, we can only control and . and are measurable quantities of the system. The load , which is also the throughput, is given by . The system is self-stabilizing, that is, you can increase to be very high, but then will also increase such that remains as its peak value. This suggests an easy way to measure the system’s peak throughput: is the proxy for load, increase it will increase the load until it reaches the peak throughput, after which the throughput will not increase. Here is what it looks like

Figure 2 - Varying to find peak throughput. for simplicity.

We can check for consistency of the two figures by using the operational law. This same graph also illustrates connection scalability, as the system often incurs overheads for each connection. Indeed, throughput decreases after the peak because of overhead in handling many concurrent users/connections.

  • For open-loop, we can control . and are measurable quantities. In a closed-loop generator, when we fix , there is always requests in the system. But in an open-loop system, fixing only guarantees the mean number of requests in the system, thus there can be more than at a given time. Under open-loop, the system can be come unstable. That is, we cannot increase forever, because as soon as both and grow without bound. Remember the utilization rule discussed earlier. Here is what it looks lie.

Figure 3 - Varying .

Compare this to Figure 2, and see how response time shoots up to infinity at the knee, as opposed to growing (super-)linearly with .

Their latency distributions are different

We have seen that open and closed loop generators behave differently at and beyond saturation. How about before saturation, i.e. . We are specifically interested in tail latency, which is very important at scale. Before moving on,

Latency is only meaningful under a given load. That is, when comparing latency of two systems, they must be under the same load.

The tail latency is a function of maximum queue length. In closed loop, there can only be a maximum of requests, so the tail latency is bound by . In open loop, is a function of which is a mean of a random variable. If the distribution is uniform (or fixed), then is a constant. However, in practice it is often a Poisson distribution, which has no bound on the maximum number of requests per second: there can be a time (very rare) when many many requests arrive at the same time. It means the worst queue length can be very large, which means the worst latency has no bound. Because of this, for system handling with open-loop requests, people are mostly interested in the magnitude of the latency.

Figure 4 - queue length distribution. Lifted from [3].

Figure 4 illustrates queue length distributions for closed loop and open loop. For the former, the CDF reaches at the exact number of connection. In contrast, for the open loop, the CDF has much longer tail it seems to never reach . Another important observation is that increasing pushes the curve further to the right.

It is proven that open loop latency is the limit behavior of closed loop latency, as .

Two Experiments You Must Do. And How to Do It

When evaluating a system, or comparing multiple ones, two things you must at least show people are peak throughput and latency under various load.

Determining peak throughput

What you want to show is Figure 2: varying and measure throughput. Ideally, you would have as many machines as possible to push the load to the peak throughput, i.e., . But resource constraints means , therefore each machine must create multiple connections. Maintaining one connection, however, is not cheap, and we do not want the client to be the bottleneck. In particular, we cannot cram a large number of connections to one clients because the CPU will then be busy switching between them rather than doing real work (of sending and receiving messages). Suppose you have created as many connection as possible per machine but it is still not enough, then what to do?. The trick here is to have more than 1 outstanding requests per connection, to make it look as if there are more connections.

Suppose we have physical machines as clients, and through offline benchmark we know that each client can have up to connections and outstanding requests per connection. I would plan my experiment as follows:

  1. Set

  2. Increase the number of clients from to and measure the throughput.

  3. If the pattern looks like Figure 1, we finish.

  4. If , we increase the number of connection per clients, c++, then go back to Step 1.

  5. If , we increase number of outstanding requests per connection, , then go back to Step 1.

  6. We don’t have enough resources. Acquire more!

At the end of this set of experiments, we should be able to say what the peak throughput is, what the value of at that peak, and whether the system is scalable with respect to the number of connections.

Showing latency under varying load

The purpose of this experiment is to show tail latency as a function of load, i.e. we want to show something like the blue line of Figure 5 below.

Figure 5 - Tail latency as a function of load. Redrawn based on a figure in [1].

Recall that we want to generate open loop loads in order to achieve realistic tail latency. Once the desired load is attained, a closed loop client can issue requests and measure latency. It seems clean and easy to have distinct load and latency client.

Writing an open loop load generator

Imaging writing an open loop load client. That client would:

  • Create a connection to the server.
  • It would send a request according to interval , such that the global load is .

One client isn’t enough, because it cannot generate request fast enough when high load is required. Even if there are enough clients and CPUs to keep up with the rate, client’s limited bandwidth may lead to request queueing, therefore introducing client bias to the load received by the system. To overcome this, we need to have enough client machines to create a sufficiently large number of connections to the server.

Generating open loop load with closed loop clients

One important theoretical results mentioned earlier is that behavior of a closed loop system with large approaches that of an open loop system. So if there are enough client machines, we can use the closed loop client described earlier.

The choice of client

Given these two options, both Lancet and Mutilate use closed loop client. One argument for this has been that closed loop implementation is more simple, but I think it is not entirely true. In fact, open loop may be less complex because each connection doesn’t have to keep track of how many more outstanding requests it can send. Nevertheless, there are practical reasons to choose a closed loop implementation. First, even in closed loop we need to use a large number of to saturate the system, so large that its behavior already approximate that of an open loop. Second, there is a greater degree control in closed loop, since we can bound the maximum resource at the client in terms of . In contrasts, the maximum resource needed for open loop has no bound, because for each the maximum rate is .

Extending closed loop client

We modify a closed loop client to support open loop load as follows.

  • All the setups of threads, connections stay the same.

  • Each thread per client machine now has a random number generator that generate inter-arrival time with the mean .

  • Each thread uses that random number generator to set a time in the future for the next message, next_ts.

  • Each thread then does the following in an infinite loop:

    • If the current time passes next_ts:
      • It picks an available connection (whose ) and sends it.
      • It updates next_ts
    • If a response is received on a connection, it updates the corresponding .
    • Otherwise, it spins.

Experiment design

Having decided to use closed loop clients to simulate open loop load, the experiment plan now goes like this:

  1. Use the previous experiment to select that achieve peak throughput. Note here that the minimum values are ones at the saturation point. However, if we have large enough such that and then we can choose a higher , i.e. beyond saturation. The reason is that we want as large as possible. But not too large, only as long as it does not lead to throughput drop. Many systems exhibit a throughput pattern that increases to the peak, plateaus there for while, and then drops.

  2. For each value of , measure the tail latency.

  3. Plot the result.

Step 1 is extremely important, because what are selected at the end, namely , is part of of the workload.

Number of connections is part of the workload, i.e. fixed for the latency experiments.

The red line of Figure 5 illustrates a problem when Step 1 is not followed strictly: is too small. When is below the saturation point in Figure 2, even if we push to the peak throughput, the actual load generated is still not enough to saturate the system. When is sufficiently large, we should expect a knee as in Figure 3 or the blue line in Figure 5. Instead, the red line stays almost constant, leading to a wrong conclusion, that the peak load is somewhere further to the right.

It does show one correct behavior, though. As load increases, having more connections better estimate open loop tail latency (which should be higher than closed loop latency).

Acknowledgement

I learned a lot from personal correspondence with the authors of [1]. Just want to give them another shout-out for releasing the source code.

References

[1] Marios Kogias et al. Lancet: A self-correcting Latency Measuring Tool. Usenix ATC 2019

[2] Mutilate: high-performance memcached load generator. https://github.com/leverich/mutilate

[3] Treadmill: Attributing the Source of Tail Latency through Precise Load Testing and Statistical Inference. ISCA 2016

[4] How to measure latency (Strange Loop)

[5] Queuing theory https://www.systems.ethz.ch/sites/default/files/file/Spring2013_Courses/OSN_Spring2013/Lectures/5_chapter5-Queues.pdf

[6] The operational analysis of queuing network models

Written on July 24, 2019