Designing Data-Intensive Applications - Chapter 1 Notes
Trade-Offs in Data Systems Architecture
Applications can be:
- data-intesive → challenge is managing data
- compute-intensive → challenge is parallelizing large computation
data-intensive → storing/processing large volumes of data, managing changes to data, ensuring consistency in case of failure and concurrency, and availability of service.
Difficulty arises in combining different tools to achieve a purpose i.e one tool cannot achieve something on its own.
Operational vs Analytical Systems
operational systems → backend services and data infrastructure where data is created.
analytical systems → a read-only copy of the data from operational systems, optimized for data processing needs.
transaction → refers to group of read and writes that form a logical unit.
Access pattern of operational systems → looks up small number of records by a key (point query), records are inserted, updated and deleted based on user’s input. Due to the access pattern’s interactive nature, it is called Online Transaction Processing (OLTP).
Access pattern of analytical systems → looks up large number of records and calculates aggregate statistics. This is called Online Analytical Processing (OLAP).
OLTP → Users are not allowed to construct custom queries. OLAP → Allows users to write arbitrary SQL.
Intermediate system → Product analytics tools like Clickhouse → Optimized for low-latency query responses which ingests data in real time.
Data warehousing
Data warehouse → Separate database from OLTP used by business analysts.
It solves the problem of:
- data silos
- schemas and layouts of OLTP systems not being well suited for analytics
- analytic queries are expensive and affects user experiences in OLTP database
- data compliance issue
Data warehouse → read-only copy of all the data from various OLTP systems in company.
Extract-Transform-Load (ETL) → Process of getting data into the data warehouse.
Hybrid Transactional/Analytical Processing (HTAP) → A single system which enables both OLTP and analytics. Under the hood, it would still have OLTP and Analytics system hidden behind a common interface.
Use-case for HTAP → Low latency read-writes and analytic queries to scan a large number of rows → Ex: fraud detection
Data lake → No constraint on file format, data model or schema. Hold copy of any data useful for analysis, obtained from operational systems via ETL.
Systems of Record and Derived Data
Systems of Record → Source of truth, holds canonical version of data. Each fact is represented exactly once (representation is normalized).
Derived data systems → process form of some data, can be re-created from source if lost. Examples: Cache, denormalized values, indexes, materialized views, transformed data representations and models (trained on dataset).
Cloud Versus Self-Hosting
Core-competency of provides competitive advantage to the organization must be developed in-house.
Non-core, routine or commonplace should be left to vendor.
Cloud native → Architecture designed to take advantage of cloud services.
They build upon lower level cloud-services to build higher-level services:
- Object Storage → Limited APIs than filesystem, but the file is distributed and stored. We don’t need to worry about running out of space on any machine/handling disk failure. Example: AWS S3, Azure Blob Storage, Cloudflare R2.
- Other services are in-turn built upon object storage. Example: Snowflake (cloud based analytical data warehouse) relies on S3 for data storage.
Separation of storage and compute
Compute instances like VMs treat the local disks attached an ephemeral cache, not like long-term storage, as these can become inaccessible if the instance fails/replaced by small/bigger one.
As an alternative to local disk, cloud services provide virtual disk storage which can be attached/detached on needs (Ex: AWS EBS, Azure managed disks). It is not a real disk, but an emulation of disk i.e a block device. Storage calls go through network, susceptible to network glitches.
Operations in the Cloud Era
DevOps/SRE Philosophy:
- Set up automation over manual one-off jobs
- Use ephemeral VMs/services rather than long-running servers
- Frequent application updates
- Learn from incidents
- Preserve knowledge
Distributes Vs Single-Node Systems
Points for using distributed systems:
- Inherent distribution
- Requests between cloud services
- Fault tolerance/high availability
- Scalability
- Latency
- Elasticity
- Specialized hardware
- Legal Compliance
Points against distributed systems:
- Reliance on network for everything → request, API calls, storage access
- Network call to third party is still slower, than function calling
- Operating on large volume of data, easier to bring computation to machine which already has data.
- Difficult troubleshooting
- Maintaining data consistency across services is difficult
Microservices and Serverless
Service-oriented architecture (SOA)/microservices → Each service has one well-defined purpose (Example: S3 is object storage), each service exposes an API which can be called by clients → Decomposes complex application into manageable services.
Advantages of microservices:
- Individual services can be updated independently
- Implementation details can change, but the API is constant
Disadvantages of microservices:
- Increased complexity
- Hard to test during development
- Maintenance of infrastructure for each service
Microservices are a technical solution to people problem: independent development of services without co-ordinating with each other → Small orgs should be avoiding this and implement the application in simplest way possible.
Serverless/Function as a Service (FaaS) → Cloud provider automatically allocates and frees hardware resources as needed, based on incoming request to the service.
Cloud Computing Vs Supercomputing
Alternate to cloud computing → High Performance Computing (HPC)/Supercomputing. ### Computation
Supercomputer: Intensive computation tasks like weather forecasting, climate modeling.
Cloud Computing: Less-intensive for online services, business data systems.
Fault Tolerance
Supercomputer: In case of node failure, system is stopped, fault is fixed and resumes from last checkpoint.
Cloud Computing: Cannot stop the cluster.
Communication
Supercomputer: Through shared memory and RDMA
Cloud Computing: Needs more security such as resource isolation, encryption and authentication.
Network Topology
Supercomputer: Multi-dimensional meshes and toruses yields better performance for HPC workloads.
Cloud Computing: Clos topoligies to provide high bisection bandwidth.
Data Systems, Law and Society
GDPR grants individuals right to have their data erased on request.
When we store data, we should also take into the account the risks of liability and reputational damage if the data leaks/compromised.
Service Organization Control (SOC) Type 2 standard, Payment Card Industry (PCI) standards.