MySQL operation and maintenance 36-queuing theory

1. Queuing model

  1. Queuing : Often one has to queue in order to get a service. There is a kind of queuing that is tangible, such as the queuing waiting to buy tickets at the ticket office, the queuing of cars waiting for refueling in front of the gas station, etc.; there is another kind of queuing that is invisible, such as the queuing of the telephone call signal received by the telephone exchange, waiting for the computer center Queuing of messages processed by processors, etc.
  2. Customers : For the convenience of description, the people who line up, whether they are people, things or information, are collectively referred to as "customers" in the future.
  3. Service desk : Whether the server is a person or a thing, for example, an electronic computer can also be a server in the queuing system, and they are collectively referred to as "service desk" in the future. The service desk is used to serve customers in the queue, and multiple service desks can be used. work concurrently.

2. What is queuing theory

  • Queuing theory, also known as stochastic service system theory and queuing theory, is a branch of mathematical operations research. It is a discipline that studies the random law of queuing phenomena in service systems. Queuing theory is widely used in the design of stochastic service systems and factories, shops, offices, hospitals, etc. for resource sharing in telecommunications, traffic engineering, computer networks, production, transportation, and inventory.
  • Customers always hope that the larger the service organization, the better, but if the service organization is too large, the expenditure on manpower and material resources will increase accordingly, which will cause waste. Therefore, the purpose of studying the queuing model is to combine customer needs and service organization Make trade-offs and decisions between scales so that it strikes a reasonable balance.
  • In computing, many hardware and software components can be modeled as queuing systems. We can use queuing theory to analyze queuing phenomena, and analyze indicators such as queue length, waiting time, and utilization rate.

3. Little's law

3.1. Contents of Little's Law

  1. Little's Law is actually a formula used to calculate the average number of requests for a system.
  2. Little's law can be expressed by the following formula: L=λW. That is, the average number of access requests = average arrival rate × average service time. For example, we have a system with an average arrival rate of 10,000 requests/s, each request takes 0.05s to process, that is, the average service time is 0.05s, then according to Little’s law, the server will bear 10,000 requests at any time ×0.05=500 requested business processing.

3.2. Significance of Little's Law

Little's Law actually gives us an idea to improve the server's concurrent response: If after a period of time, due to the increase in client traffic, the concurrent access rate reaches 20,000 requests/s, in this case, how should we improve What about the performance of the system? According to Little's Law, we have the following two options:

  • Increase the concurrent processing capability of the server, that is, 20000×0.5=1000.
  • Reduce the average service time of the server, that is, W=L/λ=500/20000=0.025s.

4. Kendall queuing representation

4.1. The core elements of Kendall notation A/S/m

  • Queuing systems can be classified using the Kendall notation, which can be simplified as follows: A/S/m
    • A: The arrival rule, that is, the distribution of the arrival time interval, may be random, deterministic, or other distribution methods such as Poisson distribution.
    • S: The service rule refers to the distribution of service time, which may be fixed or exponential and other distribution methods.
    • m: number of service desks, one or more.

4.2. Representation of customer arrival distribution in Kendall notation:

  • Common convention symbols used to indicate the distribution of customer arrival intervals and service times are as follows.
    • M: Exponential distribution, in probability theory and statistics, exponential distribution (Exponential Distribution) is a continuous probability distribution. Exponential distribution can be used to represent the time interval between independent random events, such as the time interval between passengers entering the airport, the time interval between the appearance of new entries on the Chinese Wikipedia, and so on.
    • D: Deterministic (Determini stic).
    • G: Distribution of general service time.

4.3 Common queuing models expressed in Kendall notation

Some common queuing system models are as follows:

  • M/M/1: Indicates that the interval between successive arrivals of customers is exponentially distributed, the service time is exponentially distributed, and there is a single service desk.
  • M/M/c: Indicates that the interval between successive arrivals of customers is exponentially distributed, the service time is exponentially distributed, and there are multiple service stations.
  • M/G/1: Indicates that the interval between successive arrivals of customers is an exponential distribution, the service time is a general service time distribution, and a single service desk.
  • M/D/1: Indicates that the interval between successive arrivals of customers is an exponential distribution, the service time is a deterministic time distribution, and a single service desk. For example, our rotating disk can be analyzed with this model.

5. Summary

  1. The performance of MySQL and other systems can be modeled by using the queuing model. The queuing model mainly includes two core elements: customers (queueers) and service desks (servers).
  2. Little's Law: Average number of requests = average arrival rate × average service time. According to Little's Law, if we want to adjust one of the variables, we need to change the other two variables.
  3. The common queuing model can be represented by Kendall notation, which mainly includes three elements of A/S/m, which are arrival rules, service rules and the number of service desks.

Guess you like

Origin blog.csdn.net/oddrock/article/details/130332778