Kindly Provide your views on the below design
Context : Practicing for Staff level roles
Question:
Event tracking systems like Amplitude help organizations understand how users engage with their product, allowing them to optimize the user experience, improve retention, and drive business growth
Here's a brief overview of its core functionality:
Event Collection:
Events are generated whenever a user interacts with the application (e.g., clicking a button or completing a transaction).
The system typically provides SDKs (Software Development Kits) or APIs for developers to integrate with their apps, enabling them to send events to the server.
Event Storage:
Events are stored in a database, often a distributed, scalable one, to handle large volumes of data.
This data is stored with relevant metadata such as user ID, session ID, timestamp, and the event's properties (e.g., the product being purchased, the page viewed).
Event Processing and Querying:
The system provides tools to process and query the events. It allows you to perform aggregations, calculate metrics (e.g., retention rates, conversion rates), and segment the data (e.g., by user demographics, behavior, etc.).
Querying might be done in real-time or batch modes, depending on the architecture.
Data Analysis:
The system allows product and data teams to analyze patterns in user behavior, track user journeys, and identify trends over time.
Advanced features may include cohort analysis, funnel analysis, and A/B testing to measure how different user groups behave or how they respond to changes in the app.
Visualization:
The system provides dashboards and reporting tools to visualize the data. This includes charts, graphs, heatmaps, and more, helping teams make data-driven decisions.
Segmentation:
It enables segmentation of users into different groups based on specific attributes or behaviors. For example, you could track users who have completed a particular action (e.g., adding a product to the cart) and compare their behavior with those who haven’t.
Real-time Monitoring:
Real-time tracking and monitoring are crucial for spotting issues immediately. The system can trigger alerts when certain thresholds are crossed (e.g., a sudden drop in user engagement or errors occurring in high frequency).
Integration:
Event tracking systems integrate with other tools in the tech stack, such as analytics, CRM systems, or marketing platforms, to drive targeted campaigns, personalized user experiences, and data enrichment.
Solution:
Clarifying questions
- What’s the expected event ingestion rate (e.g., events per second)? - assume an initial rate of 10,000 to 50,000 events per second
- Do we need to support real-time analytics or just batch processing, or both? - We need to support both real-time and batch processing
- How long should we store the event data - The retention period for event data is typically around 90 days to 1 year
- What properties should each event carry? Should we allow arbitrary custom properties, or is there a predefined schema?
- What are the most common queries and types of reports the system needs to support? -
Each event should contain the following key pieces of information:
- Event Name: What action the user took (e.g., "button click", "page view").
- User ID: A unique identifier for the user (anonymized if necessary).
- Session ID: To track user sessions and group events within a session.
- Timestamp: When the event occurred.
- Device/Platform Info: Information such as the user’s device type (mobile, desktop), operating system, and app version.
- Event Properties: Custom properties specific to the event (e.g., the product ID for a purchase event, the URL for a page view).
- Geo-location: If available, based on IP or GPS data
Below is Design

Link : https://excalidraw.com/#json=z9Arj0LVYX9aLejfiEwlX,2zf_8IdREuV7JrTdGkZ2-g
The SDKs send events to a high-throughput event ingestion system (e.g., Kafka or Kinesis). These SDKs should handle retries, batching, and timeouts to ensure data is reliably sent.
Once events are ingested, they go through a validation process (check for malformed events, missing fields, etc.) and possibly enrichment (e.g., add geo-location data).
Processed data is stored in a database that allows efficient querying
For this system, I will be using Columnar db like ClickHouse or Apache Druid due to their optimization for OLAP workloads, support for real-time and batch processing, and ability to scale horizontally. These databases are optimized for large-scale, high-throughput environments like event tracking systems.
As for realtional database it is not ideal for high-throughput, large-scale time-series data; performance can degrade with massive data volumes; scalability can be challenging without sharding
and for non-relational we are limited with querying capabilities (e.g., joins are expensive), consistency trade-offs (eventual consistency may be acceptable for this system).
We will Organize data in partitions (e.g., by day, week) to make querying more efficient. Each partition stores event data for that period, and tables are designed to optimize for the most common queries (e.g., aggregations by event_type, user_id).
For real-time processing, tools like Apache Flink or Kafka Streams can be utilized to process data as it arrives, enabling use cases such as tracking active users or generating dynamic metrics that require up-to-the-second accuracy. On the other hand, batch processing can be used for jobs that run periodically, such as hourly, to compute aggregated data for queries like monthly active users or user retention, which don't require real-time data updates. Finally, a query engine such as Presto, ClickHouse, or a custom SQL engine can be employed to process user queries by efficiently aggregating and filtering the event data stored in the database, ensuring fast response times even with large datasets.
The system provides querying capabilities for users to analyze events. It may include:
Real-Time Analytics: Supports aggregation and querying of real-time data.
Historical Analytics: For querying past events, providing deeper analysis of trends and patterns.
For Visulalization we can use tools like Grafana, etc.
We can persist the older data in Big Query and can have a sync service which will sync the data every week giving less load on our databases.

