๐Ÿ“Š Data Engineering

Tecton

An enterprise feature platform

Detailed Explanation

Tecton is an enterprise-grade Feature Platform for machine learning. It manages feature engineering, storage, and serving in an integrated way, accelerating the production deployment and operation of ML models. It was founded by the team that developed Uber's Michelangelo.

Key concepts

  • Feature Store: A repository for feature definitions, version control, and reusable features
  • Feature Pipeline: Batch, streaming, and real-time feature computation pipelines
  • Feature Serving: Supports online (real-time) and offline (batch) serving
  • Feature Monitoring: Monitoring of feature drift, quality, and freshness

Tecton Architecture

  • Declarative Config: Define features as code with the Python SDK (Feature-as-Code)
  • Offline Store: Historical features for training (S3, BigQuery, Snowflake)
  • Online Store: Low-latency features for real-time inference (DynamoDB, Redis)
  • Stream Processing: Integration with Spark Structured Streaming and Kafka
  • Point-in-Time Correctness: Prevents data leakage through accurate point-in-time feature retrieval

Key Benefits

Tecton prevents Training-Serving Skew and improves feature reusability, reducing model development time. It is used especially in domains where real-time ML is important, such as finance (fraud detection), e-commerce (recommendation), and ridesharing (pricing).

Code Example

Feature Definition (Tecton SDK)

# features/user_features.py
from tecton import Entity, BatchSource, SnowflakeConfig, batch_feature_view
from datetime import timedelta

# Entity ์ •์˜ - ํ”ผ์ฒ˜๊ฐ€ ์—ฐ๊ฒฐ๋  ๋น„์ฆˆ๋‹ˆ์Šค ๊ฐ์ฒด
user = Entity(
    name="user",
    join_keys=["user_id"],
    description="๊ณ ๊ฐ ์—”ํ‹ฐํ‹ฐ"
)

# ๋ฐ์ดํ„ฐ ์†Œ์Šค ์ •์˜
user_transactions = BatchSource(
    name="user_transactions",
    batch_config=SnowflakeConfig(
        database="ANALYTICS",
        schema="PUBLIC",
        table="user_transactions",
        timestamp_field="transaction_time"
    )
)

# ๋ฐฐ์น˜ Feature View ์ •์˜
@batch_feature_view(
    sources=[user_transactions],
    entities=[user],
    mode="spark_sql",
    batch_schedule=timedelta(days=1),
    ttl=timedelta(days=30),
    online=True,
    offline=True,
    feature_start_time=datetime(2023, 1, 1),
    description="์‚ฌ์šฉ์ž ๊ฑฐ๋ž˜ ํ†ต๊ณ„ ํ”ผ์ฒ˜"
)
def user_transaction_features(user_transactions):
    return f"""
        SELECT
            user_id,
            transaction_time,
            COUNT(*) as transaction_count_30d,
            SUM(amount) as total_amount_30d,
            AVG(amount) as avg_transaction_amount,
            MAX(amount) as max_transaction_amount,
            COUNT(DISTINCT merchant_id) as unique_merchants_30d
        FROM {user_transactions}
        WHERE transaction_time >= CURRENT_DATE - INTERVAL '30 days'
        GROUP BY user_id, transaction_time
    """

Real-Time Streaming Feature

# features/realtime_features.py
from tecton import StreamSource, KafkaConfig, stream_feature_view
from tecton.types import Field, String, Int64, Float64, Timestamp
from datetime import timedelta

# Kafka ์ŠคํŠธ๋ฆผ ์†Œ์Šค
click_events = StreamSource(
    name="click_events",
    stream_config=KafkaConfig(
        bootstrap_servers="kafka:9092",
        topics=["user-clicks"],
        timestamp_field="event_time"
    ),
    schema=[
        Field("user_id", String),
        Field("event_time", Timestamp),
        Field("page_id", String),
        Field("session_id", String)
    ]
)

# ์‹ค์‹œ๊ฐ„ ์œˆ๋„์šฐ ์ง‘๊ณ„ Feature
@stream_feature_view(
    source=click_events,
    entities=[user],
    mode="spark_sql",
    aggregation_interval=timedelta(minutes=1),
    aggregations=[
        Aggregation(column="page_id", function="count", time_windows=[
            timedelta(minutes=5),
            timedelta(minutes=30),
            timedelta(hours=1)
        ]),
        Aggregation(column="session_id", function="count_distinct", time_windows=[
            timedelta(hours=1),
            timedelta(hours=24)
        ])
    ],
    online=True,
    offline=True,
    feature_start_time=datetime(2024, 1, 1),
    description="์‹ค์‹œ๊ฐ„ ์‚ฌ์šฉ์ž ํด๋ฆญ ํ”ผ์ฒ˜"
)
def user_click_features(click_events):
    return f"""
        SELECT
            user_id,
            event_time,
            page_id,
            session_id
        FROM {click_events}
    """

Feature Service Definition and Serving

# feature_services/fraud_detection_service.py
from tecton import FeatureService
from features.user_features import user_transaction_features
from features.realtime_features import user_click_features
from features.device_features import user_device_features

# ์—ฌ๋Ÿฌ Feature View๋ฅผ ๋ฌถ์–ด Feature Service ์ƒ์„ฑ
fraud_detection_service = FeatureService(
    name="fraud_detection_service",
    features=[
        user_transaction_features,
        user_click_features,
        user_device_features
    ],
    description="์‚ฌ๊ธฐ ํƒ์ง€ ๋ชจ๋ธ์šฉ ํ”ผ์ฒ˜ ์„œ๋น„์Šค"
)

# ----- ์ถ”๋ก  ์‹œ ํ”ผ์ฒ˜ ์กฐํšŒ (Python SDK) -----
import tecton

# Feature Service ๊ฐ€์ ธ์˜ค๊ธฐ
fs = tecton.get_feature_service("fraud_detection_service")

# ์˜จ๋ผ์ธ ํ”ผ์ฒ˜ ์กฐํšŒ (์‹ค์‹œ๊ฐ„ ์ถ”๋ก )
features = fs.get_online_features(
    join_keys={"user_id": "user_123"}
)

print(features.to_dict())
# {
#     "transaction_count_30d": 45,
#     "total_amount_30d": 12500.0,
#     "avg_transaction_amount": 277.8,
#     "user_click_features__page_id_count_5m": 12,
#     "user_click_features__session_id_count_distinct_1h": 2,
#     ...
# }

# ์˜คํ”„๋ผ์ธ ํ”ผ์ฒ˜ ์กฐํšŒ (ํ•™์Šต ๋ฐ์ดํ„ฐ ์ƒ์„ฑ)
training_events = spark.read.parquet("s3://bucket/training_events/")

training_data = fs.get_historical_features(
    spine=training_events,  # user_id, timestamp ์ปฌ๋Ÿผ ํฌํ•จ
    timestamp_key="event_timestamp"
).to_spark()

training_data.write.parquet("s3://bucket/training_features/")

Serving Features via REST API

# REST API ํ˜ธ์ถœ ์˜ˆ์‹œ
import requests

TECTON_API_URL = "https://app.tecton.ai/api/v1/feature-service/get-features"
TECTON_API_KEY = "your-api-key"

headers = {
    "Authorization": f"Tecton-key {TECTON_API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "params": {
        "feature_service_name": "fraud_detection_service",
        "join_key_map": {
            "user_id": "user_123"
        },
        "workspace_name": "production"
    }
}

response = requests.post(
    TECTON_API_URL,
    headers=headers,
    json=payload
)

features = response.json()["result"]["features"]
print(features)
# [45, 12500.0, 277.8, 12, 2, ...]

Practical Conversation Example

Meeting: Discussing Feature Store Adoption

ML engineer:
"We're computing the same features differently for each model, so the results are inconsistent. We also have Training-Serving Skew, where feature values differ between training and inference."
Tech Lead:
"We should consider adopting a Feature Platform like Tecton. With Feature-as-Code, once you define a feature, you can use the same logic for both training and serving."
Data Engineer:
"I built a pipeline myself that processes Snowflake data with Spark and stores it in DynamoDB, but it's hard to maintain."
Tech Lead:
"Tecton automatically synchronizes the Offline Store and Online Store, and it also guarantees Point-in-Time Correctness. It also increases feature reuse, which raises overall team productivity."

Interview: Feature Engineering Experience

Interviewer:
"How did you serve features in a real-time ML system?"
Candidate:
"I used Tecton to manage batch and streaming features in an integrated way. I computed batch features as daily batches in Snowflake, and for real-time features I did window aggregation on Kafka streams."
Interviewer:
"How did you handle the Data Leakage problem?"
Candidate:
"I used Tecton's Point-in-Time Join. When generating training data, I specified a timestamp key so that only features that were actually available at the time of each event are retrieved."

Code Review: Reviewing a Feature Definition

Senior:
"You set this feature to online=True, but if it's computed as a daily batch, feature freshness can be delayed by up to 24 hours. Is that OK for real-time inference?"
Junior:
"It's a 30-day aggregation feature, so a one-day delay seems fine, but what should we set the TTL to?"
Senior:
"Set it longer than the batch interval, around ttl=timedelta(days=2). Even if a batch fails, the previous value will still be served. Also check the null ratio on the feature monitoring dashboard."

Take a mock interview on this topic โ†’ WIA SOOM AI Interview ยท Start for free

Cautions

Point-in-Time Correctness

Be sure to use Point-in-Time Join when generating training data. If future data is used at a past point in time, Data Leakage occurs, in which the model shows better performance than it actually has.

Online/Offline Consistency

Even with the same feature definition, values in the Online Store and Offline Store can differ. Carefully verify the aggregation window, timezone, and null handling logic.

Feature Freshness

Batch features incur delay according to batch_schedule. Implement features where real-time freshness matters with a Stream Feature View, and set the TTL appropriately to prevent serving stale data.

Cost Management

Costs for the Online Store (DynamoDB, Redis) and streaming compute can increase. Rather than serving all features online, set only the features needed for real-time inference to online=True.

Schema Change Management

When changing a feature schema, check compatibility with existing models. Adding a new feature is safe, but deleting an existing feature or changing its type can affect models that are being served.

Related Terms

Learn More

Official Documentation

Tecton Documentation

SDK reference, tutorials, architecture guides

docs.tecton.ai
Blog

Tecton Blog

Feature Engineering best practices, case studies

tecton.ai/blog
Training

Tecton Academy

Learning courses from Feature Platform basics to advanced

tecton.ai/academy
Community

Tecton Community Slack

ML engineer community, Q&A and discussion

tecton.ai/community