The post has been translated automatically. Original language: Russian
There are not enough iron plates in the factory at Factorio. You install ten more furnaces, connect them to the conveyor belt, and expect production to grow. After a minute, it is clear that some of the furnaces are idle. The same amount of ore comes in as before, and the new furnaces simply share it with the old ones.
The section that limits the performance of the entire line is called a bottleneck. In our case, this is the supply of ore. To understand exactly where the problem is, you need to check the extraction, delivery and loading of furnaces.
How to find a bottleneck
Let's imagine that a mine produces 120 units of ore per minute, and furnaces can process 180. If all the ore reaches the furnaces, the line produces 120 iron plates per minute. We will double the furnace capacity to 360, and the output will remain the same. And if the ore supply is increased to 240, the same furnaces will be able to produce 240 plates per minute while the conveyor manages to take them away. The numbers are conditional, but they show which section sets the limit in each case.
For one reason, the reason can be guessed incorrectly. An empty belt in front of the furnaces may mean that the mine is producing little ore or that some of the ore is being taken by another line. If the plates accumulate at the outlet and the furnaces stop, it is worth checking where the finished products go.
Where is it found in IT
Let's imagine an online store where a catalog is slowly opening. The command adds a second application server. Now both servers can accept requests, but both still access the same database. If the main delay occurs there, additional servers may increase the number of requests that the database must serve at the same time.
It is useful to measure the path of a single request here. How long does the processing take in the application? How much is waiting for the base? If the main delay is due to a database query, you can examine its execution plan and see if the index helps. After the change, you need to repeat the measurement at the same load. The delay may be reduced, and the next limitation will be found on another site.
Before expanding the system, find out which section is currently setting its limit. In Factorio, this can be seen by the movement of the ore and plates. In the application, it's based on where the query spends the most time.
На заводе в Factorio не хватает железных пластин. Вы ставите ещё десять печей, подключаете их к конвейеру и ждёте, что производство вырастет. Через минуту видно, что часть печей простаивает. Руды поступает столько же, сколько раньше, и новые печи просто делят её со старыми.
Участок, который ограничивает производительность всей линии, называют узким местом. В нашем случае это подача руды. Чтобы понять, где именно проблема, нужно проверить добычу, доставку и загрузку печей.
Как найти узкое место
Представим, что шахта выдаёт 120 единиц руды в минуту, а печи могут переработать 180. Если вся руда доходит до печей, линия выпускает 120 железных пластин в минуту. Удвоим мощность печей до 360, и выпуск останется прежним. А если увеличить подачу руды до 240, те же печи смогут выпускать 240 пластин в минуту, пока конвейер успевает их увозить. Числа условные, но по ним видно, какой участок в каждом случае задаёт предел.
По одному признаку причину можно угадать неправильно. Пустая лента перед печами может означать, что шахта добывает мало руды или что часть руды забирает другая линия. Если же пластины скапливаются на выходе и печи останавливаются, стоит проверить, куда уходит готовая продукция.
Где это встречается в IT
Представим интернет-магазин, в котором медленно открывается каталог. Команда добавляет второй сервер приложения. Теперь оба сервера могут принимать запросы, но оба по-прежнему обращаются к одной базе данных. Если основная задержка возникает именно там, дополнительные серверы могут увеличить число запросов, которые база должна обслуживать одновременно.
Здесь полезно измерить путь одного запроса. Сколько времени занимает обработка в приложении? Сколько — ожидание базы? Если основная задержка приходится на запрос к базе, можно изучить его план выполнения и проверить, поможет ли индекс. После изменения нужно повторить замер при той же нагрузке. Задержка может сократиться, а следующее ограничение обнаружится уже на другом участке.
Прежде чем расширять систему, выясните, какой участок сейчас задаёт её предел. В Factorio это видно по движению руды и пластин. В приложении — по тому, где запрос проводит больше всего времени.
Comments 4
Newest Popular