<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chester Chen on Medium]]></title>
        <description><![CDATA[Stories by Chester Chen on Medium]]></description>
        <link>https://medium.com/@chesterxgchen?source=rss-30f234d8d8b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Chester Chen on Medium</title>
            <link>https://medium.com/@chesterxgchen?source=rss-30f234d8d8b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 15:27:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chesterxgchen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The GoPro’s Data Journey : 2016–2022 Reflections]]></title>
            <link>https://medium.com/@chesterxgchen/the-gopros-data-journey-2016-2022-reflections-1b4263615559?source=rss-30f234d8d8b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b4263615559</guid>
            <category><![CDATA[machine-learning-platform]]></category>
            <category><![CDATA[modern-data-stack]]></category>
            <category><![CDATA[data-science-engineering]]></category>
            <category><![CDATA[building-data-team]]></category>
            <category><![CDATA[data-infrastructure]]></category>
            <dc:creator><![CDATA[Chester Chen]]></dc:creator>
            <pubDate>Fri, 25 Mar 2022 17:36:19 GMT</pubDate>
            <atom:updated>2022-03-31T15:56:11.742Z</atom:updated>
            <content:encoded><![CDATA[<h3>The GoPro’s Data Journey : 2016–2022 Reflections</h3><h3>Chester Chen</h3><p>former Director, Data Science Engineering at GoPro.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpvdqVkrz05FqqA5cactug.jpeg" /></figure><p>TL;DR</p><p>In 2020, I was reading article about Intuit Data Journey ( <a href="https://medium.com/intuit-engineering/the-intuit-data-journey-d50e644ed279">https://medium.com/intuit-engineering/the-intuit-data-journey-d50e644ed279</a>), inspired, I thought I should write up about GoPro’s data journeys and reflections at some point. Now, March 2022, it is about the time to reflect near 6 years’ efforts at GoPro. Our team is small, but journey is similar.</p><p>GoPro is a great American brand and market leader in action camera. With GoPro’s camera, there is also an ecosystem around the camera. This including mobile app that controls the camera, mobile app that edits the video &amp; image, composes story with music, desktop app for review and edit media content, e-commerce that sales camera &amp; associated products such as GoPro lifestyle gears, camera accessories on gopro.com. There are also cloud-based media libraries to store and edit (soon) users’ media . GoPro has Camera as Hub (CAH) features which enable camera to upload the media directly to GoPro cloud storage. GoPro provides subscriptions for user to have unlimited cloud storage and amazing discounts on camera &amp; accessories; GoPro’s Quik subscriptions that enable premium editing features. User will get flashback emails that remind them wonderful moments. The whole product ecosystem generates a lot of user activities and event data that feed into back-end data lake or lake house. These data includes camera event logs, mobile events logs, web analytics data, desktop event logs, subscriptions transaction, cloud media activities, AWS event logs, e-commerce transactions and many other data. In addition, we have marketing and advertising activities from CRM (Email, mobile, SMS, Web), Ads (Facebook, TickTok, Google etc.), Social Media data, marketing campaign responses cross all channels, service email response and customer support data. That’s a just tons of data that flow into GoPro’s Data Lake.</p><p>With GoPro’s more and more focus on data-driven, data become fundamental in business decision. A data platform which ingests, transforms a steady stream of raw data into a well curated of high quality data will help to bring out more product features &amp; users insights, leads to better product improvements and personalized user engagements. The team that ingests, curates and analyze data become critical to the company. If we continue in that direction, the team could become the intelligent hub of the product and business.</p><p>Over the past six years, we have developed the foundations for data lake, including scalable ingestion and transformation infrastructure that has clear separation of compute and storage layers; an automated analytics reporting framework, BI visualization framework and process, machine learning platform &amp; production machine learning pipelines.</p><h3><strong><em>Back To The Future</em></strong></h3><p>Back in mid 2016, Data Science Engineering (DSE) team was at crisis point: when I first arrived at the DSE, there was mass exodus of talents: over half of team left within 2 months for various reasons; within few months, only 3 of the original a dozen-people team remains. We need to quickly recruit new talents &amp; rebuilt new team. On top of it, we found many other challenges with existing legacy data infrastructure &amp; development process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QtxfXrsGa-TAnyN3jKsLHQ.jpeg" /></figure><p><strong>Infrastructure issues</strong></p><ul><li>the existing fixed-sized Hadoop cluster doesn’t scale, so it was unable to satisfy the data analysts demands in the morning, while sitting idle in the evening.</li><li>data analysts can’t use notebook for ML learning tasks, the UI interface only support SQL.</li><li>Compute infrastructure lacks of elasticity</li><li>Daily failures is normal when copy data among different compute clusters</li><li>Strong coupling in compute and storage : when we need to add one more node to the cluster, we need to add storage as well, even though storage is enough.</li><li>Separated hive meta stores for each Hadoop Clusters (Batch, Streaming and Analytics)</li></ul><p><strong>Process issues</strong></p><ul><li>There was no proper software engineering development process, no code review process, the code quality is totally depends on individual developer skill set.</li><li>Many codes were deployed to production without basic testing, no unit tests.</li><li>Production access control is lacking. Developer can directly go to production machine and start to code and modify production on the fly.</li><li>No CI/CD deployment process, developer manually compiled from desktop and copy the artifacts from dev laptop to the production</li><li>in many cases, production code is not the same code in git repository. We even have cases where production has no source code in github, we have to decompile the binary code to figure out what the source code trying to do.</li></ul><p><strong>Technology issues</strong></p><ul><li>there was no common frameworks for data ingestion and transformation, every task is one-off job</li><li>A custom-built legacy workflow framework was in place, but not able to cover variable cases of workflow</li><li>The team leveraged mostly Hive SQL scripts + Shell Scripts for all the projects</li><li>A third party pipeline orchestration scheduler can only be modified from a single window machine, even though all jobs are running on Linux OS. Not only that, no one can upgrade the software, this can only be done by third party expert, and in the last upgrade, an expert was flown from Israel to do the upgrade.</li></ul><p><strong>Cost issues</strong></p><ul><li>Very expensive 3rd party multi-year licenses to maintain the on-premise Hadoop clusters</li><li>Very expensive AWS EBS volume and compute costs with many cluster nodes (all clusters are running 24x7)</li><li>the team have signed a half-dozen commercial licenses for different services ranging from feature engineering, diagnostics, tools and other data services. Except that the team ends up not really using them, or not in a stage to fully utilize them. This costs hundreds of thousands of dollars each year.</li></ul><p><strong>Business related issues</strong></p><ul><li>Although we collect a lot of data from many data sources at that point, there was a weak tie to the business operation. The team played passive supporting roles, rather than active roles in data collection, process, reporting. There was very loose tie to marketing activities and no direct supports for most of the business production or services.</li><li>There were strong believe that we should guard against data schema changes, any new changes must be reviewed and approved by the data team. This becomes a bottleneck in terms interactions with other product teams who want to move fast and needs quickly implement analytics data event that can change independent of data team’s approval process.</li></ul><p>Realize that we had reached a tipping point we need a new team and new data infrastructure.</p><ul><li><strong>Move to cloud: </strong>For the new data infrastructure, we decided to move to cloud, with particular emphasis on the compute &amp; storage separation, centralized hive metastore, elasticity and enable machine learning capabilities.</li><li><strong>Build new team: </strong>Before we can move to the cloud, we must build new team. With new team, we focused on the talents with distributed computing, software development experiences, less on data warehousing analytical skill set.</li><li><strong>Build new process: </strong>we not only need instruments standard software development process such source control, unit testing, code review, CI/CD, but also development a new process for dev, staging and production deployments. Enable safe dev, testing and production rollout</li><li><strong>Building new frameworks: </strong>We developed common frameworks for ingestion and transformation based on Apache Spark and Spark Streaming and replaced the old workflow with new Apache Airflow, building data quality monitoring, reporting and visualization frameworks</li><li><strong>Reduce costs:</strong> By moving to AWS cloud, centralized hive metadata, using S3, on-demand compute, elastic clusters, we significant reduced costs. All extra/non-essential software licenses were terminated.</li><li><strong>Enable machine learning capabilities: </strong>With adopting Databricks notebook, we are able to perform SQL/python/Scala/Shell Scripts all in the same notebook. We can prototype machine learning code directly on the notebook. Enjoy the same flexibility of Jupyter Notebook. Analytics can schedule their work using built-in scheduler as well.</li><li><strong>Data as service: </strong>While we rebuilding the DSE infrastructure, we always aware there is need to provide data as service for different business units. So we did several data service tools to help business units.</li><li><strong>Strengthen business ties:</strong> Once we had the proper infrastructure, we also strength the ties to the GoPro’s product development, marketing, and business operations and becomes integral part of business operations with data services</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73MOuf0gv8_YK6WUarJd5A.jpeg" /></figure><h3>Building The Data Team</h3><p>I noticed that the previous team was mostly composed of the engineers with warehouse and data analyst backgrounds. Although they are experts in data schema design, SQL, but a bit weak in software engineer discipline and process. Many of them had exposure to big data (using Hadoop cluster Hive/Impala SQL), but no experience in Scala, Spark or Mapreduce Jobs. To building frameworks and data infrastructures, I decided to hire several software engineers with mixed experience in system design, distributed computing, big data (Hadoop/Spark) experiences. Most of them are very senior engineers who can anchor the team. Lucky for me, several my old colleagues and friends joined me, with few excellent data engineers and software architect remaining in the team, it gave me a good foundation of the team. We then hired a few Junior engineers and data analyst in next year or so. This forms the US Data Science Engineering (DSE) team.</p><p>Few years later, GoPro decided to open office in Bucharest, Romania. The Romania teams grow pretty quickly covering wide range of software development areas from web development, e-commerce, QA, firmware and devOp. My team also built a 5-person team in Romania. But It is a bit challenging to recruit talents with big data experience in Romania, so we end up hires software engineers and provided the in-house training on Scala and Spark.</p><p>Over next few years, the DSE team grows to a dozen members made of software engineers, machine learning engineer, data or analytics engineer. Our responsibility includes</p><ul><li>build and enhance data infrastructure (Data lake, pipeline orchestration, compute infrastructure, visualization platform, ML platform, reporting framework)</li><li>build and maintain data ingestion and transform pipelines</li><li>create and maintain production metrics reporting &amp; visualization for GoPro’s different business and products</li><li>support marketing operation with automated data supports: customer data platform integration, SMS integration, email, advertising, mobile/web campaign notifications</li><li>build and maintain machine learning pipelines for user behavior analysis (such as purchase propensity, churn, LTV) and recommendations system (in progress)</li></ul><p><strong>One team vs. two-team</strong></p><p>One questions people might ask why structure the team in such a way ? why not split the team into smaller teams and each focused on specific areas such as</p><ul><li>Infrastructure team</li><li>Data/Analytics engineering team</li><li>machine learning team</li></ul><p>so that infrastructure team focused just the data lake &amp; ML infrastructure and framework and data/analytics engineering team focused on handle business requests, metrics reporting, and ML pipelines ?</p><p>At one point, we did think of doing this, but eventually drop the idea based on team’s feedbacks. Above split make sense for a bigger company with a large team. For GoPro, our team is small ( a dozen engineers), split team will cause lacks of flexibilities</p><ul><li>priority mis-match: critical/high priority business requirement may not be able to complete on time due to lack of resources, meanwhile infrastructure team is working on long-term infrastructure that doesn’t have a tight deadline</li><li>missing context &amp; exposures: separate infrastructure team may be lack of the business contexts on business needs, also lack of exposures to other teams and business.</li><li>cross-domain skill development: some members of the data engineering team would like to add software development skills in additional to the data engineering work. Some software engineers won’t mind working on some data engineering or visualization work from time to time.</li></ul><p>We end-up keep as one team, but assign more infrastructure projects to certain group of engineers with some data engineering job; others with mostly data/analytics engineering work, but mixed with other software engineering tasks under guidance of infrastructure developers. In general, certain analytics focused engineers are never going to work on complex infrastructure project; similarly, some infrastructure engineers will never dive into the messy data analytics. But infrastructure engineers will do some data ETL projects; and ML engineers will work on data engineering as well.</p><p>When the company and the team become larger, it might be make sense to have separate teams to working on different special areas. So far, one team works.</p><h3>Strengthen Business Relationships</h3><p>When I first join GoPro, Data Science Engineering (DSE) is a supporting team that provides data to Analytics team. All our requirements, regardless of the products or services, marketing, would come from Analytics Team. The Analytics team has different data analysts focused on each product or service. The main tasks are Product Analytics. User behavior analysis was not the main focus. The marketing (email and advertising) operation was manual for the most part. If there is a need, analyst would write up the requirements with a list of fields they needs, we will just built table to include the fields. As to why do we need these fields, what’s the purpose of these fields, whether these fields will achieve the desired goals, those were not much of our concern. Our convens are consistently deliver these data as asked in a tabular format.</p><p>At certain time, we started to asking questions about the requirements, and asked for more upcoming projects for planning and future requirements. It often took long time to get the answers or requirements we need, and many times we don’t get the answers at all. We gradually realized that analytics team don’t know answers either. We starts to reach out directly to the end customers: product team, engineering team, business units and marketing team. We are now getting the 1st hand requirements directly from them. In many cases, we are working hands-and-hands with cross-team in clarify analytics requirements, push engineering team to instrument event data, building machine learning data feedback loops, driving metrics definitions and productionizing the metrics reporting. In the process, we anticipate data infrastructures improvements needs and start to work those behind the scenes.</p><p>Today, the team is positioned not only be able to provide direct data support for the Analytics team, but also ready to become a core intelligent unit that can direct support product innovation as well.</p><ul><li>Direct support GoPro camera analytics, crash diagnostics</li><li>Through the customer data platform (CDP) &amp; SMS initiative, DSE supports the cross-channel ( Email, SMS, Mobile, Web) marketing for both CRM and advertising, which directly impact companies revenue</li><li>DSE team provides automated metrics reportings for all kinds of metrics: marketing campaign reports, product analytics (camera, e-comm, subscriptions, editing, desktop, live streaming, model, media storage, media access) and business cost tracking etc</li><li>We started to working on machine learning pipeline for media (video &amp; image) recommendations to enrich GoPro Subscription services.</li><li>We setup data and machine learning pipelines to provide user-focused analysis: calculating user propensity score, survival analysis and LTV analysis</li><li>We provided direct support for brand protection using camera lookup service to avoid brand abuse.</li><li>We setup many visualization dashboards for different business units.</li><li>We are working to provide more data discovery and data service to allow more to explore data available and getting insight through self-service.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjSq4kVP_hqfiwwPy7PioA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BlnEh9FoE7J_14lyS4bSdw.jpeg" /><figcaption>data platform evolution</figcaption></figure><h3>Data Platform Evolution</h3><p>We instrumented quite few changes by replaced fix-sized hadoop clusters with elastic cloud-based computer cluster + centralized hive metastore with storage in AWS S3. At the time 2017, there were few vendors in the space, after few months of comparative POCs, we decided to use Databricks as our Spark cluster provider. Databricks flexible notebook functions (mix of different languages : SQL, python and Scala) win the favors of data scientists. Dynamic scaling cluster is another features solve our direct pain. What we end up with the followings:</p><h4>Data Infrastructure</h4><ul><li>Databricks Notebooks ( python + SQL jobs)</li><li>Databricks computing cluster management (long running Spark cluster + on-demand Spark cluster)</li><li>data lake storage management ( MySQL-backed Hive metastore + S3)</li><li>migrate on-premise HBase (expired license, unable to upgrade) to AWS EMR-HBase</li><li>migrate on-premise Kafka (expired license, unable to upgrade) to AWS MKS</li><li>configuration-driven data ingestion framework for projects and jobs</li><li>Job orchestration: moved away from Control-M to Apache Airflow</li><li>Real-time stream processing infrastructure (Apache Spark streaming + Kafka + HBase + S3)</li><li>Data catalog/data discovery ( Apache Amundsen, POC)</li><li>Faster query access ( Dremio, ongoing integration) for Superset visualization performance improvements &amp; ETL on the fly queries</li><li>Data portal (Web application with visualizations, MLOp monitoring, data service tools)</li><li>Data table format ( still exploring, we had Hudi POC several years ago, still not standardized the table format. currently mixed Parquet, Delta Lake, peaked into Iceberg)</li><li>We also experimented Spark on K8s, but process is paused due to other priorities</li></ul><h4>Analytics Platform</h4><ul><li>data visualization framework (Dremio + Apache Superset + Plotly Server, moved away from original Tableau )</li><li>data reporting framework (Slack Metrics reporting + Superset + Plotly Dashboards)</li><li>Data quality check framework ( Spark/Scala based quality check — similar to Great Expectation)</li></ul><h4>Machine Learning Platform</h4><ul><li>Pipeline orchestration with Airflow</li><li>data drift monitoring ( facets-overview-spark + data portal UI )</li><li>MLFlow integration</li><li>Model drift monitoring ( working in progress)</li></ul><h4>Databricks Integration</h4><p>Our databricks integration involves both batch spark job and Spark Streaming Job integrations. Previous Spark jobs were running on Hadoop Cluster under Yarn Cluster modes. We essentially needs three types of Spark Clusters:</p><ul><li>Long running clusters used by Analytics Team and others</li><li>Long running clusters used by Spark Streaming jobs</li><li>On-demain clusters used by Batch Spark jobs.</li></ul><p>All batch jobs are launched from CLI commands, where each job will have predefined application configuration which contains the typesafe configuration job specific details such as input, output, transform configuration etc. The configuration can be overwritten via CLI arguments. We also use typesafe configuration to store job secrets in AWS S3. It’s called dse-vault. The dse-vault configuration contains Databricks spark cluster configuration, such as default cluster runtime version, default numbers of workers, etc. Once the spark jobs failed or completed, the cluster will auto-shutdown after specified idle time.</p><p>A custom-built Airflow operator integration allows engineers to specify the cluster specification ( number of works, worker type, spark versions etc) in Airflow DAG. The airflow operator will turn these DAG properties to Cluster configurations and pass to CLI tool, which launch the Databricks clusters and run the spark job.</p><p>Streaming integration experienced some challenges including more data clusters needed created used than Hadoop/Yarn. In particular, we can over-provision spark jobs in Yarn. But In databricks we need to create separate clusters to handle this. But I will skip the discussion here as I was not deeply involved in this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2s_9C_3utP5uiEW2D83M_A.jpeg" /></figure><h3>Development &amp; Deployment Process</h3><h4><strong>Deployment model</strong></h4><p><strong>Push or Pull ? </strong>To enhance development process for the team, beside introduced the standard software development practice, we were also looking into different way of dev, testing and production deployment process. Initially, we need to move team quickly into the new development paradigm, we adapted the “push” development-deployment; and later on we changed to “pull” model.</p><ul><li><strong>Push Mode</strong>l : in this model, developer write the Spark or SQL code in local machine, when ready, the package jar file + configuration files are pushed to AWS S3, then we use CL command to launch spark cluster. The computer cluster then load the need jar files into the cluster and start processing. When the code is ready to deploy for production, the code is pushed to github. The CI/CD build the jar file from github and push the jar files to AWS S3. The rest is the same. This process worked for few years, but there are few limitations:</li><li>The deployment process requires CI/CD access AWS S3 ( security concern)</li><li>There is no production promotion process, any build can push a jar to the cluster. A broken build might affect production</li><li>There are many pre- and post- tasks that can not be captured by Spark jar file uploads</li><li><strong>Pull Model</strong>: We decided to adapt an new deployment model as proposed by team software architect. The pull model requires all artifacts in a project are packaged into a debian package. This includes spark job jars, dependencies, python files, SQL scripts and shell scripts. Most of the pipelines jobs are consistent of Airflow python DAGs, Apache Spark data ETL scala jars, SQL, shell scripts, python files and setup scripts etc. The debian package manager manages the versions of the package, it helps to drive the discipline that we need to add version changs for every change we make (as debian package manager won’t deploy the same version twice). In development model, we developed a maven package plugin that helps package different files into debian package. we setup a development env. which can simulate the production with different docker containers, which simulate EC2 node, airflow nodes, databases etc. Development will only access development vault (secret store), development hive metastore and development S3 buckets. Similarly for production and staging env. Once the code reviewed by peers and merged into master branch, the CI/CD process deployed the debian package to artifactory (as maven repository) and tag as staging. When ready, the promotion is made from Jenkins and promote the staging build to production, which trigger the tagging of the debian package to production. Only team leads can promote package to production and every needs to announce the promoted project and version in the deployment slack channel. On one of EC2 node, a systemD process will pull periodically from artifactory for debian package and perform package installation.</li></ul><h4>Development, Staging and Production Separation</h4><p>In many cases, after we did unit tests or local spark tests on our laptop, we like to try out our codes in a integrated dev env. where we can testing our packaging, or different piece of the code work together (SQL schema, jar dependency, scripts, logics with different data set, code in databricks Cluster etc.), but not in production, then move to staging for more religious tests or longer period test in staging, finally move to production, ALL of these should be without changing the code.</p><p>We were able to address this challenge. The team software architect proposed and implemented this system. now the whole team DSE follow this new dev/test/deployment process. The process has clearly separations for different environments; and able to develop and test safely without worry about mess-up the production.</p><p>The main idea for this system is the following. Since all batch jobs starts from Airflow, we can define Airflow runtime variable with dev, stage and production values. When Airflow job is executed, based on runtime env. , for each Airflow DAG, we define <strong>Job runtime secrets</strong> for different envs. These are not job application configurations, but job secrets what contains credentials. For example, it contains Databricks cluster credentials, database credentials to dev/stage/prod databases. The S3 buckets name are now determined by dev/stage/prod environment variables. From application code perspective, there is no code change, just env. variable switches. In dev env. we launch a set of docker instances to simulate different hosts, airflow and databases. In dev environment, the spark clusters is created with cluster point to dev hive metastore and dev S3 bucket. In staging and production , we also have separate set of the machines for Airflow, database. Similarly, launch spark clusters associating with staging and production hive meta stores respectively.</p><h3>Building Common Frameworks</h3><h4>Configuration standards</h4><p>We standardize the configuration on Typesafe Config (<a href="https://github.com/lightbend/config">https://github.com/lightbend/config</a>), the company has changed the name to lightbend, but we still prefer to called it Typesafe config based on it’s original name. The Typesafe configuration is HOCON: “Human-Optimized Config Object Notation&quot;, a JSON superset (<a href="https://github.com/lightbend/config/blob/main/HOCON.md">https://github.com/lightbend/config/blob/main/HOCON.md</a>). It is JVM-based configuration. It supports java property, json or HOCON formats. It supports inheritance and overwrites, variable substitutions, and includes. It comes with simple and flexible APIs. This works in both in Java and Scala languages.</p><p>For python, we used pyhocon (<a href="https://github.com/chimpler/pyhocon">https://github.com/chimpler/pyhocon</a>) which have similar APIs to Java counter parts.</p><h4>Job Frameworks</h4><p><em>To avoid every job is one-off task and make sure we conforming to common code base, reduce code duplicate, and common interface for deployment, we set up too common batch spark job frameworks:</em></p><ul><li><em>dse-common-spark : generic spark job interface, which capture the basic configuration and job CLI, all batch jobs (mostly launched from Airflow) will be based on this framework. The developer is provided a subMain(), contains SparkSession, Configuration and Vault ( job secrets) to implements. There is no other interface need to follow. With this, developers pretty just use spark as they normally do, they will need to implements all the ingestion and transformation logics.</em></li><li><em>dse-batch: Batch spark jobs is based on dse-common-spark, it includes some common used HiveTable writers, common jobs such as ingest from CSV or Json to Tabular Columns can be easily done by specify Typesafe Configurations. If there are special data transformation needed for the task, one can write a custom DataFrame transform plug-in and not worry about the rest. This framework requires a lot more structures. for example, CSV file table writer requires one define input and output configurations, which includes tableName patterns. From which the CSV file table writer will auto ingest files with ABC-20220102.csv, CDE-20220201.csv into tables named ABC, CDE automatically and mark ingest_date as “20220201”, process_date will be the date the job is run. Similarly there are json file table writer, JDBC table writer etc.</em></li></ul><p>With batch framework, most common ingestion jobs can be done simply by specify configurations. <em>Today, all batch jobs are derived from these two frameworks.</em></p><p><em>For both streaming and batch jobs, we</em></p><ul><li><em>build Dynamic DDL (</em>data description language) <em>for base-table ingestion, this gives the upstream flexibility to add new events and columns to our base-table without have to wait for DSE to “approve” the schema changes. We enforce the schema in the next stage ETL and gradually select the newly added columns to reflect the metrics and analytics needs.</em></li><li><em>The framework also includes many column normalization and different kind of error handling etc.</em></li></ul><h4>Metrics Publishing Framework</h4><p><em>Suggested by one of colleague about 4 years ago, we started to looking into leverage Slack channel as a way to push analytics metrics report. Although the visualization dashboards work for some, people has to login to the dashboard (in many cases, using desktop browser) and check the numbers. Slack has the benefits not only can access the metrics quickly from any device (mobile, desktop), but also allow people to discuss the metrics directly. Slack does have the limitation of the real-estate, can only display two column metrics. So we can only display metrics not all the rich interactive visualization analysis, but we put the additional dashboard and definition links in the slack and they can always to click to look at detailed interactive dashboard. After few years, we have hundreds people access different metrics channels:</em></p><ul><li><em>GoPro &amp; Quik Subscriptions metrics reports</em></li><li><em>Mobile Quik Subscription purchase funnel &amp; User activity metrics</em></li><li><em>Mobile App metrics</em></li><li><em>Quik edit media reports</em></li><li>GoPro &amp; Quik Subscription media service reports</li><li>Camera firmware update metrics</li></ul><p><em>In the Slack reporting framework, we leverage Plot.ly API, dynamically generate visualization image and save the image in S3, and display the image through our web portal rest API service in Slack channels.</em></p><p><em>Today, product managers rely heavily on our daily slack reports. Certain metrics pattern changes will trigger discussions. In many times, we spot the production issues via these metrics before production team realize the problem.</em></p><h4>Visualization Framework</h4><p><strong><em>Choose Visualization Tool</em></strong></p><p>Our initial visualization tool was Tableau-based, we had a tableau server and daily extract jobs to refresh the server. We have analytics team and other business analysts using Tableau to access the dashboard. Although Tableau is great tool, we found a few issues with our use case</p><ul><li>On one side, license seems never enough, on the other side, we have people with license only access the reports once or twice every few months. We have to have someone to run a prune job to remove license from people who haven’t accessed for more than 2–3 months. We are paying many licenses for someone use it maybe 1–2 times a year</li><li>With Tableau, some analysts put a lot of SQL and business logics into Tableau dashboard, when the analyst left company, and logics changes, the dashboards are essentially has to re-done, as no one knows the logics. The code is not in Github repo. If someone deleted the dashboard, we couldn’t trace the how the dashboard was built</li></ul><p>Our goal is to</p><ul><li>move the metrics generation logics into batch jobs and code will be check-in github</li><li>the visualization contains minimum or no business logics</li><li>No license constraints for people view the graph. If we have to use commercial tool, its ok to have paid license to small numbers of analysts/analytics engineers who create the dashboards. But view license should mostly free.</li><li>Able to experiment the visualization without someone look at the un-published dashboard</li></ul><p>We decided to use Apache Superset and Plot.ly server. Plot.ly Server &amp; Plot.ly Dash are favored by Analytics team. Our team decided to leverage Apache Superset, as it is open source and free, we can do customization for authentication and other integration needs. we do have to pay license for Plot.ly server, but at least number of viewers is unlimited.</p><p>while development visualization framework, one issue we faced was: how do we separate the working in progress update to the dashboard from already published charts. For new dashboards this is easy, as we simply will not give permission to the users. For the updated or enhanced dashboard. We do not want to user see the experiments and work in progress charts. We can use staging dashboards, but staging data is different from production data, users would still prefer to access the same data, so the numbers are realistic. Most importantly, once we verified in the staging, how to we transfer it to production?</p><p>We setup several superset instances for different environments. For production, we setup two Superset instance, both point to the production data. One named “Sandbox”, and another named “Production”. The sandbox is private to the team, developer can develop visualization freely in Sandbox Superset. When ready, he/she can “archive and publish” the dashboard to the production superset server.</p><p>“Archive and Publish” is a custom Superset UI action we developed, it performs the following tasks:</p><ul><li>Download the the current dashboard in JSON format and store in MySQL database as text blog. The JSON format is Superset’s export format. It contains all the charts and dashboards layout. This allows one to restore or rollback previous dashboard if needed.</li><li>The JSON block will be loaded from MySQL database and re-loaded ( via Superset’s import command) to “Production” Superset server.</li></ul><p>We have to modify the existing Superset code-based and UI to introduce such change.</p><p>If the new dashboard introduced new data sources ( new database connections for example), the developer needs to check-in the datasource config file (YAML) into github, the check-in data source must remove embedded credentials and replace with dummy placeholders. The code-review will ensure that’s done correctly. We insist to have github datasource check-in process is to ensure the production can be easily replicated to another machine without manual intervention. Once the data source is in github, following the deployment process, it will be packaged in to debian package, and deployed to Production Superset server. A systemD service will pull new data sources from antifactory debian repository and load to Superset production.</p><p><strong>Automatic Access</strong></p><ul><li>Initially, when new users try to access Superset Dashboard, they have request to have access. It becomes detious and users have wait for the permissions</li><li>We developed LDAP to Superset Role mapping. So when user login via LDAP, we automatically grant the permission depends on user’s department.</li><li><em>When login to data portal via LDAP, we automatically login Superset. This avoid double login user has to do</em></li></ul><p><strong>Visualization Performance</strong></p><p>When accessing the data from Superset, we have performance issue. Superset provides several out of boxes data sources which allow one to access RDBMS, Apache Druid, CSV File etc. But Since our data is at S3 with Hive Metastore, we have to directly read from S3/Hive Metastore or access via Databricks. At first, we tried to use a modified version of pyHive to access via a long running Spark cluster directly. But its too slow, so we decide to aggregate the data and export the data to MySQL, then connect superset to mySQL. This works in most cases, but there are few limitations</p><ul><li>Aggregate the data in Spark job, then use Spark JDBC connector export the data to MySQL, not only it adds extra cost, but also limit the expressness of data visualization</li><li>when data is large (few million rows), loading Superset from mySQL is still slow</li><li>We usually set the cache key on Redis ( used by Superset) expires in 24 hrs. When looking at the dashboards, Superset trying to load many of charts together , especially when there are many charts in the same dashboard. This will show the query timeout and long time spins.</li></ul><p>Our current approach is to use Dremio to directly access parquet data in S3, and let Superset to connect to Dreamio. This avoids the extra aggregation and export to Step to MySQL. The initial test shows that result is very promising.</p><h4>Data Quality Monitoring Framework</h4><p>While data monitoring tells us the potential issues with data ingestions or the transformation pipeline, it doesn’t tell us the data quality during data transformation. We started to work on Data Quality Check framework in late 2019 and earlier 2020, the framework starts with rule-based column checks for camera pipeline, it evolves into general data quality check framework for all tables and feature engineering works with many checks mirror the checks in “Great Expectations” framework. The Framework is written in Scala and Spark. The output of the quality check goes to a data quality table and can be visualitioned later in dashboard. The pipelines that failed to pass the critical threshold will trigger pipelines to fail.</p><p>There is a larger trends in data quality monitoring and observations. we are debating how much observation/monitoring do we need ? do people actually check the monitoring dashboards once we build ? what’s the critical monitoring we must have ? As right now, we settled only add dashboards on critical pipelines, add critical data quality checks in the pipeline and make sure the pipeline fails if the critical quality check criteria failed to pass.</p><h4>Machine Learning Platform</h4><p>Our initial machine learning use cases are from marketing operation (LTV, Propensity, Churn) and media recommendations (video/image). The ML jobs are offline batch jobs so far. We leverage the current Airflow orchestration to manage the pipeline, feature generation, validation and model training. we are looking into the following area</p><ul><li>Model lifecycle management</li><li>Feature engineering</li><li>data quality and model monitoring</li></ul><p>we are particularly interested in</p><ul><li>Data distribution drift monitoring</li><li>Model tracking &amp; monitoring</li></ul><p>We first developed a data visualization framework for feature statistics based on Google Facets (<a href="https://pair-code.github.io/facets/">https://pair-code.github.io/facets/</a>). The framework is extended to handle big data using Spark (<a href="https://github.com/gopro/facets-overview-spark">https://github.com/gopro/facets-overview-spark</a>). The facets-overview-spark project open sourced in 2018.</p><p>For different ML pipelines, we use Spark SQL to generate Data Frames, then we pass the training and test data frames to the facet-overview-spark to generate the statistics and save the resulting protobuf into AWS S3. DSE data portal rest API will load the protobuf file into memory and then generate the HTML via Google Facets HTML template. The React UI then used to render the visualization.</p><p>For machine learning monitoring, we setup a MLFlow instance and integrated MLFlow API to monitoring the training errors.</p><p>Our current ongoing work is to leverage “feature attribution” to monitoring the model drifts for the pipeline we have label datas, other work for PSI and KS test are in the plan. We are still at very earlier stage of the ML development, there are a lot more to do in this area.</p><h4>Data Services</h4><p><em>Besides providing data table, metrics reporting and ML pipelines, we also developed a data portal to help different business units to find data solutions.</em></p><p><strong><em>Camera lookup tool </em></strong><em>— this a tool used by Brand Protection team to fight against those who abuse the brand policy. This tools saved GoPro millions of dollars.</em></p><p><strong><em>data tracking tool </em></strong><em>— tracking datas flow and help debug the data payload</em></p><p><strong><em>Visualization — </em></strong><em>group different dashboards into similar collections. Superset can provide dashboard, but Superset doesn’t have grouping function, for example, we like to group all related dashboard together. Such as Subscription Analytics, Camera Analytics, Mobile Analytics etc. With DSE portal, we can embed the Superset as IFrame and group related visualization together.</em></p><p>When user try to view Superset dashboard, Superset requires authentication as well. To avoid user double login, we did additional integration to auto login users based on users LDAP credentials. <em>When user logins to data portal via LDAP, we automatically login Superset. This avoid double login user has to do.</em></p><p>In additional, we map the user LDAP department with user’s Superset Roles (permissions), so when a new user visited first time, we don’t need to assign permissions. User already granted the proper permissions.</p><p><strong><em>Data and ML Model Monitoring </em></strong><em>— data drift and other monitoring visualization can also accessed from data portal ( ongoing)</em></p><p><strong><em>Data Catalog access</em></strong><em> ( ongoing) — intend to embed Amundsen URL to dse-portal. so user can discover the published tables and its quality</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ap2h9IMANYLoQ8FIBrjJZg.jpeg" /></figure><h3>Summary</h3><p>As mid-2018, we migrated our entire data pipelines to the new infrastructure ( with HBase and Kafka migrated in 2 years later). We have seen much fewer operational issues since move to the new platform. We greatly increase the capacity for analytics team, yet significantly reduce the AWS cost and license cost. Data scientists are now capable of running SQL, python, Scala and do quick visualization. It also helps our teams for debugging and analysis in Scala. For metrics production, we introduce reporting framework which can automatically deliver the basic reports to Slack channel and provide the data for visualization. We also built a strong business relations with core business including cloud-media service, subscriptions (multiple), e-commerce, multiple mobile apps, desktop apps, marketing operations and camera, brand production and legal support.</p><p>Looking back, not only we transform the technology stack, but also the team’s responsibility as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*QjxX27_nWra8Egh8WCSgFw.jpeg" /></figure><p>The team’s initial responsibility is simply ingest the data from various data source, prepare the data table needed by Analytics team. we need to make sure the data infrastructure is scalable, data pipeline is reliable, the curated data with high quality, and data tools are available and function. At this stage, the team is mainly a support team for Analytics.</p><p>Over time, our responsibility has included to product analytics metrics generation, metrics report publication &amp; visualization, our metrics production pipeline becomes import to product and services with many people monitoring the metrics on daily basis</p><p>Next, the team is transitioned to be the cornerstone of the performance marketing production, directly impact company advertising and CRM operations, thus directly impact company revenues.</p><p>Currently, we are make another transition to become the company’s intelligence hub that support product &amp; service (camera, media, subscriptions, e-commerce), marketing intelligence and data services ( brand protection, legal data lookup and other services)</p><h3>What worked well &amp; lessons learnt</h3><p>While it took over 1 year to migrate all the pipelines and converted pretty much every single pipelines and supporting both pipelines in production, meanwhile disabled many pipelines that no longer maintainable or no one consume the produced dataset, we glad to made the decision. The benefits of the separating computing and storage is hugely important. That enable us to develop a new process that separate the dev, staging and production. Use Apache Airflow replace control-M is also important to give us a lot more flexibility and control</p><p>A configurable data ETL and reporting frameworks remove a lot of on-off jobs and make common data pipeline simple. In most cases, simply change of the configurations we are quickly enable a new data ingestion pipeline and new reporting slack channel.</p><p>The process for dev. staging and production build and deployment is another key to new infrastructure. We also leverage this process for building custom Superset and MLFlow installation as well.</p><p>During this migration process, we encounter another issue which we did not count for at beginning of the process: As our data pipeline codes as well as library are in one monolithic repository. This make it very hard to improve frameworks while make sure it doesn’t break production pipelines. When we changed the framework, now we have to test every pipelines to make sure it doesn’t break. This adds a lot of time for each framework roll out. We spent a quite some time to split the library and applications into different repositories so that application pipelines can depends on different version of the library and upgrade as needed.</p><p>Another issue comes with one team structure. Although the one team gives flexibility to allow team to work on infrastructure, data engineering and ML engineering, it does slow down the infrastructure development as the business focuses shift. Many times, the infrastructure projects have to be put to lower priority when high priority business projects are requested. The infrastructure improvement sometime is not happen as fast as we wished. This is the trade-off we made.</p><p>One things we did not do well is the related to the data cataloging. At one point, DSE team has a dictionary service maintained by one data analyst in the team. With the change of the structure and new moving to cloud effort, this data dictionary service is no longer maintained. We are in the new effort to make up this with new data catalog and data discovery service.</p><p>Well the common batch spark framework serves its purpose, there are few cases that the framework design based on inheritance makes it hard to customize. Even there are mechanism of pluggable data frame transformation, an alternative design is needed. This is on the backlog to redesign at some point.</p><p>One important lessons learned from this process is that data team and data services must serve the companies core business and production, find innovated solutions and presented to the product/business owners, work together will greatly benefits company’s overall goals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOIPTlq6fZG7OHM0EAtCZg.jpeg" /></figure><h3>Final words</h3><p><em>Looking back, it’s a lot of fun to build the team, the data lake infrastructure, create metrics production platform, build visualizations, build data service, push for machine learning application in GoPro business, building machine learning platform. In most of these years, I consistently wear several different hats: head of engineering, product manager and program manager. At the same time, I managed to find some time to code: I am the one of major contributors or sole contributor of the many projects.</em></p><p><em>Love and proud our work at GoPro, GoPro is great place to work too. Excellent work &amp; life balance, great benefits. I really appreciate GoPro gave me this opportunity to lead the Data Science Engineering team ! I equally appreciate the trusts that my (past and present) GoPro colleagues have in me. I am honored to have opportunity work with so many talents at GoPro, I learnt a lot from them. While I am looking forward to my next chapter, I wish the best for GoPro and Data Science Engineering team.</em></p><p>Many of the work mentioned above are the results of current and past DSE team members. Without naming them individually, the credits should go to them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b4263615559" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>