Storage
The predominant storage solution for systems design is a database. These come in many forms, each one optimised for different things - certain guarantees about your data, speed, consistency etc.
- Databases, at the end of the day, are just servers
- This means that persistence is something that we have to think about
- If the power goes down and you’re executing transations to RAM - that data is lost forever
- However, writing to disk for guaranteed persistence is extremely slow (see Comparisions)
- Writing to SSD is quicker, but much more expensive and may not be ideal for situations where lots of writes occur
Remember that there are distributed databases - how are these managed? How is data sharded?
SQL vs NoSQL
- SQL databases are relational, NoSQL databases are non-relational.
- SQL databases use structured query language and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data.
- SQL databases are vertically scalable, while NoSQL databases are horizontally scalable.
- SQL databases are table-based, while NoSQL databases are document, key-value, graph, or wide-column stores.
- SQL databases are better for multi-row transactions, while NoSQL is better for unstructured data like documents or JSON.