# A Brief Introduction to Container Logistics


Container logistics is an interesting but complicated topic, with a lot of implicit knowledge kept by industry insiders. In this post, I'll give a brief overview, based on my experiences having worked in the industry for three different shipping companies (all located in Chile) over a period of five years. Hopefully, this will allow people to get more accurate models of the heavy port congestion in Long Beach that has been theorized about extensively [here on LW](https://www.lesswrong.com/posts/RgJicDmXHDxcJ9Fsw/an-unexpected-victory-container-stacking-at-the-port-of-long). I can't comment on circumstances specific to that port or the US more generally; but there's a set of underlying intuitions that should give people a solid, universal foundation to think about the issue. Based on those intuitions, I think people are way too optimistic about simple and easy solutions that claim to make major progress on the problem overnight.

# Lifecycle of a Container Shipment

I'll start with the basics. Let's say you want to send some cargo from port A to B. Thanks to the invention of standardized shipping containers, this is a relatively easy process, vastly easier than 100 years ago. All the equipment used along the trip (ships, cranes, truck trailers, etc) are specialized for the task of moving containers. This reduces costs dramatically, and makes your cargo arrive faster and safer.

The main trunk lines of international transport are between Asia and the US west coast, and between Asia and Europe (through the Suez canal). There's a significant amount of traffic across the Atlantic too. All of this is done with massive container ships carrying 8'000 or more TEUs (twenty-foot equivalent units. 20' container = 1 TEU, 40' container = 2 TEUs). Then there are many, many feeder services with much smaller vessels, going along the coasts of every continent, delivering cargo to/from smaller ports. I was in charge of container logistics for one such feeder line along the South American West Coast, visiting Colombia, Ecuador, Peru and Chile.

From a user perspective the process of shipping from A to B looks like this: you make a booking with a shipping company. This booking allows you to pick up a standardized container at a depot, which is usually near A, but might be hundreds of kilometers inland as well. You fill the container with your goods, and apply a tamper proof seal. You then arrange to get that container to port A, which will give you a bill of lading (a physical or virtual document similar to a cheque for the goods). The container is then loaded onto a ship, and sometime later that ship arrives at port B, where it can be claimed by someone who holds the bill of lading. The container may or may not be on its original ship: it may have been a straight shot, or it may have been transferred at multiple ports between A and B, e.g., from a small feeder route to a larger trunk route.

After the recipient unloads the container at port B, it returns it to a depot. This depot is either directly owned by the shipping line, or it may be a separate company that offers their services to multiple shipping lines. A depot will typically contain thousands of containers. Here, containers are inspected, and minor damages like tears, dents and oil spills can be cleaned up between uses. Shipping lines will typically insist on a return to a depot even if the recipient immediately wants to ship something back out, for liability reasons.

These depots are concentrated near the port of course, but there are also many depots far away from any port, near important cities and industrial centers. In that sense, a port can have a very large area of influence, and the container fleet that a shipping company keeps will also be spread over this entire area.

# Issues of Trust and Cooperation

The whole shipping process involves dozens of actors, from the exporter, through a long chain of companies who handle the container (incurring costs on behalf of the shipment), all the way to the importer. This creates a trust problem: who is responsible for the problems that arise when one part of this chain goes wrong? Some of these companies are hired by the shipping company, others by the exporter or importer, or even by a logistics company acting as a middle man. This is usually solved by some kind of chain of custody, where any problem with the container must be immediately noted and complained about by the relevant party.

I mention this issue because it's important to understand that a major problem like port congestion can't be approached in the same way as something like optimizing the layout of a chemical plant. There is no unified, global objective. All these different actors are trying to make money and shield themselves from having to pay for any extra costs. While there are usually detailed contracts regulating many corner cases, in practice the cooperation between these entities is often done informally, based on long-term relationships between organizations and even between individual people at those organizations.

For example, the exporter usually hires the trucker, and the shipping company hires the port, but then the trucker interacts with the port directly, even though these parties don't have any formal contract. Despite this, they will often know each other and solve smaller problems on the fly without involving their respective clients. Sometimes they’ll bill each other directly for any extra costs, but it’s often hard to translate small favors to precise monetary amounts, so this often ends up being based on reputation and reciprocity.

It’s also important to note that everything related to ship operations (such as the stowage plan I’ll introduce below) must be approved by the ship's captain, who is a naval officer and thus has professional ethical duties similar to a doctor or engineer. The captain is responsible for anything that goes wrong on the ship, they have absolute authority and could in theory refuse to sail for any reason. I mention this to emphasize again that many of the things done in this industry are about properly managing risk and responsibility, and that some optimizations that seem obvious can have hidden legal ramifications.

# Port Operations and Container Stacking

Now we get to the part everyone's interested in. What does the flow of containers in and out of a port look like, and how is the space in the port managed?

The most important fact here is that ships are very expensive. A large container ship costs around 100'000 USD for each day of idle time. That’s roughly how much it would cost to lease a ship long-term on the open market, including fixed costs such as crew and ongoing operations, but excluding variable costs such as fuel or berthing fees at the port (i.e., renting one of the berths that allow for loading/unloading). Note that in practice, container ships are mostly owned by the respective shipping company, but the other two major types of ships, bulk carriers and tankers, are frequently leased in this way. The leasing prices of ships also vary dramatically with economic cycles, it is rather a boom/bust type business. The figure I quoted is not meant to be precise, but should be useful to pin down the order of magnitude.

From this we can derive an important guiding principle: minimizing the ship's turnaround time is the highest priority, and everything else must be organized around enabling this.
For each visit of a given ship in a port, a ship operator is responsible for organizing the ship's stay. This is someone who works for the shipping company at an office near the port, who is familiar with the port infrastructure and the typical needs of the ship at this and later ports.

The shipping company continuously takes new bookings for all of its ships. Most bookings are made between one month and one week in advance of the ship’s ETA (estimated time of arrival). At the end of that time window, the shipping company stops taking new bookings. At this point, a provisional stowage plan is drafted by the ship operator, specifying where each container will be stowed. This is a hard combinatorial problem, as there are many constraints:
- ensuring the balance and structural integrity of the ship
- ensuring that sensitive cargo is stowed in the correct place. Dangerous cargo must be stowed above deck, refrigerated containers (reefers) have their own section with power plugs, wine must be stowed far away from heat sources (engine room), etc.
- ensuring that the job of the operator at the next port isn't needlessly hard, i.e., not burying containers that will be unloaded soon.

All of this should be achieved while avoiding "wasted" container movements (any movement that isn't loading / unloading) as much as possible.

I don’t have any experience at ports that are part of major trunk routes, but I would expect these issues to be slightly easier to manage for ships that essentially go back and forth between two major destinations (e.g., Shanghai - Long Beach). However, a port such as Long Beach also serves as a transport hub, so only one part of the containers unloaded are actually delivered at this port, with another substantial portion transferred to other ships.

Most customers pick up their empty containers a few days to a week before ETA, although in some cases, customers request earlier pick up and then use the containers as ad-hoc storage of their goods for a few days/weeks at a minor container yard, a train terminal, etc.

Once the stowage plan is made, the port can start receiving containers from customers. The containers are not simply stored in one big pile, but they must be kept separated by type / destination / weight / etc to ensure the stowage plan can be implemented efficiently. It is basically a big and very expensive version of [Tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi). At this point, it starts getting problematic if a customer wants to make a change to their booking. Getting a container out from the middle of a stack will easily cause 50 container movements (billed at $20 each), and the port doesn't necessarily have enough idle time with their machinery to even do this. A compromise here would be to set this container aside when it naturally comes up in the loading sequence, which only costs one extra movement. This of course wastes time and makes operations harder.

The window for container arrivals closes around 48 hours before ETA, although sometimes the port will accept late arrivals for a fee. A certain percentage of containers always fails to show up, so a final round of adjustments has to be made to the stowage plan.

When the ship finally arrives, it will berth and immediately start unloading, and then loading. A typical stay of a ship is 1-2 days long. During this time, the cranes at the berth should be in continuous operation, not wasting a single second. Almost no amount of money will make the shipping company accept a change to a booking at this point.

After the ship leaves, we now have a second round of Towers of Hanoi at the port, this time with the inbound containers that were unloaded. These are stored at the port and handed out to importers as they send their trucks to pick them up.

# Logistical Slack

The important thing to notice in port operations is that the container stacks are relatively close to being "random access", like the memory in your computer. Containers arrive and depart in an unpredictable manner, so they must be put into some sort of order to enable an efficient port stay for the ship. There are many easy suggestions for how to improve port logistics, but they often assume that containers are more or less fungible. This is a bad assumption.

If I was the benevolent dictator of Long Beach, I could enforce more efficient operations in a variety of ways. For example, I could just call in trucks, put arbitrary containers on those trucks, and tell the driver to go wherever this container must go. But not all truckers are willing to travel to arbitrary locations. Not all containers can accept the same kind of truck (e.g. due to weight differences). There are typically trade-offs in terms of reliability vs cost for different truckers. Also, each individual shipment (of one or a few containers) must be cleared by customs separately before it can leave the port.

Similarly, I could stack the containers much more closely together, sacrificing the "random access" property in the process, to create extra space in the port that might increase average throughput. However, this would destroy any guarantee that a given container will ever get out of the port. Humanity as a whole might be better off, but the owner of that particular cargo will be severely affected. The stacks must also be kept separate for different shipping companies. We are not at the point where we can make shipping itself fungible (e.g., forcing one company to carry the empty containers of another back to Asia) because this would require solving complex issues around the sharing of costs and liabilities.

What these kinds of proposals have in common is that they trade off a resource which I'll call "logistical slack" against an immediate, temporary relief of the congestion the port is facing. Losing this logistical slack is similar to "technical debt", a term from software engineering that describes how a piece of software becomes harder to modify and maintain over time, because the people working on it are incentivized to solve their short-term problems in fast and hacky ways, and neglect to maintain a coherent architecture for the project. Technical debt is a bad place to be, and it tends to kill projects over time.

Giving up logistical slack is a terrible idea for very similar reasons. It would cause all operations to become more complex and expensive, like a debt that demands continuous interest payments. The momentary relief created would immediately be consumed, not necessarily in the most efficient way, but rather to appease those who complain the most forcefully. Furthermore, a port simply never has the downtime to do a "spring cleaning"-style reorganization. Thus, any problem created must be cleaned up incrementally over many, many cycles of normal operations. A decision that seems like a good idea now may leave a mess that lasts for years, with the true costs not becoming immediately apparent.

# An Aside on Minor Container Yards

I’ll now briefly focus on the container yards where the stacking limit of height 2 was famously removed in Long Beach. If I understand the situation correctly, these are minor yards mostly belonging to trucking companies, which are used as a base of operations for a fleet of trucks.

Such a yard will have some space that can serve as short-term storage for both full and empty containers. For example, a customer has a full warehouse, and wishes to send out a shipment before the shipping company opens its arrival window at the port. The trucking company can arrange for this using their own storage space. Another frequent situation is that there is a truck with an empty container that was just unloaded at some importer’s facility. This container would usually be directly returned to the shipping company. However, if the truck is urgently needed, the trucker can save time by simply dropping it at their own yard, going on to do higher priority work, and return this container a few days later when they have some downtime and their opportunity cost is lower.

I believe that the stacking limit of two for these depots didn’t arise by coincidence. It just happens to be that containers can be stacked up to two high with a standard forklift. This is exactly as sketchy as it sounds and has a tendency to damage the container and can even cause accidents. Any stacking more sophisticated than this requires specialized vehicles (reach loaders, top loaders, etc) that cannot easily travel and are thus dedicated to one site.

I don’t want to claim expertise that I don’t have, and I certainly don’t know the specific situation in Long Beach. But for whatever it’s worth, I believe quite strongly that no significant storage capacity was unlocked by Long Beach’s suspension of stacking height limits.


# Container Fleet Management


Container traffic is not balanced across both directions of each given trade route. Most noticeably, the flow of consumer goods from Asia to the US and Europe creates a huge imbalance, which the shipping companies correct for by making regular shipments of empty containers. Similarly, many locations have seasonal products requiring specialized containers. For example in Chile, there are yearly spikes in the demand for reefers, to export avocados and many other fruits and vegetables.

An important part of my job was to keep on top of these imbalances and plan for future demand, requesting empty shipments in and out of "my" ports, keeping the stock low, but not too low. Sometimes, reality did not match the sales projections, and then we ended up either with severe shortages or huge mountains of idle containers.

The former situation caused salespeople to be upset with me, and forced me to burn a lot of accumulated trust with my suppliers to make things happen on tighter timelines. Containers arriving on a given ship can in theory be turned around fast enough to be exported on the next ship just a week later, but this will require calls to importers pleading to return the containers fast, night shifts at the container depot for repairs, longer arrival windows at the port, etc. It can be done, but it's not a sustainable way to work. Any shipping company that tries to cut corners in this way will quickly find itself not receiving the favors (both small and large) that are needed to ensure smooth operations.

The latter situation (too much stock) caused the global offices to be upset with me, since containers are always in short supply somewhere in the world. There's nothing worse than asking for empty containers to be shipped to us, then sending them back empty four months later, with no paying shipment to cover the costs. In those cases we'd ask sales to call up their customers and offer below market rates to destinations X,Y,Z as a one-time deal, for big volumes only.

Shipping companies often rent large batches of containers on a long-term basis, with somewhat flexible conditions of pick up and return. This is a further tool used to balance the fleet. If bookings are lower than expected, the global office will simply return a few hundred containers in Asia to their owners instead of shipping them to us in Chile, while we use our excess stock to cover those future shipments. That's another source of non-fungibility, since different containers should preferentially be used on different routes, to ensure proximity to their eventual place of return. Again, there's no worse failure than having to ship an empty container halfway across the world with multiple transfers, only to return it to its owner.

I'll close this post with a funny anecdote. One of our depots once lost a container. Yes, they just *lost* an object measuring ~80 cubic meters. When it arrived, they entered it into their system, but the container was later not to be found in the stacks where it was supposed to be. They went and physically searched through the whole depot. There was a months long back and forth where we settled on them just having to buy the container from us, and doing whatever they wanted with it if it ever turned up. But then, just before finalizing this, I got a call from my contact at the depot. He was staring out his office window when he noticed that one of the containers that was visible in a stack just a few dozen meters away had a serial number that seemed strangely familiar... he looked up that number only to realize that it was in fact the long-lost container!