Case studies

data

A production database in a container without a persistent volume

The production database ran in a container. A restart, a node drain or a new image left an empty data directory. The application came up. The data did not. In this case study we show why database state cannot live in the image writable layer, and how we arranged a volume, a copy and a restore exercise.

Illustration: a team at a monitor and a database in a container without an attached volume

PVC

Data outside the container layer

RPO

A copy and restore on the calendar

Drain

Restart and move without losing the dataset

From this case study you will learn

  • why a database in a container without a volume loses data on restart
  • how a stateless service differs from an engine with an InnoDB directory
  • how to describe a PersistentVolumeClaim, a drain and a second copy path
  • how to exercise restore on a copy of the environment, not on production

The client ran the production database the same way as the API and the worker: as a container. The manifest or compose looked consistent. Restart, rolling update and node drain were ordinary platform operations. After one of those moves the data directory returned to the image state. The application came up. The data did not.

What the client brought

The database engine was described correctly in the config file. What was missing was a place where that file and those data would outlive the container. There was no PersistentVolumeClaim. There was no separate volume on the host. The database sat next to stateless services, so it received the same life cycle.

What the copy looked like

A copy, if it existed at all, sat outside a rhythm. Nobody restored it on a copy of the environment. The team learned about the gap when the pod came back with a new identifier and the directory was empty. Sometimes a dump from a laptop helped. Sometimes it did not.

This was not an engine fault. InnoDB, WAL and the data directory did what they are designed to do. The problem was that state lived in the image writable layer, which disappears with the container.

Why it breaks on restart

A container has a shorter life cycle than a database. A new image, another node, evict, rolling update: each of these moves can wipe the writable layer. The database holds state. State has to sit on a volume with a storage class, an access policy and room to grow.

Platform work, loss of the dataset

An image upgrade, a pod move and a host restart look like ordinary cluster work. For the database they are loss of the dataset if the engine files do not sit outside the container. A restore without a prior test is then a guess, not a procedure.

In the manifest a stateless service and a database look similar: image, port, variables. The difference appears on restart. One comes up empty and that is correct. The other comes up empty and that is an incident.

How we arranged it

We split the data out of the container path. The database got a volume: a PersistentVolumeClaim, a storage class, size and growth written in the manifest. Deploy and restart do not touch the engine files. A node drain has an order: flush, detach, start on the new node with the same volume.

A second path, not only a PVC

A volume alone does not close the topic. We added a logical dump on the calendar and a volume snapshot. We run restore on a copy of the environment, not on production. RPO and RTO are written down. The upgrade runbook says in which order the pod goes down, how it waits for flush and how it comes back.

A PVC solves surviving a restart. A restore exercise answers whether the copy can be restored at all. Both are in scope, because the client arrived after data loss, not after a missing manifest field.

Result

The database survives a restart, a move to another node and an image swap. The data sits on the volume. The copy has an owner. Restore has a date on the calendar. The same layout is described in the data security service.

Summary

A database in a container is acceptable when state sits on a volume and the copy has an exercise. Treating the engine like a stateless worker ends with an empty directory at a moment that, from the platform’s point of view, looks like success.

Write to us
Other

Other case studies

A media CDN for Magento: private S3 and CloudFront without moving the shop

A Magento shop with several domains kept product images, manuals and editor files on the application disk. The disk grew to hundreds of gigabytes and blocked scaling. We moved pub/media to a private S3 bucket and served media through CloudFront. The shop itself stayed on its existing server.

An EKS cluster for tens of thousands of pods, upgraded without downtime

We built an Amazon EKS cluster where Karpenter matches EC2 nodes to the load and data lives on EFS and S3. We run tens of thousands of pods on hundreds of nodes there and upgrade the cluster regularly without interrupting the applications.

The S3 bill dropped from $20,000 to $1,500 a month

The client was overpaying for AWS: data in an expensive S3 class, oversized instances, an EKS cluster on paid Extended Support and data transfers for partners at its own cost. We went through the bill line by line, removed the causes and set up a daily cost view in Grafana.

A Magento shop lost its server together with its only backup

A large Magento shop served around one million customers. Backups ran every day, but they were written to the same server as the shop. When access to the server was lost, the shop and every backup became unavailable at the same time. We describe how we restored the shop and how backups now work in two independent places.

A 1 TB copy and a restore that took several days

The copy was 1 TB. After an outage the team restored the whole disk, while the service only needed a few files to run. Transfer, verification and bringing the machine up took several days. In this case study we describe how we split a start restore from the full image, so the service returns to traffic without waiting for the whole set.

AWS without a landing zone and without cost control

The AWS account grew without a landing zone, without a list of instance types and without a cost trail during the week. The bill arrived only with the invoice, at the end of the month. In this case study we describe how daily reports, threshold alerts and instance-type order went in, and what that did to the bill.