๐Ÿ“Š Data Engineering

Fivetran

Fivetran

An automated data integration platform. Connector-based ELT.

Detailed Explanation

Fivetran is an automated data integration platform, an ELT (Extract, Load, Transform) service that automatically extracts data from various data sources and loads it into a data warehouse/lake.

Key Features of Fivetran

  • Fully managed connectors: Provides more than 500 pre-built connectors
  • Automatic schema detection: Automatically detects and applies source schema changes
  • Incremental sync: Efficiently syncs only changed data
  • Data normalization: Automatic data normalization and preparation for analysis
  • High reliability: 99.9% SLA guaranteed

Major Supported Connectors

CategoriesConnectorFeatures
DatabasePostgreSQL, MySQL, MongoDBCDC-based real-time sync
SaaSSalesforce, HubSpot, StripeAPI-based automatic sync
Cloud storageS3, GCS, Azure BlobFile-based data collection
EventsKafka, Kinesis, WebhooksReal-time streaming ingestion

Code Example

Configuring connectors via the Fivetran API

# Fivetran API๋ฅผ ์‚ฌ์šฉํ•œ ์ปค๋„ฅํ„ฐ ์„ค์ • ๋ฐ ๊ด€๋ฆฌ
import requests
import json

class FivetranConnectorManager:
    """Fivetran ์ปค๋„ฅํ„ฐ ๊ด€๋ฆฌ ํด๋ž˜์Šค"""

    def __init__(self, api_key, api_secret):
        self.base_url = "https://api.fivetran.com/v1"
        self.auth = (api_key, api_secret)

    def create_connector(self, group_id, service, config):
        """์ƒˆ ์ปค๋„ฅํ„ฐ ์ƒ์„ฑ"""
        payload = {
            "service": service,
            "group_id": group_id,
            "config": config,
            "paused": False,
            "trust_certificates": True,
            "run_setup_tests": True
        }

        response = requests.post(
            f"{self.base_url}/connectors",
            auth=self.auth,
            json=payload
        )
        return response.json()

    def get_connector_status(self, connector_id):
        """์ปค๋„ฅํ„ฐ ์ƒํƒœ ์กฐํšŒ"""
        response = requests.get(
            f"{self.base_url}/connectors/{connector_id}",
            auth=self.auth
        )
        return response.json()

    def sync_connector(self, connector_id):
        """์ˆ˜๋™ ๋™๊ธฐํ™” ํŠธ๋ฆฌ๊ฑฐ"""
        response = requests.post(
            f"{self.base_url}/connectors/{connector_id}/sync",
            auth=self.auth
        )
        return response.json()

    def update_connector_config(self, connector_id, new_config):
        """์ปค๋„ฅํ„ฐ ์„ค์ • ์—…๋ฐ์ดํŠธ"""
        response = requests.patch(
            f"{self.base_url}/connectors/{connector_id}",
            auth=self.auth,
            json={"config": new_config}
        )
        return response.json()


# ์‚ฌ์šฉ ์˜ˆ์ œ
fivetran = FivetranConnectorManager(
    api_key="your_api_key",
    api_secret="your_api_secret"
)

# PostgreSQL ์ปค๋„ฅํ„ฐ ์„ค์ •
postgres_config = {
    "host": "db.example.com",
    "port": 5432,
    "user": "fivetran_user",
    "password": "secure_password",
    "database": "production",
    "update_method": "WAL",  # CDC ์‚ฌ์šฉ
    "replication_slot": "fivetran_slot",
    "publication_name": "fivetran_pub"
}

# ์ปค๋„ฅํ„ฐ ์ƒ์„ฑ
result = fivetran.create_connector(
    group_id="target_destination_123",
    service="postgres",
    config=postgres_config
)
print(f"Connector ID: {result['data']['id']}")

# Salesforce ์ปค๋„ฅํ„ฐ ์„ค์ •
salesforce_config = {
    "client_id": "your_salesforce_client_id",
    "client_secret": "your_salesforce_client_secret",
    "is_sandbox": False,
    "sync_mode": "History",
    "api_type": "REST"
}

# ๋™๊ธฐํ™” ์ƒํƒœ ํ™•์ธ
status = fivetran.get_connector_status("connector_123")
print(f"Status: {status['data']['status']['sync_state']}")

Configuring connectors as IaC using Terraform

# Terraform์œผ๋กœ Fivetran ์ปค๋„ฅํ„ฐ ๊ด€๋ฆฌ
terraform {
  required_providers {
    fivetran = {
      source  = "fivetran/fivetran"
      version = "~> 1.0"
    }
  }
}

provider "fivetran" {
  api_key    = var.fivetran_api_key
  api_secret = var.fivetran_api_secret
}

# ๋ชฉ์ ์ง€ ๊ทธ๋ฃน ์ƒ์„ฑ
resource "fivetran_group" "data_warehouse" {
  name = "production-snowflake"
}

# PostgreSQL ์ปค๋„ฅํ„ฐ ์„ค์ •
resource "fivetran_connector" "postgres_source" {
  group_id = fivetran_group.data_warehouse.id
  service  = "postgres"

  destination_schema {
    name   = "postgres_prod"
    prefix = "pg_"
  }

  config {
    host     = "db.example.com"
    port     = 5432
    user     = var.postgres_user
    password = var.postgres_password
    database = "production"

    update_method      = "WAL"
    replication_slot   = "fivetran_slot"
    publication_name   = "fivetran_pub"
  }

  run_setup_tests = true
  paused          = false
  sync_frequency  = 360  # 6์‹œ๊ฐ„๋งˆ๋‹ค
}

# Salesforce ์ปค๋„ฅํ„ฐ ์„ค์ •
resource "fivetran_connector" "salesforce_source" {
  group_id = fivetran_group.data_warehouse.id
  service  = "salesforce"

  destination_schema {
    name = "salesforce_prod"
  }

  config {
    is_sandbox = false
    api_type   = "REST"
  }

  sync_frequency = 60  # 1์‹œ๊ฐ„๋งˆ๋‹ค
}

# dbt ๋ณ€ํ™˜ ์—ฐ๋™ (๋ณ€ํ™˜ ๊ณ„์ธต)
resource "fivetran_dbt_transformation" "customer_360" {
  dbt_project_id = var.dbt_project_id
  run_tests      = true

  schedule {
    schedule_type = "INTEGRATED"
    connector_ids = [
      fivetran_connector.postgres_source.id,
      fivetran_connector.salesforce_source.id
    ]
  }
}

Practical Conversation Example

Data Engineer: "Right now we extract Salesforce data manually, and it takes 2 hours every day. What if we adopt Fivetran?"
Data Team Lead: "Good suggestion. Fivetran has a well-built Salesforce connector, so once you set it up, it syncs automatically. It also detects schema changes automatically."
Data Engineer: "Is real-time sync of PostgreSQL via CDC also possible?"
Data Team Lead: "It supports WAL-based CDC. If you set up Logical Replication, you can sync with a delay of under 5 minutes. However, the large initial snapshot may take a while."
Data Engineer: "How does the cost work? I heard it's based on MAR (Monthly Active Rows)..."
Data Team Lead: "Right, billing is based on MAR. So log-type data that changes frequently can get expensive. For that kind of data, Kafka or building it yourself might be better."

Cautions

Cost Management

  • Billing based on MAR (Monthly Active Rows) - costs can spike for frequently changing data
  • Large MAR consumption during the initial historical sync
  • Reduce costs by excluding unnecessary tables/columns from syncing

Schema Change Management

  • Automatic schema detection is not always perfect - periodic verification is needed
  • When a column is dropped, it is not automatically deleted at the destination (soft delete)
  • Changing a data type may cause compatibility issues

Performance Considerations

  • Initial sync of large tables can put load on the source DB
  • API-based connectors are affected by rate limits
  • If the sync interval is too short, cost and load increase

Related Terms

Learn More