Notes

Part 6 of 10

Cloud native architecture

Cloud changes more than the economics, where you subscribe to services instead of buying hardware and licenses. It also changes how data systems are built technically. A cloud native system is one designed to take advantage of cloud services.

Almost any software you can host yourself can also be sold as a managed cloud service. But systems built for the cloud from scratch have shown real gains: more speed from the same hardware, faster recovery from failures, quick scaling with load, and support for bigger datasets. This holds for both OLTP databases and analytics systems.

Layering of cloud services

  • Self-hosted software needs only generic resources: an OS, files on a filesystem, a TCP/IP network, CPU, and memory. A few systems need special hardware, like GPUs for machine learning or very fast network cards.
  • In IaaS, such software runs on VMs (instances) with a set amount of CPU, memory, disk, and bandwidth. VMs are quicker to get than physical machines and come in more sizes, but you still manage everything on them.
  • The key cloud native idea is to build higher-level services on top of lower-level cloud services, not just on what the OS provides.
  • Object storage (like Amazon S3 or Cloudflare R2) holds large files. Its API is simpler than a filesystem's, mostly just reading and writing whole files. In return it hides the physical machines, spreads data across them automatically, never runs out of space, and does not lose data when a machine or disk dies.
  • Services stack on each other: a cloud warehouse may store its data in object storage, and other services are then built on that warehouse.
  • Higher-level services are made for specific uses. If your needs match one, use it and save a lot of effort; if nothing fits, build your own from lower-level parts.

Separation of storage and compute

  • Traditionally a disk is treated as durable. To survive a disk failure, RAID keeps copies of the data across several disks in one machine, handled by hardware or the OS, unseen by apps.
  • Cloud native systems treat a VM's local disk as a temporary cache, not long-term storage. The disk is lost if the VM fails, or if it is swapped for a bigger or smaller one on other hardware.
  • Virtual block storage (like Amazon EBS) is a separate network service that pretends to be a disk, handing out small blocks, typically 4 KiB each. It can be moved from one VM to another.
  • Virtual disks let older disk-based software run in the cloud. But pretending to be a disk adds overhead that cloud-first designs avoid, and every disk read or write becomes a network call, so the app suffers whenever the network hiccups.
  • Cloud native systems instead build on storage services tuned for specific jobs. Object stores work best with fairly large files, from hundreds of kilobytes up to several gigabytes. Database rows are much smaller, so cloud databases keep small values in a separate service and group many values into big blocks for object storage (a later chapter explains how).
  • Traditionally one machine does both storage (disk) and compute (CPU and memory). Cloud native systems split these apart, sometimes called disaggregation. An object store only stores files, so the code that analyzes them runs on other machines, and data must travel over the network to reach it.
  • Multitenancy: many customers' data and work share the same hardware and service, instead of each customer getting its own machine. This uses hardware better and makes scaling and management easier for the provider. But it needs careful engineering so one customer cannot slow down another or see their data.