Grokking the Solutions Architect Interview
Vote

0% completed

​

Choosing Storage and Databases

Block, File, and Object Storage

Database Types

Managed Databases

Read Replicas and Standby Replicas

Durability and Availability

Choosing by Access Pattern

Using This in an Interview

Key Takeaways

Practice Questions

Title image: the retailer's five kinds of data, each as a small card with its size or rate.
Title image: the retailer's five kinds of data, each as a small card with its size or rate.

The retailer's online store depends on five kinds of data:

  • Orders: about 4,000 on a normal day, each with its lines, payment status, and delivery address.
  • The product catalog: about 40,000 products, with attributes that differ by product type.
  • Product images: about 8 for each product, so about 320,000 files.
  • Shopping sessions: each visitor's cart and login state, up to about 30,000 at once during the sale.
  • Sales reports: weekly sales by store and product over three years of history.

These kinds of data differ in size, in how often they change, and in how they are read. The sections below describe the storage and database types that a cloud offers, and they match each kind of data to the type that suits it.

Block, File, and Object Storage

Cloud storage comes in three types, and each one is reached in a different way.

Block storage is a virtual disk attached to one server. The server formats it and uses it like a local drive. It is fast, but in most setups only one server can use it at a time. On AWS, it is Amazon EBS.

File storage is a shared folder that many servers mount over the network at the same time. It suits applications that expect a normal file system, such as an old content tool. On AWS, it is Amazon EFS.

Object storage keeps whole files, called objects, that applications read and write over HTTP by name. It holds almost any amount of data and charges for what is stored. On AWS, it is Amazon S3.

The product images fit object storage. At about 500 KB each, 320,000 images take 320,000 times 0.5 MB, which is 160,000 MB or about 160 GB. Each image is written once and read many times, and browsers can fetch it by its address.

Database Types

Each database type is built for one way of reading data, so the access pattern decides the type.

  • A relational database stores data in tables with fixed columns and supports transactions, groups of changes that succeed or fail together. An order and the stock change it causes must be saved together, so orders belong here. AWS examples: Amazon RDS and Amazon Aurora.
  • A key-value database reads and writes one item by its key in a few milliseconds, at almost any request rate. Sessions are read by session ID on every page, so they fit. AWS example: Amazon DynamoDB.
  • A document database stores each record as a flexible document, so a sofa can have a fabric field and a lamp a wattage field. The catalog fits this shape. AWS example: Amazon DocumentDB.
  • A search engine finds records by words, with ranking and spelling tolerance, so "lether sofa" also finds "leather sofa". The store builds a search index from the catalog. AWS example: Amazon OpenSearch Service.
  • An analytics warehouse stores each column together, so a query that sums one column across millions of rows reads only that column. Sales reports belong here. AWS example: Amazon Redshift.

Reports show why the split matters. About 4,000 orders a day for three years is 4,000 times 1,095, about 4.4 million orders. A weekly report that scans all of them on the order database would slow checkout, so the orders are copied each night to the warehouse.

The retailer's five kinds of data mapped to their stores: orders to a relational database, the catalog to a document database with a search index, images to object storage, sessions to a key-value database, and reports to an analytics warehouse.
The retailer's five kinds of data mapped to their stores: orders to a relational database, the catalog to a document database with a search index, images to object storage, sessions to a key-value database, and reports to an analytics warehouse.

Managed Databases

A managed database is one where the provider installs, patches, backs up, and replaces failed hardware, while the customer chooses the size, the queries, and the schema (the design of the tables or documents). All the AWS examples above are managed services.

The retailer's 12 engineers had run their own database servers in the data center. A managed service removes that work, but it also removes some control. The engineers cannot log in to the server, and they can use only the versions and extensions (add-on modules for the database) that the provider supports. The SA checked the order database's extensions before choosing the service.

Read Replicas and Standby Replicas

A read replica serves reads, while a standby replica waits to take over, and the two solve different problems.

A read replica is a copy that receives changes from the main database a short time after each write, usually under a second, and answers read queries. It reduces load on the main database. Because the copy can be slightly behind, a page that must show a just-placed order should read from the main database.

A standby replica is a copy kept ready to take over, updated with every write before the write is confirmed. If the main database fails, the service switches to the standby, usually within a minute or two. In the common Amazon RDS setup with one standby, the standby serves no reads at all. Aurora differs: its copies share one storage layer, so one Aurora replica can both serve reads and take over.

The retailer's order database has both. Its standby runs in a second availability zone, and one read replica serves the "my orders" history page. The confirmation page shown right after checkout reads from the main database.

The order database with a standby replica in a second availability zone that takes over on failure, and a read replica that serves the order history page.
The order database with a standby replica in a second availability zone that takes over on failure, and a read replica that serves the order history page.

Durability and Availability

Durability is the chance that stored data is not lost; availability is the chance that you can read it right now. A store can be highly durable and briefly unavailable.

S3 Standard is designed for 99.999999999 percent durability. AWS explains this figure with an example: if you store 10 million objects, you can expect to lose one object about once every 10,000 years. The same service is designed for 99.99 percent availability, a lower figure, because a brief failure to read loses nothing.

Replicas copy every change, including a mistaken delete. A replica therefore protects availability, but it does not replace a backup.

Choosing by Access Pattern

Access patternRetailer dataStore typeAWS example
Related changes that must succeed togetherOrdersRelationalAurora or RDS
One item by key, at a high rateSessionsKey-valueDynamoDB
Records with varying fieldsCatalogDocumentDocumentDB
Text queries with rankingProduct searchSearch engineOpenSearch Service
Scans and sums over millions of rowsSales reportsAnalytics warehouseRedshift
Large files written once, read oftenImagesObject storageS3

The SA rejected an in-memory cache for sessions. It reads faster, but a failed cache node without a replica would empty the carts of thousands of customers during the sale. DynamoDB keeps each item in three availability zones, with no nodes for the team to run.

Using This in an Interview

When an interviewer asks which database you would use, name the access pattern before the product.

"Orders need transactions, because an order and its stock change must be saved together, so I would use a managed relational database with a standby in a second zone. Sessions are read by key on every page, so a key-value store fits. Reports scan millions of rows, so I would copy orders nightly to a warehouse rather than run reports on the order database."

A mid-level answer picks a suitable database for each kind of data. A senior answer also names the rejected option, the replica choice, and what the team can operate.

Expect two follow-up questions:

  • "Why not put everything in one relational database?" It would work at first, but report scans and the session reads of 30,000 shoppers would compete with checkout during the sale.
  • "Is the standby a backup?" No. It copies every change, including a mistaken delete, so the retailer still needs backups.

Key Takeaways

  • Block storage serves one server, file storage serves many, and object storage serves applications over HTTP.
  • Choose the database by access pattern: transactions, key lookups, flexible records, text search, or large scans.
  • A read replica serves reads; a standby replica takes over on failure.
  • Durability and availability are different promises, and replicas are not backups.

The next lesson, Networking for Cloud Architects, shows how a store's checkout reaches the order database.

Practice Questions

1. Why do the retailer's sales reports run on a warehouse instead of the order database?

<details><summary>Show answer</summary>

Because scanning about 4.4 million orders would slow checkout. A warehouse stores columns together and is built for large scans. A nightly copy keeps report queries away from the database that takes orders.

</details>

2. A customer places an order and then opens the "my orders" page, but the order is missing. What is the likely cause?

<details><summary>Show answer</summary>

The page read from a read replica that had not yet received the change. A read replica receives each change a short time after the main database. Pages that must show a change at once should read from the main database.

</details>

3. The catalog grows to 100,000 products with 8 images each at 500 KB. How much image storage is needed?

<details><summary>Show answer</summary>

About 400 GB. 100,000 times 8 is 800,000 images, and 800,000 times 0.5 MB is 400,000 MB.

</details>

Reading Progress

0%


Vote for new content

On This Page

Block, File, and Object Storage

Database Types

Managed Databases

Read Replicas and Standby Replicas

Durability and Availability

Choosing by Access Pattern

Using This in an Interview

Key Takeaways

Practice Questions