পাঠ ২৩ · ২৯-এর মধ্যে · মডিউল ৪
Home / AI Courses / Data Engineering / BigQuery ও Redshift

BigQuery ও Redshift

BigQuery (serverless) vs Redshift (node-based)
৭ মিনিট পড়া মাঝারি · Intermediate GCP & AWS

এই পাঠে যা শিখবেন

  • BigQuery-এর slot model ও on-demand vs reservation pricing
  • Redshift cluster (RA3, DC2), distribution style, sort key
  • Partitioning + clustering — BigQuery-তে কীভাবে design
  • BD enterprise context — কোন platform কখন

১ · দুই ভিন্ন দর্শন

Snowflake পেলেন previous পাঠে — যা cloud-native, multi-cloud, storage-compute decoupled। BigQuery (Google, ২০১১) আরও radical — পুরোপুরি serverlessServerlessinfrastructure (server, cluster, scaling) সম্পূর্ণ provider-এ; user শুধু query চালান, billing usage অনুযায়ী। কোনো node provision বা সাইজ select-এর দরকার নেই।। Redshift (AWS, ২০১২) ঠিক উল্টো — traditional MPP architecture, node-based, manual tuning-প্রবণ।

দুই দর্শন এক বাক্যে

BigQuery: "আপনি SQL লিখুন, আমরা দেখব কীভাবে চালাবে।"
Redshift: "আপনি cluster ও table layout design করুন; আমরা MPP execute করব।"

২ · BigQuery — slot ও on-demand pricing

BigQuery-তে compute unit হলো slotBigQuery SlotBigQuery-এর virtual CPU equivalent — একটি unit of compute capacity। Query parallel slot-এ split হয়। Reservation-এ আপনি ১০০, ৫০০, ১০০০ slot pre-purchase করতে পারেন। — virtual CPU। দুটি pricing model।

  • On-demand: প্রতি TB bytes scanned-এ $৬.২৫ (২০২৫ approx)। কোনো setup নেই; প্রথম query থেকেই কাজ। স্বয়ংক্রিয়ভাবে ২০০০+ slot পর্যন্ত burst।
  • Editions (reservation): Standard/Enterprise/Plus tier-এ slot pre-purchase। দাম $০.০৪-$০.১০/slot-hour। Predictable workload-এ on-demand-এর চেয়ে সস্তা।

উদাহরণ — Robi-র marketing analytics: মাসে ৫০০ TB scanned। On-demand: $৩,১২৫। ১০০ Standard slot reservation ($০.০৪ × ৭৩০h × ১০০ = $২,৯২০) — বরং কম, plus predictable। কিন্তু slot underutilized থাকলে wastage।

৩ · BigQuery-তে partitioning ও clustering

Bytes scanned কম রাখা = bill কম। তাই partitioning ও clustering critical।

  • Partitioning: physically table-কে slice করে — সাধারণত date column-এ। WHERE _PARTITIONDATE partition skip করে। Cardinality cap: ৪০০০ partition।
  • Clustering: partition-এর ভিতরে rows physically sorted। Up to ৪টি column। Pruning পরিষ্কার, scan কমে।
SQL · BigQuery
-- Partitioned + clustered table
CREATE OR REPLACE TABLE robi_analytics.cdr_2025
PARTITION BY DATE(call_ts)
CLUSTER BY region, msisdn_prefix
OPTIONS (
  partition_expiration_days = 365,
  require_partition_filter  = TRUE  -- protection: WHERE date বাধ্যতামূলক
)
AS SELECT * FROM robi_raw.cdr_landing;

-- Query — শুধু last 7 days, Dhaka region
SELECT msisdn_prefix, COUNT(*) AS calls, SUM(duration_sec) AS total_dur
FROM robi_analytics.cdr_2025
WHERE DATE(call_ts) BETWEEN '2025-05-02' AND '2025-05-08'
  AND region = 'Dhaka'
GROUP BY 1
ORDER BY calls DESC
LIMIT 100;

    
require_partition_filter = TRUE — যদি কেউ WHERE date বাদ দিয়ে query চালায়, BigQuery error দেবে। ৫০ TB টেবিল-এ ভুলে full scan = $৩১৩ billing surprise। এই option BD finance team-এর "guard rail"।

৪ · Redshift — node-based cluster

Redshift-এ আপনি cluster provision করেন — node count + node type। দুটি প্রজন্ম:

  • RA3 (২০১৯+): Snowflake-এর মতো — managed storage (S3-based) ও compute আলাদা। ra3.xlplus, ra3.4xlarge, ra3.16xlarge।
  • DC2 (legacy): compute ও storage একসাথে নোডে। Small workload, predictable। পুরনো setup-এ এখনো আছে।
  • Redshift Serverless (২০২২+): RPU (Redshift Processing Unit)-এ pay। BigQuery-র দিকে কাছাকাছি।

Cluster sizing — উদাহরণ: ১০ TB warehouse + ২০ analyst → ৪× ra3.4xlarge (১২৮ vCPU, ৩৮৪ GB RAM, managed storage)। On-demand price ~$১৩.০৪/hour cluster = ~$৯,৪০০/মাস (~১০ লাখ BDT)।

৫ · Distribution Key ও Sort Key — Redshift-এর হৃদয়

Redshift-এ প্রতিটি table-এ ডিজাইনার-কে সিদ্ধান্ত নিতে হয় — rows কীভাবে nodes-এ distribute হবে, এবং disk-এ কীভাবে sort হবে। ভুল choice → query ১০-১০০x ধীর।

  • DISTSTYLE KEY: একটি column-এর hash দিয়ে rows distribute। Join-এ same key থাকলে — co-located, দ্রুত। Skew risk।
  • DISTSTYLE EVEN: round-robin। Balanced কিন্তু join-এ data shuffle।
  • DISTSTYLE ALL: পুরো table প্রতি node-এ replicate। Small dimension table (১ M rows-এর কম)।
  • DISTSTYLE AUTO: Redshift নিজে বেছে নেয় (default ২০২০+)।

SORTKEY: rows physically sorted column-এ। Range filter দ্রুত হয় (zone map skip)।

SQL · Redshift
-- Fact table — co-located join with customers on customer_id
CREATE TABLE fact_orders (
  order_id     BIGINT,
  customer_id  BIGINT NOT NULL,
  order_ts     TIMESTAMP NOT NULL,
  amount_bdt   DECIMAL(12,2),
  district     VARCHAR(40)
)
DISTSTYLE KEY
DISTKEY (customer_id)
COMPOUND SORTKEY (order_ts, district);

-- Dimension — replicate to all nodes (small)
CREATE TABLE dim_customer (
  customer_id  BIGINT PRIMARY KEY,
  name         VARCHAR(120),
  segment      VARCHAR(20)
)
DISTSTYLE ALL;

-- Co-located join — কোনো network shuffle হয় না
SELECT c.segment, DATE_TRUNC('day', f.order_ts) AS day,
       SUM(f.amount_bdt) AS rev
FROM fact_orders f
JOIN dim_customer c USING (customer_id)
WHERE f.order_ts >= DATEADD(day, -7, CURRENT_DATE)
GROUP BY 1, 2
ORDER BY 2 DESC, 3 DESC;

    
DISTKEY(customer_id) + DISTSTYLE ALL dim table → join-এ shuffle ০। এই pattern Redshift-এ ১০x speedup-এর সাধারণ source। EXPLAIN-এ DS_DIST_NONE দেখলে confirm।
BigQuery বনাম Redshift — দুই দর্শন Serverless slots vs node-based MPP 🔍 BigQuery (GCP) SQL query → Dremel engine Auto-scale — ২০০০+ slots burst Colossus storage (Capacitor format) 💲 Pricing: $৬.২৫/TB scanned বা slot reservation cluster manage নেই Tuning: partition + cluster declarative · simpler 🟧 Redshift (AWS) SQL query → leader node Compute nodes (RA3) MPP-shuffle Managed storage (S3-backed) 💲 Pricing: hourly cluster ra3.4xlarge ~$৩.২৬/h cluster always running Tuning: DISTKEY + SORTKEY physical · explicit
দুই platform — দুই philosophy। BigQuery declarative, Redshift physical। দু'টিই production-ready, কিন্তু operational model আলাদা।

৬ · কখন কোনটি — decision framework

একক "best" নেই। নিচের প্রশ্নগুলো করুন।

  • Workload predictable? Yes → Redshift reserved instance বা BigQuery reservation। No → BigQuery on-demand বা Redshift Serverless।
  • Cloud বেছে রেখেছেন? GCP-heavy → BigQuery। AWS-heavy → Redshift (egress cost)।
  • DE team size? ছোট (১-৩) → BigQuery (less ops)। বড় (১০+) → Redshift (control)।
  • Real-time ingestion? BigQuery streaming insert বা Redshift streaming ingestion (Kinesis থেকে)।
  • ML workflow? BigQuery ML in-database, Vertex AI integration। Redshift ML (SageMaker)।

৭ · Bangladesh enterprise context

BD-তে যে platform বেশি দেখা যায়:

  • Robi Axiata, Grameenphone analytics layer: BigQuery — GCP partnership, marketing science টিম-এ standard।
  • Aamra Networks, Brain Station 23 customer: Redshift — অনেক client AWS-heavy।
  • Daraz Group: hybrid — Alibaba's MaxCompute on Alicloud + BigQuery exports।
  • Pathao, Foodpanda Bangladesh: BigQuery — startup speed, low ops overhead।
  • BD bank analytics: অনেকটা legacy Teradata/Oracle; cloud migration ধীর।

Region ও latency:

  • BigQuery: asia-southeast1 (Singapore), asia-south1 (Mumbai)। Multi-region asia।
  • Redshift: ap-southeast-1 (Singapore), ap-south-1 (Mumbai)।
  • ঢাকা থেকে latency দু'টোতেই ~৪০-৭০ ms — analytical workload-এ acceptable।

৮ · BigQuery-তে in-database ML — একটি ছোট উদাহরণ

SQL · BigQuery ML
-- Customer churn prediction — সম্পূর্ণ SQL-এ
CREATE OR REPLACE MODEL `pathao_dwh.churn_model`
OPTIONS (
  model_type = 'logistic_reg',
  input_label_cols = ['churned'],
  data_split_method = 'AUTO_SPLIT'
) AS
SELECT
  rides_last_30d,
  avg_fare_bdt,
  days_since_last_ride,
  district,
  preferred_payment,
  IF(rides_last_7d = 0, 1, 0) AS churned
FROM `pathao_dwh.customer_features`
WHERE snapshot_date = '2025-04-30';

-- Predict new customers
SELECT
  customer_id,
  predicted_churned_probs[OFFSET(1)].prob AS churn_prob
FROM ML.PREDICT(
  MODEL `pathao_dwh.churn_model`,
  (SELECT * FROM `pathao_dwh.customer_features`
   WHERE snapshot_date = '2025-05-08')
)
WHERE predicted_churned_probs[OFFSET(1)].prob > 0.7
ORDER BY churn_prob DESC
LIMIT 1000;

    
BigQuery ML — model training ও prediction পুরোপুরি SQL-এ। Pathao-এর marketing team Python ছাড়াই churn prediction চালাতে পারে। Redshift ML একই করে SageMaker-এ delegate করে।
BigQuery on-demand-এ "select *" sneak attack — ৫০ TB টেবিলে full scan = $৩১৩। সবসময় column-list specify করুন; require_partition_filter set করুন; max_bytes_billed per-job limit করুন।

ভাবনার প্রশ্ন

প্রতিটি প্রশ্ন নিজে কিছুক্ষণ ভাবুন — তারপর "→ উত্তর" চাপুন।

প্র ০১ Pathao Bangladesh-এর CTO bare-metal data center থেকে cloud migration plan করছেন। মাসিক ~৩০০ TB scanned, ১০ DE, BI ৫০ user। BigQuery, Redshift, Snowflake — কোনটি বাছবেন? পাঁচটি আলাদা মাত্রায় তুলনা করুন।

কোনো absolute "best" নেই — workload + team + ecosystem-এর উপর নির্ভরশীল। Pathao-এর context-এ পাঁচটি মাত্রায় তুলনা।

(১) Pricing — মাসিক ৩০০ TB scanned:

  • BigQuery on-demand: $৬.২৫ × ৩০০ = $১,৮৭৫। Predictable cap-এর জন্য slot reservation ($২,৯২০ for ১০০ slots) — slightly higher কিন্তু budget-known।
  • Redshift: ৪× ra3.4xlarge ১/৩ utilization → ~$৩,৫০০ + storage। Higher fixed cost; underutilized off-hours।
  • Snowflake: warehouse-based, multiple WH design। Likely $২,৫০০-৩,৫০০।
  • Winner cost: BigQuery (Pathao-র workload bursty)।

(২) Operational overhead:

  • BigQuery — কোনো cluster, vacuum, sortkey nei। ১ DE ১০০% ops handle করতে পারে।
  • Redshift — VACUUM, ANALYZE, distkey rebalance, WLM tuning। ১-২ FTE।
  • Snowflake — middle ground; warehouse design লাগে কিন্তু low maintenance।
  • Winner ops: BigQuery।

(৩) Ecosystem fit:

  • Pathao Google Maps API, Firebase, GA4 ব্যবহার করে — সব GCP-এ। BigQuery native।
  • Redshift মানে S3, Lambda, Kinesis re-engineer।
  • Snowflake multi-cloud, কিন্তু integration efforts।
  • Winner ecosystem: BigQuery।

(৪) Real-time ingestion:

  • Pathao real-time dashboard (driver location, ride status) চায়।
  • BigQuery streaming insert ($০.০৫/GB) সহজ — Pub/Sub থেকে direct।
  • Redshift streaming ingestion (Kinesis Data Streams) — robust কিন্তু setup কঠিন।
  • Snowflake Snowpipe — micro-batch, latency ~১ মিনিট।
  • Winner streaming: BigQuery।

(৫) ML/AI integration:

  • BigQuery ML in-database; Vertex AI seamless।
  • Redshift ML → SageMaker call।
  • Snowflake Snowpark + Cortex (নতুন)।
  • Winner ML: BigQuery (BD context)।

(৬) Risks ও lock-in:

  • BigQuery — GCP lock-in। SQL standard ANSI, কিন্তু operational lock-in বেশি।
  • Snowflake — multi-cloud freedom, vendor lock-in কিন্তু portability ভাল।
  • Redshift — AWS lock-in।

সিদ্ধান্ত: Pathao-এর জন্য BigQuery। Bursty workload, ছোট DE team, GCP ecosystem, ML-heavy roadmap — সব dimension-এ winner। Risk hedge: dbt + Iceberg-export-এ portability রাখুন future migration-এর জন্য।

মূল উপলব্ধি: Cloud DW choice technical-only নয়। Team capacity, existing cloud, regulatory, vendor relationship — সব মিলে। BD startup-এ most common winner — BigQuery; legacy enterprise-এ Redshift; multi-cloud strategic — Snowflake।

প্র ০২ আপনি Brain Station 23-এ কাজ করেন; একটি UK fintech client AWS Redshift-এ migrate করেছে। তাদের fact_transactions (২ TB) ও dim_customer (৫ M rows) join খুব ধীর। কী diagnose ও fix করবেন?

Redshift slow join — বেশিরভাগ ক্ষেত্রে distribution + sort key মিস। Step-by-step diagnostic।

(১) Diagnose — STEP 1: EXPLAIN দেখা:

EXPLAIN
SELECT c.segment, SUM(t.amount)
FROM fact_transactions t
JOIN dim_customer c ON t.customer_id = c.customer_id
WHERE t.tx_date >= DATEADD(day, -30, CURRENT_DATE)
GROUP BY 1;

খারাপ pattern: DS_DIST_BOTH বা DS_BCAST_INNER — দু'টোই full network shuffle। ভালো: DS_DIST_NONE বা DS_DIST_ALL_NONE।

(২) Diagnose — STEP 2: STL_DIST দেখা:

SELECT slice, num_values, ratio
FROM stl_dist
WHERE query = pg_last_query_id();

একটি slice-এ disproportionately বেশি rows = data skew।

(৩) সম্ভাব্য কারণ:

  • fact_transactions DISTSTYLE EVEN — তাই join-এ shuffle।
  • dim_customer DISTSTYLE EVEN — ছোট হলেও replicate-এ benefit।
  • Sort key অনুপস্থিত — date filter zone map use করছে না।
  • VACUUM/ANALYZE পুরনো — statistics stale, planner ভুল choice।

(৪) Fix:

-- fact: customer_id-এ co-locate, date-এ sort
CREATE TABLE fact_transactions_v2 (LIKE fact_transactions)
DISTSTYLE KEY DISTKEY (customer_id)
COMPOUND SORTKEY (tx_date);

INSERT INTO fact_transactions_v2 SELECT * FROM fact_transactions;

-- dim: ৫ M rows × ~১০০ B = ৫০০ MB → ALL distribute সম্ভব
CREATE TABLE dim_customer_v2 (LIKE dim_customer)
DISTSTYLE ALL;

INSERT INTO dim_customer_v2 SELECT * FROM dim_customer;

-- Statistics ও cleanup
ANALYZE fact_transactions_v2;
ANALYZE dim_customer_v2;
VACUUM REINDEX fact_transactions_v2;

(৫) যাচাই:

  • EXPLAIN-এ DS_DIST_NONE দেখা চাই।
  • SVL_QUERY_REPORT-এ "rows" per step উল্লেখযোগ্যভাবে কম।
  • Query time ১০-১০০x কমার expectation।

(৬) Long-term hygiene:

  • Weekly VACUUM (auto-vacuum-এ rely না করা)।
  • Daily ANALYZE।
  • WLM queue separation — short query, long ETL আলাদা।
  • Concurrency Scaling enable — burst-এ extra cluster auto।

মূল উপলব্ধি: Redshift performance debugging — distribution + sort + statistics। BigQuery/Snowflake-এ এই concern অনেক কম, কিন্তু Redshift control-এর বিনিময়ে responsibility। UK fintech client-এ সঠিক distkey চয়ন = ১০x speedup, খরচ same।

প্র ০৩ Grameenphone-এর CDR data দিনে ১৫ TB বাড়ে। BigQuery-তে partitioning + clustering design করুন যাতে (ক) প্রতিদিনের cost predictable, (খ) ৭ দিনের window query <১০ সেকেন্ডে, (গ) ৩ বছর retention।

Telco CDR — BigQuery-এর সবচেয়ে high-stakes use case। ১৫ TB/day × ৩৬৫ × ৩ = ১৬ PB। ভুল design = টানা billing surprise।

(১) Schema design:

CREATE TABLE gp_dwh.cdr (
  call_ts          TIMESTAMP NOT NULL,
  caller_msisdn    INT64     NOT NULL,
  callee_msisdn    INT64,
  duration_sec     INT64,
  cell_id          STRING,
  region           STRING,
  call_type        STRING,
  payload          STRING    -- raw record
)
PARTITION BY DATE(call_ts)
CLUSTER BY region, caller_msisdn
OPTIONS (
  partition_expiration_days = 1095,    -- ৩ বছর
  require_partition_filter  = TRUE,
  description = 'CDR raw — 15 TB/day'
);

(২) কেন এই design:

  • PARTITION BY DATE: ৩৬৫ × ৩ = ১০৯৫ partition; BigQuery limit ৪০০০ within।
  • CLUSTER BY region প্রথম: ৮ division — জনসংখ্যাগত query (Dhaka customers) সরাসরি।
  • caller_msisdn দ্বিতীয়: investigation query ("এই number-এর last 7 days history") দ্রুত।
  • require_partition_filter: Junior engineer "select * from cdr" → error, না bill suicide।
  • partition_expiration_days: auto-drop ৩ বছর পর — storage cost control।

(৩) Storage cost:

  • Active storage: $২০/TB/month × ১৫ TB × ৩০ = $৯,০০০ (last 30 days)।
  • Long-term storage (৯০ days+): $১০/TB/month — auto। ১৬ PB × $১০ = $১৬০,০০০/মাস।
  • BDT: ~১.৭৫ কোটি/মাস storage alone। GP-র scale অনুযায়ী acceptable।

(৪) Query cost — ৭ দিনের window:

  • ৭ × ১৫ TB = ১০৫ TB। Cluster pruning (Dhaka-এর filter) → ~১৩ TB scan।
  • On-demand: $৬.২৫ × ১৩ = $৮১/query। ১০০ analyst × ১০ query/day = ৮১ ক $৮১,০০০/day — অসঙ্গত।
  • সমাধান: flat-rate slot reservation। ২,০০০ slots × $৬০/month/slot = $১২০,০০০/month। Predictable।

(৫) Query performance — ১০s target:

-- ৭ দিন, Dhaka, top 100 callers
SELECT caller_msisdn, COUNT(*) AS calls, SUM(duration_sec) AS total
FROM gp_dwh.cdr
WHERE DATE(call_ts) BETWEEN '2025-05-02' AND '2025-05-08'
  AND region = 'Dhaka'
GROUP BY 1
ORDER BY calls DESC
LIMIT 100;
  • Partition pruning: ১০৯৫ → ৭।
  • Cluster pruning: region='Dhaka' → ~১২.৫% rows।
  • Effective scan: ~১.৩ TB। ২০০০ slots-এ ~৬-৮s।

(৬) Aggregation table — daily roll-up:

-- Daily agg view দিয়ে ৯০% query আরো দ্রুত
CREATE MATERIALIZED VIEW gp_dwh.cdr_daily_region AS
SELECT DATE(call_ts) AS day, region, call_type,
       COUNT(*) AS calls, SUM(duration_sec) AS dur
FROM gp_dwh.cdr
GROUP BY 1, 2, 3;

(৭) Monitoring ও cost guard:

  • Project-level maximum_bytes_billed = ১০ TB per query।
  • BigQuery Reservation Insights — slot utilization weekly।
  • Audit log: যে query ১০০+ TB scan করে — alert + review।

মূল উপলব্ধি: Telco-scale BigQuery-এ partition + cluster + reservation + materialized view — চারটি একসাথে দরকার। শুধু একটি বাদ গেলে cost বা performance ভাঙে। GP-র মতো operator-এ DE team-এর primary KPI = "predictable cost + sub-10s queries"।

প্র ০৪ Daraz Bangladesh BigQuery-তে marketing analytics চালায়। গত মাসে bill হঠাৎ $২,০০০ থেকে $২৫,০০০-এ গেল। DE team কী কী cause investigate করবে এবং কী কী guardrails বসাবে?

BigQuery cost surprise — যেকোনো cloud DW-এর সবচেয়ে common incident। Investigation এবং remediation step-by-step।

(১) Investigation — INFORMATION_SCHEMA জিজ্ঞেস:

SELECT
  user_email, job_id, query,
  total_bytes_billed/POW(1024,4) AS tb_billed,
  total_slot_ms/3600000 AS slot_hours,
  creation_time
FROM `region-asia-southeast1`.INFORMATION_SCHEMA.JOBS
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
ORDER BY total_bytes_billed DESC
LIMIT 50;

(২) সাধারণ root cause:

  • Full-table scan: "SELECT * FROM huge_table" — partition filter মিস। দিনে ১০০ TB scan সহজ।
  • SELECT * একটি wide table: ৫০ column × ১ TB → ৫০ TB scan, যদিও ৩ column চাই।
  • Cartesian join: JOIN condition মিস → row explosion, intermediate scan বিশাল।
  • Repeated subquery: CTE materialize হয় না; পাঁচবার একই subquery = পাঁচগুণ scan।
  • Tableau "auto-refresh" dashboard: প্রতি ১৫ মিনিট একই query rerun, cache miss।
  • External query bug: dbt model-এ partition filter বাদ গেছে।

(৩) Daraz-specific likely cause:

  • Marketing analyst নতুন campaign launch report-এ "WHERE date" বাদ দিয়ে ১২ TB events table full scan, ৫০x/day।
  • বা — dbt run accidentally হয়ে গেল table re-materialize, ৪ TB rebuild × ১০ models।
  • বা — Looker dashboard auto-refresh ৫ মিনিটে — ৫০০ user × ৩০ days।

(৪) Immediate guardrails — ০-২৪ ঘণ্টা:

  • Project-level maximum_bytes_billed = 1 TB per query।
  • সব production tables-এ require_partition_filter = TRUE alter।
  • User-level custom quota — daily TB cap।
  • Looker auto-refresh disable; user-triggered শুধু।

(৫) Medium-term — ১-৭ দিন:

  • Slot reservation switch — predictable cost (যেমন ৫০০ slots/$১৪,৬০০/mo flat)।
  • Materialized view-এ frequent dashboard query precompute।
  • BI Engine reservation — small datasets in-memory।
  • dbt: --profile prod-cap with bytes_billed limit।
  • Cost alert — Cloud Billing budget at 50%, 80%, 100%।

(৬) Long-term — culture:

  • Onboarding training: SELECT * নিষিদ্ধ; partition filter mandatory।
  • Code review: dbt PR-এ --dry-run bytes_billed check।
  • Cost dashboard — daily, by user, by query family।
  • Quarterly cost review — DE lead + finance।

(৭) BD-specific consideration:

  • BDT exchange rate volatility — USD bill ১২x = BDT bill ১৫x (rate পরিবর্তনে আরও খারাপ)।
  • CFO অনুমোদন cycle ২-৪ সপ্তাহ — runaway cost মাসের শেষে catastrophe।
  • Bangladesh Bank-এর foreign exchange rules — USD payment delay possible।

মূল উপলব্ধি: Cloud DW cost engineering technical না — culture। Guardrails আগে বসান, surprise-এর পর নয়। Daraz-এর ক্ষেত্রে immediate fix + slot reservation + culture shift = ১২x bill ৩x-এ নামানো realistic।

অনুশীলন

  1. Cost calculate: BigQuery-তে ৫ TB scanned query — on-demand-এ কত খরচ? যদি ১০০ slot reservation থাকে এবং query ১২ মিনিট চলে — slot cost কত?
    • On-demand: ৫ TB × $৬.২৫ = $৩১.২৫।
    • Slot: ১২ min = ০.২ hour। ১০০ slot × ০.২h × $০.০৪ = $০.৮০।
    • উপলব্ধি: heavy query-এ slot dramatically cheaper, কিন্তু idle slot-এ ভাড়া দিতে হয়। Predictable workload-এ reservation, bursty-তে on-demand।
  2. Redshift schema design: Pathao trips table (১০০ M rows) + drivers (১০ K) + cities (৬৪)। Frequent: trip-driver-city join, last 30 days। DISTSTYLE/DISTKEY/SORTKEY কী?
    CREATE TABLE trips (...)
      DISTSTYLE KEY DISTKEY (driver_id)
      COMPOUND SORTKEY (trip_ts);
    
    CREATE TABLE drivers (...)
      DISTSTYLE KEY DISTKEY (driver_id)
      SORTKEY (city_id);
    
    CREATE TABLE cities (...)
      DISTSTYLE ALL;  -- ৬৪ rows tiny

    trips ↔ drivers co-located (same DISTKEY); cities ALL → no shuffle। SORTKEY trip_ts → date filter zone map skip।

  3. BigQuery partition design: bKash transactions ~৫ TB/day, ৭ বছর retention regulatory। Partition + cluster + expiration কী দেবেন?
    CREATE TABLE bkash_dwh.tx (
      tx_ts        TIMESTAMP,
      msisdn       INT64,
      amount_bdt   NUMERIC(12,2),
      tx_type      STRING,
      ...
    )
    PARTITION BY DATE(tx_ts)
    CLUSTER BY tx_type, msisdn
    OPTIONS (
      partition_expiration_days = 2557,   -- 7 years
      require_partition_filter  = TRUE
    );
    • ৭ × ৩৬৫ = ২,৫৫৫ partition (limit ৪০০০ — safe)।
    • tx_type cluster — fraud query type filter দ্রুত।
    • msisdn — investigation per-customer history।
    • Long-term storage auto-discount ৯০ দিন পর।

আরও পড়ুন · ABCL TECH-এ আপনার পরবর্তী পদক্ষেপ

BigQuery free tier: মাসে ১ TB query + ১০ GB storage বিনামূল্যে। BigQuery sandbox Gmail-এ লগইন করেই শুরু করুন। Redshift practice Google Colab-এ psycopg2 দিয়ে।
পূর্ববর্তী পাঠ
পাঠ ২২ · Snowflake পরিচিতি