





Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!






Data engineering enables data-driven decision making by collecting, transforming, and visualizing data. A data engineer designs, builds, maintains, and troubleshoots data processing systems with a particular emphasis on the security, reliability, fault-tolerance, scalability, fidelity, and efficiency of such systems.
A data engineer also analyzes data to gain insight into business outcomes, builds statistical models to support decision-making, and creates machine learning models to automate and simplify key business processes.
Key Points
What is Data Engineering?
GCP is a collection of Google computing resources, which are offered via services. Data engineering services include Compute, Storage, Big Data, and Machine Learning.
The 4 ways to interact with GCP include the console, command-line-interface (CLI), API, and mobile app.
The GCP resource hierarchy is organized as follows. All resources (VMs, storage buckets, etc) are organized into projects. These projects may be organized into folders, which can contain other folders. All folders and projects can be brought together under an organization node. Project folders and organization nodes are where policies can be defined. Policies are inherited downstream and dictate who can access what resources. Every resource must belong to a project and every must have a billing account associated with it.
Advantages: Performance (fast solutions), Pricing (sub- hour billing, sustained use discounts, custom machine ty- pes), PaaS Solutions, Robust Infrastructure
Google Compute Platform (GCP)
Hadoop Data can no longer fit in memory on one machine (mo- nolithic), so a new way of computing was devised using many computers to process the data (distributed). Such a group is called a cluster, which makes up server farms. All of these servers have to be coordinated in the following ways: partition data, coordinate computing tasks, handle fault tolerance/recovery, and allocate capacity to process.
Hadoop is an open source distributed processing fra- mework that manages data processing and storage for big data applications running in clustered systems. It is com- prised of 3 main components:
HDFS Each disk on a different machine in a cluster is comprised of 1 master node; the rest are data nodes. The master node manages the overall file system by storing the directory structure and metadata of the files. The data nodes physically store the data. Large files are broken up/distributed across multiple machines, which are replicated across 3 machines to provide fault tolerance.
MapReduce Parallel programming paradigm which allows for proces- sing of huge amounts of data by running processes on mul- tiple machines. Defining a MapReduce job requires two stages: map and reduce.
YARN- Yet Another Resource Negotiator Coordinates tasks running on the cluster and assigns new nodes in case of failure. Comprised of 2 subcomponents: the resource manager and the node manager. The re- source manager runs on a single master node and sche- dules tasks across nodes. The node manager runs on all other nodes and manages tasks on the individual node.
Hadoop Overview An entire ecosystem of tools have emerged around Hadoop, which are based on interacting with HDFS.
Hive: data warehouse software built o top of Hadoop that facilitates reading, writing, and managing large datasets residing in distributed storage using SQL-like queries (Hi- veQL). Hive abstracts away underlying MapReduce jobs and returns HDFS in the form of tables (not HDFS). Pig: high level scripting language (Pig Latin) that enables writing complex data transformations. It pulls unstructu- red/incomplete data from sources, cleans it, and places it in a database/data warehouses. Pig performs ETL into data warehouse while Hive queries from data warehouse to perform analysis (GCP: DataFlow). Spark: framework for writing fast, distributed programs for data processing and analysis. Spark solves similar pro- blems as Hadoop MapReduce but with a fast in-memory approach. It is an unified engine that supports SQL que- ries, streaming data, machine learning and graph proces- sing. Can operate separately from Hadoop but integrates well with Hadoop. Data is processed using Resilient Dis- tributed Datasets (RDDs), which are immutable, lazily evaluated, and tracks lineage. Hbase: non-relational, NoSQL, column-oriented data- base management system that runs on top of HDFS. Well suited for sparse data sets (GCP: BigTable) Flink/Kafka: stream processing framework. Batch stre- aming is for bounded, finite datasets, with periodic up- dates, and delayed processing. Stream processing is for unbounded datasets, with continuous updates, and imme- diate processing. Stream data and stream processing must be decoupled via a message queue. Can group streaming data (windows) using tumbling (non-overlapping time), sliding (overlapping time), or session (session gap) win- dows. Beam: programming model to define and execute data processing pipelines, including ETL, batch and stream (continuous) processing. After building the pipeline, it is executed by one of Beam’s distributed processing back- ends (Apache Apex, Apache Flink, Apache Spark, and Google Cloud Dataflow). Modeled as a Directed Acyclic Graph (DAG). Oozie: workflow scheduler system to manage Hadoop jobs Sqoop: transferring framework to transfer large amounts of data into HDFS from relational databases (MySQL)
Hadoop Ecosystem
Identity Access Management (IAM) Access management service to manage different members of the platform- who has what access for which resource.
Each member has roles and permissions to allow them access to perform their duties on the platform. 3 member types: Google account (single person, gmail account), service account (non-person, application), and Google Group (multiple people). Roles are a set of specific permissions for members. Cannot assign permissions to user directly, must grant roles.
If you grant a member access on a higher hierarchy level, that member will have access to all levels below that hierarchy level as well. You cannot be restricted a lower level. The policy is a union of assigned and inherited policies.
Primitive Roles: Owner (full access to resources, manage roles), Editor (edit access to resources, change or add), Viewer (read access to resources) Predefined Roles: finer-grained access control than primitive roles, predefined by Google Cloud Custom Roles
Best Practice: use predefined roles when they exist (over primitive). Follow the principle of least privileged favors.
GCP’s monitoring, logging, and diagnostics solution. Pro- vides insights to health, performance, and availability of applications. Main Functions
Stackdriver
OLAP vs. OLTP Online Analytical Processing (OLAP): primary objective is data analysis. It is an online analysis and data retrieving process, characterized by a large volume of data and complex queries, uses data warehouses. Online Transaction Processing (OLTP): primary objective is data processing, manages database modifi- cation, characterized by large numbers of short online transactions, simple queries, and traditional DBMS.
Row vs. Columnar Database Row Format: stores data by row Column Format: stores data tables by column rather than by row, which is suitable for analytical query proces- sing and data warehouses
IaaS, Paas, SaaS IaaS: gives you the infrastructure pieces (VMs) but you have to maintain/join together the different infrastructure pieces for your application to work. Most flexible option. PaaS: gives you all the infrastructure pieces already joined so you just have to deploy source code on the platform for your application to work. PaaS solutions are managed services/no-ops (highly available/reliable) and serverless/autoscaling (elastic). Less flexible than IaaS
Fully Managed, Hotspotting
Key Concepts Google App Engine Flexible, serverless platform for building highly available applications. Ideal when you want to focus on writing and developing code and do not want to manage servers, clusters, or infrastructures. Use Cases: web sites, mobile app and gaming backends, RESTful APIs, IoT apps.
Google Kubernetes (Container) Engine Logical infrastructure powered by Kubernetes, an open- source container orchestration system. Ideal for managing containers in production, increase velocity and operatabi- lity, and don’t have OS dependencies. Use Cases: containerized workloads, cloud-native distributed systems, hybrid applications.
Google Compute Engine (IaaS) Virtual Machines (VMs) running in Google’s global data center. Ideal for when you need complete control over your infrastructure and direct access to high-performance hardward or need OS-level changes. Use Cases: any workload requiring a specific OS or OS configuration, currently deployed and on-premises software that you want to run in the cloud.
Summary: AppEngine is the PaaS option- serverless and ops free. ComputeEngine is the IaaS option- fully controllable down to OS level. Kubernetes Engine is in the middle- clusters of machines running Kuberenetes and hosting containers.
Additional Notes You can also mix and match multiple compute options. Preemptible Instances: instances that run at a much lower price but may be terminated at any time, self- terminate after 24 hours. ideal for interruptible workloads Snapshots: used for backups of disks Images: VM OS (Ubuntu, CentOS)
Compute Choices
Scalable, fully-managed Data Warehouse with extremely fast SQL queries. Allows querying for massive volumes of data at fast speeds. Good for OLAP workloads (petabyte-scale), Big Data exploration and processing, and reporting via Business Intelligence (BI) tools. Sup- ports SQL querying for non-relational data. Relatively cheap to store, but costly for querying/processing. Good for analyzing historical data.
Data Model Data tables are organized into units called datasets, which are sets of tables and views. A table must belong to da- taset and a datatset must belong to a porject. Tables contain records with rows and columns (fields). You can load data into BigQuery via two options: batch loading (free) and streaming (costly).
Security BigQuery uses IAM to manage access to resources. The three types of resources in BigQuery are organizations, projects, and datasets. Security can be applied at the project and dataset level, but not table or view level.
Views A view is a virtual table defined by a SQL query. When you create a view, you query it in the same way you query a table. Authorized views allow you to share query results with particular users/groups without giving them access to underlying data. When a user queries the view, the query results contain data only from the tables and fields specified in the query that defines the view.
Billing Billing is based on storage (amount of data stored), querying (amount of data/number of bytes processed by query), and streaming inserts. Storage options are ac- tive and long-term (modified or not past 90 days). Query options are on-demand and flat-rate. Query costs are based on how much data you read/process, so if you only read a section of a table (partition), your costs will be reduced. Any charges occurred are billed to the attached billing account. Expor- ting/importing/copying data is free.
BigQuery Partitioned tables Special tables that are divided into partitions based on a column or partition key. Data is stored on different directories and specific queries will only run on slices of data, which improves query performance and reduces costs. Note that the partitions will not be of the same size. BigQuery automatically does this. Each partitioned table can have up to 2,500 partitions (2500 days or a few years). The daily limit is 2, partition updates per table, per day. The rate limit: 50 partition updates every 10 seconds.
Two types of partitioned tables:
Windowing: window functions increase the efficiency and reduce the complexity of queries that analyze partitions (windows) of a dataset by providing complex operations without the need for many intermediate calculations. They reduce the need for intermediate tables to store temporary data
Bucketing Like partitioning, but each split/partition should be the same size and is based on the hash function of a column. Each bucket is a separate file, which makes for more efficient sampling and joining data.
Querying After loading data into BigQuery, you can query using Standard SQL (preferred) or Legacy SQL (old). Query jobs are actions executed asynchronously to load, export, query, or copy data. Results can be saved to permanent (store) or temporary (cache) tables. 2 types of queries:
Wildcard Tables Used if you want to union all similar tables with similar names. ’’ (e.g. project.dataset.Table)
BigQuery Part II Controlling Costs
Query Performance Generally, queries that do less work perform better.
Input Data/Data Sources
SQL Anti-Patterns
Managing Query Outputs
Optimizing Query Computation
Optimizing BigQuery
NoSQL document database that automatically handles sharding and replication (highly available, scalable and durable). Supports ACID transactions, SQL-like queries. Query execution depends on size of returned result, not size of dataset. Ideal for ”needle in a haystack”operation and applications that rely on highly available structured data at scale
Data Model Data objects in Datastore are known as entities. An entity has one or more named properties, each of which can have one or more values. Each entity in has a key that uniquely identifies it. You can fetch an individual entity using the entity’s key, or query one or more entities based on the entities’ keys or property values.
Ideal for highly structured data at scale: product catalogs, customer experience based on users past acti- vities/preferences, game states. Don’t use if you need extremely low latency or analytics (complex joins, etc).
DataStore
Fully-managed cloud service for running Spark and Hadoop clusters. Provides access to Hadoop cluster on GCP and Hadoop-ecosystem tools (Pig, Hive, and Spark). Can be used to implement ETL warehouse solution.
Preferred if migrating existing on-premise Hadoop or Spark infrastructure to GCP without redevelopment ef- fort. Dataflow is preferred for a new development.
DataProc
Managed service for developing and executing data processing patterns (ETL) (based on Apache Beam) for streaming and batch data. Preferred for new Hadoop or Spark infrastructure development. Usually site between front-end and back-end storage solutions.
Concepts Pipeline: encapsulates series of computations that accepts input data from external sources, transforms data to provide some useful intelligence, and produce output PCollections: abstraction that represents a potentially distributed, multi-element data set, that acts as the pipeline’s data. PCollection objects represent input, intermediate, and output data. The edges of the pipeline. Transforms: operations in pipeline. A transform takes a PCollection(s) as input, performs an operation that you specify on each element in that collection, and produces a new output PCollection. Uses the ”what/where/when/how”model. Nodes in the pipeline. Composite transforms are multiple transforms: combi- ning, mapping, shuffling, reducing, or statistical analysis. Pipeline I/O: the source/sink, where the data flows in and out. Supports read and write transforms for a number of common data storage types, as well as custom.
Windowing Windowing a PCollection divides the elements into win- dows based on the associated event time for each element. Especially useful for PCollections with unbounded size, since it allows operating on a sub-group (mini-batches).
Triggers Allows specifying a trigger to control when (in processing time) results for the given window can be produced. If unspecified, the default behavior is to trigger first when the watermark passes the end of the window, and then trigger again every time there is late arriving data.
DataFlow Asynchronous messaging service that decouples senders and receivers. Allows for secure and highly available com- munication between independently written applications. A publisher app creates and sends messages to a to- pic. Subscriber applications create a subscription to a topic to receive messages from it. Communication can be one-to-many (fan-out), many-to-one (fan-in), and many-to-many. Gaurantees at least once delivery before deletion from queue.
Scenarios
Benefits/Features Unified messaging, global presence, push- and pull-style subscriptions, replicated storage and guaranteed at-least- once message delivery, encryption of data at rest/transit, easy-to-use REST/JSON API
Data Model Topic, Subscription, Message (combination of data and attributes that a publisher sends to a topic and is eventually delivered to subscribers), Message Attribute (key-value pair that a publisher can define for a message)
Message Flow
Pub/Sub
Company Overview Flowlogistic is a top logistics and supply chain provider. They help businesses throughout the world manage their resources and transport them to their final destination. The company has grown rapidly, expanding their offerings to include rail, truck, aircraft, and oceanic shipping.
Company Background The company started as a regional trucking company, and then expanded into other logistics markets. Because they have not updated their infrastructure, managing and tracking orders and shipments has become a bottleneck. To improve operations, Flowlogistic developed proprie- tary technology for tracking shipments in real time at the parcel level. However, they are unable to deploy it because their technology stack, based on Apache Kafka, cannot support the processing volume. In addition, Flowlogistic wants to further analyze their orders and shipments to determine how best to deploy their resources.
Solution Concept Flowlogistic wants to implement two concepts in the cloud:
Business Requirements -Build a reliable and reproducible environment with scaled parity of production -Aggregate data in a centralized Data Lake for analysis -Perform predictive analytics on future shipments -Accurately track every shipment worldwide -Improve business agility and speed of innovation through rapid provisioning of new resources -Analyze/optimize architecture cloud performance -Migrate fully to the cloud if all other requirements met
Technical Requirements -Handle both streaming and batch data -Migrate existing Hadoop workloads -Ensure architecture is scalable and elastic to meet the changing demands of the company -Use managed services whenever possible -Encrypt data in flight and at rest -Connect a VPN between the production data center and cloud environment
Case Study: Flowlogistic I Existing Technical Environment Flowlogistic architecture resides in a single data center:
CEO Statement We have grown so quickly that our inability to up- grade our infrastructure is really hampering further growth/efficiency. We are efficient at moving shipments around the world, but we are inefficient at moving data around. We need to organize our information so we can more easily understand where our customers are and what they are shipping.
CTO Statement IT has never been a priority for us, so as our data has grown, we have not invested enough in our tech- nology. I have a good staff to manage IT, but they are so busy managing our infrastructure that I cannot get them to do the things that really matter, such as organizing our data, building the analytics, and figu- ring out how to implement the CFO’s tracking technology.
CFO Statement Part of our competitive advantage is that we penalize our- selves for late shipments/deliveries. Knowing where our shipments are at all times has a direct correlation to our bottom line and profitability. Additionally, I don’t want to commit capital to building out a server environment.
Case Study: Flowlogistic II
Note: All services are fully managed., easily scalable, and can handle streaming/batch data. All technical require- ments are met.
Flowlogistic Potential Solution
Company Overview MJTelco is a startup that plans to build networks in rapidly growing, underserved markets around the world. The company has patents for innovative optical communications hardware. Based on these patents, they can create many reliable, high-speed backbone links with inexpensive hardware.
Company Background Founded by experienced telecom executives, MJTelco uses technologies originally developed to overcome communica- tions challenges in space. Fundamental to their operation, they need to create a distributed data infrastructure that drives real-time analysis and incorporates machine lear- ning to continuously optimize their topologies. Because their hardware is inexpensive, they plan to overdeploy the network allowing them to account for the impact of dynamic regional politics on location availability and cost.
Their management and operations teams are situated all around the globe creating many-to-many relationship between data consumers and providers in their system. After careful consideration, they decided public cloud is the perfect environment to support their needs.
Solution Concept MJTelco is running a successful proof-of-concept (PoC) project in its labs. They have two primary needs:
Business Requirements -Scale up their production environment with minimal cost, instantiating resources when and where needed in an un- predictable, distributed telecom user community. -Ensure security of their proprietary data to protect their leading-edge machine learning and analysis. -Provide reliable and timely access to data for analysis from distributed research workers. -Maintain isolated environments that support rapid ite- ration of their machine-learning models without affecting their customers.
Case Study: MJTelco I Technical Requirements -Ensure secure and efficient transport and storage of telemetry data. -Rapidly scale instances to support between 10,000 and 100,000 data providers with multiple flows each. -Allow analysis and presentation against data tables tracking up to 2 years of data storing approximately 100m records/day. Support rapid iteration of monitoring infrastructure focused on awareness of data pipeline problems both in telemetry flows and in production learning cycles.
CEO Statement Our business model relies on our patents, analytics and dynamic machine learning. Our inexpensive hardware is organized to be highly reliable, which gives us cost advantages. We need to quickly stabilize our large distributed data pipelines to meet our reliability and capacity commitments.
CTO Statement Our public cloud services must operate as advertised. We need resources that scale and keep our data secure. We also need environments in which our data scientists can carefully study and quickly adapt our models. Because we rely on automation to process our data, we also need our development and test environments to work as we iterate.
CFO Statement This project is too large for us to maintain the hardware and software required for the data and analysis. Also, we cannot afford to staff an operations team to monitor so many data feeds, so we will rely on automation and infrastructure. Google Cloud’s machine learning will al- low our quantitative researchers to work on our high-value problems instead of problems with our data pipelines.
Case Study: MJTelco II Need Open Source GCP Solution Compute, Block Storage
Persistent Disks, SSD
Persistent Disks, SSD Media, Blob Storage
Filesystem, HDFS
Cloud Storage
SQL Interface on File Data
Hive BigQuery
Document DB, NoSQL
CouchDB, Mon- goDB
DataStore
Fast Scanning NoSQL
HBase, Cassan- dra
BigTable
OLTP RDBMS- MySQL
CloudSQL, Cloud Spanner OLAP Hive BigQuery Cloud Storage: unstructured data (blob) CloudSQL: OLTP, SQL, structured and relational data, no need for horizontal scaling Cloud Spanner: OLTP, SQL, structured and relational data, need for horizontal scaling, between RDBMS/big data Cloud Datastore: NoSQL, document data, key-value structured but non-relational data (XML, HTML, query depends on size of result (not dataset), fast to read/slow to write BigTable: NoSQL, key-value data, columnar, good for sparse data, sensitive to hot spotting, high throughput and scalability for non-structured key/value data, where each value is typically no larger than 10 MB
Choosing a Storage Option