Many people say Factorio is a must-play game for software engineers. Shopify even lets employees expense it as a personal purchase. Here are some lessons I picked up after playing.

Shopify lets people expense factorio. This idea is spreading 👌 https://t.co/lTnDKDDrmO — tobi lutke (@tobi) February 13, 2022

There’s an interesting quote I found on a blog about this Shopify perk:

…Shopify’s decision to let employees expense the game a very clever one indeed: it’s quirky perk, partly a way for leisure time to build better habits—and partly a way to give more people a shared vocabulary for which business problems can be solved, and how to solve them.

What Kind of Game is Factorio, Anyway?

factorio-switch-2-release-space-age

The premise is simple: you’re stranded on an uninhabited planet. Your rocket is wrecked. Your job is to build a new rocket and launch it into space. To get there, you need to research and build everything from scratch, from smelting raw iron and copper ore all the way up to crafting low density structures.

Why does Factorio resonate with software engineers? Because at its core, the game is about problem solving and automation. These two things are daily bread for engineers, so the problems you encounter in the game often map directly to work.

Imagine a Website

Before we go further, let’s pretend we’re a full-stack engineer managing a website. To align the terminology, think of this website as a factory. Every factory has input, processing, and output. In manufacturing, input is raw material, output is finished goods.

Translated to website terms: input comes from users, whether it’s visits, adding items to a shopping cart, or something else. The website processes that input. The output is data back to the user, maybe an invoice or just a news article.

In the following sections, I’ll draw parallels like this and translate them into Factorio terms, and vice versa.

Learning to Scale Up

In Factorio, you’ll face all sorts of problems. There’s no right or wrong way as long as you solve them. And just like in the real world, every solution has its pros and cons. The first problem you’ll encounter is “how do I produce X?”

Take a look at this illustration: FIG1: A simple Steel Smelter This is a basic steel factory. One steel bar is made from 5 iron plates. An iron plate is made from one iron ore. And you need coal to fuel the furnace.

That’s a simple solution for “how do I make a steel bar.” But it produces one bar every 16 seconds. It’s like your website can only handle 10 requests per minute. How do you increase the output? Horizontal and vertical scaling, very familiar to software engineers.

Here’s an example of horizontal scaling. Basically, you add more furnaces. But those furnaces need coal and iron ore, so the materials are delivered via conveyor belts. In software engineering, this means adding more servers. The furnaces are your servers. User traffic needs to be distributed across them, so the conveyor belt is essentially your load balancer. FIG2: A Steel Smelter setup that’s easy to scale You can build a production line like the one above, but there’s no fixed blueprint in Factorio. Players are free to design their factories however they want. That’s why creativity is constantly tested in Factorio, and it can train your creativity as a software engineer to see beyond just one solution.

One advantage of this production line is how easy it is to expand. I just copy two rows of furnaces like below to provision the next line. Kind of like deploying servers 😄. FIG3: Copy & paste a similar pattern The problem that emerges from this production line is the shrinking raw material input, because there are now more processors consuming it. Output > Input. That means the input channel needs to be widened. One way is to upgrade to faster conveyor belts (FIG4). In software engineering, this could mean ordering more bandwidth from your hosting provider. For cloud hosting, this is usually baked into the usage cost 💸. FIG4: Low bandwidth problem, upgrade Yellow Belt -> Red Belt

Overengineering

Relevant XKCD Imagine one day the marketing team asks a software engineer for help building a landing page (not a true story). After finishing, the engineer takes the initiative to build a Content Management System for landing pages. The hope is that next time, marketing can build them on their own without engineering support.

As it turns out, marketing never requests another landing page. After looking into it, the first test didn’t meet expectations (again, not a true story). The CMS ends up unused. You’ll run into this in Factorio too. Take these 5 iron chests: FIG5: An Iron Chest requires 8 Iron Plates Making one chest takes only half a second. Hoping that chests will be needed in bulk, you could set up a dedicated production line for them. But materials in Factorio are finite, so you borrow from an existing production line. With so little iron plate supply going to the chest line, production stalls. Just like in real life, we’re borrowing time to work on the CMS project. Look at the calculation diagram below:

FIG6: Iron Plate output isn’t enough, time wasted

In Factorio, you’ll frequently see conveyor belts with gaps because of material shortages. It’s not uncommon for players to manually calculate a production line’s output. In the diagram above, I calculated that we’re short 15 iron plates per second. That means the chest production line won’t get the materials it needs. It’s faster to hand-craft chests than to wait for materials from this production line.

The lesson here: overengineering shows up when utilization is low. Building automation for something that doesn’t add value or isn’t better than the existing system. It creates unnecessary cost.

Underengineering

The opposite of the previous case. Here, the software engineer becomes the bottleneck.

Imagine a similar request (landing pages), but marketing asks for help every single week. Utilization is guaranteed to be high. As a result, every week there’s landing page work. What started as an occasional request becomes a recurring task. Time for other project development shrinks. In this case, a CMS would actually be a huge help. Being slow to recognize this situation wastes the engineer’s time. Same thing in Factorio, for example with Utility science pack production: FIG7: A component you could craft by hand The diagram above shows the recipe for a science component. In Factorio, science components are the currency for researching technology. Players can craft them by hand without an assembler. In one minute, a player can produce 0.62 of this component. The problem is, the game needs you to produce hundreds of these 😂. You could make them manually, but it would take dozens of real-world hours.

Compare that with this optimized production line using speed modules. Now we can produce 19.2 components per minute. Over ten times faster than hand-crafting. FIG8: The same component, built with automation From this, we learn the importance of digging deeper into stakeholder needs. Making the effort to understand the domain of the work helps us create better estimates and solution designs.

Do it Right, then Do it Fast

Related to scaling up, in Factorio it’s important to design efficient production lines. A messy, cramped layout takes up a lot of space. Space that could be used for another production line. So it’s important to get the design right before expanding further.

Same thing when adding servers. As much as possible, the servers you provision should be built from a clean operating system without extra software. Besides saving storage, it also saves bandwidth when containers pull images you frequently use.

From the illustration below, with limited space we managed to fit 14 assemblers, increasing output to 268.8 per minute. FIG9: A scalable production line

The Importance of Monitoring and Observability

Monitoring in Factorio is critical. A moment of inattention and you’ll run into problems like this: FIG10: Low on power, happens all the time In Factorio, you can see the energy output alongside demand. If demand exceeds supply, some areas will show red indicators like above. But if your energy supply depends on solar panels, power can go completely dark once the battery reserves are drained: FIG11: “Blackout” In cloud hosting, monitoring usually comes built-in. CPU, memory, and I/O metrics are standard. It’s also common knowledge that these metrics alone aren’t enough to explain why a website suddenly goes down. Additional metrics like error monitoring with Sentry or custom dashboards with Grafana make a big difference.

In Factorio, you can add extra instrumentation to improve observability. In this case, we can monitor what’s on the conveyor belt using a Display Panel: FIG12: Monitoring the uranium count on the conveyor belt You can set up logic to display messages based on certain conditions. For example, showing “Low uranium” when the content on the belt drops below 4.

Software engineers often act like detectives. This investigative skill gets a lot of practice in Factorio. In this example, the cause of the uranium shortage turned out to be a train jam 😄. After tracing the issue, there was a train blocking the route, causing the signal to show red “no-go.” I could explain the train system in a separate article, but to simplify, I just manually ran the train to free up the uranium route. Problem solved! FIG13: The uranium train is stuck because something is blocking the path. Root cause: the rail network can’t accommodate bidirectional traffic

Conclusion

Factorio is a game deeply connected to the software engineering profession. From the outside it looks like a typical resource management game, but inside it’s a repeating cycle of problem solving that gives players the freedom to be creative. There’s no single correct solution, everything can be measured, monitored, and automated. It’s an incredibly fun game if problem solving is something you enjoy.

I also created a YouTube series on how to play Factorio from scratch, perfect for beginners who want to get a productivity boost from the game. Enjoy!