By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Topic: Data Ingestion (Cloud Storage, BigQuery, Pub/Sub, Dataflow)
Data ingestion is the first step in any ML pipeline—getting raw data from sources (databases, APIs, IoT devices, logs) into a format and location where it can be cleaned, transformed, and used for training or inference. In GCP, this involves Cloud Storage (for batch files), BigQuery (for structured analytics), Pub/Sub (for real-time streaming), and Dataflow (for scalable ETL). Real-world scenario: A ride-sharing app ingests real-time GPS data (Pub/Sub) to predict surge pricing, while historical trip data (BigQuery) trains demand-forecasting models. Poor ingestion leads to slow pipelines, high costs, or stale features.
Use case: Historical data for training (e.g., 10 years of customer transactions).1. Upload data to GCS: - Use gsutil cp or Cloud Storage Transfer Service (for large datasets). - Store in Parquet/ORC (columnar = faster queries) or Avro (schema evolution).2. Load into BigQuery: - Use bq load CLI or the BigQuery UI. - Choose partitioning (e.g., by date) and clustering (e.g., by customer_id) to reduce query costs.3. Validate data: - Run SELECT COUNT(*), MIN(date), MAX(date) FROM dataset.table to check for gaps. - Use BigQuery ML to detect anomalies (e.g., CREATE MODEL ... OPTIONS(model_type='logistic_reg')).
gsutil cp
bq load
SELECT COUNT(*), MIN(date), MAX(date) FROM dataset.table
CREATE MODEL ... OPTIONS(model_type='logistic_reg')
Use case: Real-time fraud detection (e.g., credit card transactions).1. Set up Pub/Sub: - Create a topic (e.g., transactions) and a subscription (e.g., fraud-detection-sub). - Configure message retention (default: 7 days) and acknowledgement deadline (default: 10s).2. Deploy Dataflow pipeline: - Use a template (e.g., "Pub/Sub to BigQuery") or write a Beam pipeline (Python/Java). - Add windowing (e.g., 5-minute tumbling windows) and triggers (e.g., emit results every 30s).3. Write to BigQuery: - Use beam.io.WriteToBigQuery with a schema (define columns like transaction_id, amount, timestamp). - Enable streaming inserts (higher cost) or batch writes (lower cost, higher latency).4. Monitor and scale: - Check Dataflow job metrics (e.g., "Elements Added," "System Lag"). - Set autoscaling (default: 1–1,000 workers) or fixed workers (for predictable costs).
transactions
fraud-detection-sub
beam.io.WriteToBigQuery
transaction_id
amount
timestamp
Use case: Recommendation system with real-time and batch features.1. Batch features (GCS → BigQuery): - Load historical user-item interactions (e.g., clicks, purchases) into BigQuery. - Pre-compute features (e.g., avg_purchase_value) using SQL.2. Streaming features (Pub/Sub → Dataflow): - Ingest real-time events (e.g., user_clicked_item) via Pub/Sub. - Use Dataflow to compute rolling features (e.g., clicks_last_5_minutes).3. Write to Vertex AI Feature Store: - Create a feature group (e.g., user_features) with a schema (e.g., user_id, avg_purchase_value). - Use Dataflow to write batch features (from BigQuery) and streaming features (from Pub/Sub) to the feature store.4. Serve features: - Call the feature store from your Vertex AI endpoint for low-latency inference.
avg_purchase_value
user_clicked_item
clicks_last_5_minutes
user_features
user_id
"BigQuery vs. Cloud SQL for ML data?"
Key Constraints:
Pub/Sub message size limit: 10MB (compress large payloads or split into chunks).
"Which Service?" Scenarios:
Q: "A fraud detection model needs sub-second feature updates. Which ingestion pipeline?"
Cost Traps:
Why? BigQuery is optimized for petabyte-scale queries, and CSV files can be loaded directly with partitioning/clustering.
A gaming app streams player events (e.g., "level_completed") to a Pub/Sub topic. The ML team needs to compute rolling features (e.g., "games_played_last_hour") and store them for real-time inference. Which GCP services should they use?
Why? Pub/Sub for streaming, Dataflow for windowed aggregations, and Feature Store for low-latency serving.
A data engineer notices that their Dataflow job fails when new columns are added to the Pub/Sub messages. How can they make the pipeline resilient to schema changes?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.