SlideShare una empresa de Scribd logo
1 de 47
Descargar para leer sin conexión
Orchestrating the execution of
workflows for media streaming
service and even more
Shuen-Huei (Drake) Guan
sr. principal engineer, KKBOX
vice chairperson, PyCon APAC 2015
Who am I?
• administrator, Ptt BBS
• technical director / R&D manager, Digimax
• team player, KKBOX
• contributor, PyCon Taiwan
Rather a story than tech sharing.
No any KKBOX trade secrets get revealed.
There're just some slides talking
about Python.
And, it's not about music streaming.
350 team players to serve
10M users across 6 countries
20M songs
Events
KKTIX
the always lovely sponsor!
If we can make music
streaming work, how
about video streaming?
— KKBOX CxO
Let's work on a video-on-demand service
• Adaptive streaming.
• DRM protection.
• Video processing on cloud.
We thought video streaming is
similar to music streaming,
but we were wrong.
Issue 1. Workflow
multiple distinct interconnected steps that need to be executed in
a particular order in a distributed environment...
— someone
flickr:siddhu2020
flickr:siddhu2020
http://bit.ly/1FAukT2
Sample encoding workflow for music
def run(source, secret_key, cipher):
# verify if the source is ok.
if not verify(source): return False
# convert audio with different bitrates
_ = [convert(source, i) for i in range(4)]
# update id3 tag for all converted audios
_ = update_id3_tag(_)
# encrypt all audios
_ = encrypt(_, secret_key, cipher)
# deploy to backend DB
deploy(_)
return True
Issue 2. Distribute tasks to the
cloud, and use the cloud
efficiently!
Gearman
Sample encoding workflow for music
Sample client code to submit a workflow1
$workflow = new Gearman_Workflow('KKBOX_Convert_Audio'
'source' => $source,
'args' => $args);
$workflow->attachCallback(function () {
});
$client->run($workflow);
1
warning, it's PHP.
Sample worker (server) code to do things1
class KKBOX_Convert_Audio extends Gearman_Worker {
public function run($arg) {
// check the source
if (!verify()) return;
// convert audio with different bitrates
for ($i=0; $i<4; $i++) {
convert($i);
}
// update id3 tag for all audios
update_id3_tag();
// encrypt audios
encrypt();
// sequentially deploy to backend DB
for ($i=0; $i<4; $i++) {
deploy($i);
}
}
1
warning, it's PHP.
Sample encoding workflow for video, a
little bit complicated
Sample worker (server) code to do things1
class KKBOX_Encode_Video extends Gearman_Worker {
public function run($arg) {
transcode();
encrypt();
}
}
class KKBOX_Convert_Video extends Gearman_Worker {
public function run($arg) {
if (!verify()) return;
// create asynchronous sub-workflows
$result = create_sub_workflow(KKBOX_Encode_Video);
// wait for all sub-workflows to finish
joint($result);
create_sub_workflow(KKBOX_Package_DASH, $result->encrypted);
create_sub_workflow(KKBOX_Package_HLS, $result->plain);
joint();
deploy();
}
1
warning, it's PHP.
The real gearman worker code is way more
complicated w/o elegance we like to have
Issue 3. Workflows would evolve...
• Let's save file size and IO.
• Let's make it faster.
• Let's add some more profiles.
• Let's fix some encoding.
Everything fails all the time.
— Werner Vogels, CTO of Amazon
flickr:Bill Abbott
flickr:Bill Abbott
http://bit.ly/1GnrSGr
Issue 4. Gearman server down!
Factors we like to pay much attention in
• Encoding workflow
• Tasks distributing across machines on cloud.
• Server maintenance.
We hope ...
1. no need to maintain this system;
2. easier to distribute workflow/tasks, even to local machine;
3. with high-level workflow.As long as you can draw your
processes on a paper, you can map it to a workflow!
What Google suggests us...
• Apache Kafka, Mesos, ...
• Gearman (sorry, but we've tried.)
• Luigi by Spotify
• Celery
• Potentially all message brokers with some additional work.
AWS Simple Workflow (SWF)
class HelloWorker(swf.ActivityWorker):
domain = DOMAIN
version = VERSION
task_list = TASKLIST
def run(self):
activity_task = self.poll()
if 'activityId' in activity_task:
print 'Hello, World!'
self.complete()
return True
class HelloDecider(swf.Decider):
domain = DOMAIN
task_list = TASKLIST
version = VERSION
def run(self):
history = self.poll()
if 'events' in history:
# Find workflow events not related to decision scheduling.
workflow_events = [e for e in history['events']
if not e['eventType'].startswith('Decision')]
last_event = workflow_events[-1]
decisions = swf.Layer1Decisions()
if last_event['eventType'] == 'WorkflowExecutionStarted':
decisions.schedule_activity_task(...)
elif last_event['eventType'] == 'ActivityTaskCompleted':
decisions.complete_workflow_execution()
self.complete(decisions=decisions)
return True
SWF
• Decider defines the workflow.
• We still need to write workflow logic in decider.
• Workers do the action.
• Everytime, we changed workflow or action, we need to re-
deploy deciders and workers.
Let's de-couple the workflow and
action out of SWF
Job script for a workflow
Job {KKBOX Convert Video} -subtasks {
Task {Source Inspection} -cmds {
Cmd {
emilia verify -i s3://bucket/source.mp4
}
}
Task {Transcode} --parallel -subtasks {
Iterate i -from 0 -to 4 -by 1 -template {
Task {Transcode Audio} -cmds {
Cmd {
ffmpeg -i s3://bucket/source.mp4 -o /tmp/converted_$i.mp4
}
}
}
Iterate i -from 0 -to 8 -by 1 -template {
Task {Transcode Video} -cmds {
Cmd {
ffmpeg -i s3://bucket/source.mp4 -o /tmp/converted_$i.mp4
}
}
}
}
Task {Adaptive} -subtasks {
Task {DASH} -subtasks {
}
Task {HLS} -subtasks {
}
Task {MSS} -subtasks {
}
}
}
What is exactly a job script?
Make it pythonic if that makes developers
happier
source = 's3://bucket/source.mp4'
with Job():
with Task('Source Inspection'):
Cmd('emilia verify -i %s' % source)
with Task('Transcode', parallel=True):
for i in range(4):
with Task():
Cmd('ffmpeg -i %s ... -o /tmp/a_%d.mp4' % (source, i))
for i in range(9):
with Task():
Cmd('ffmpeg -i %s ... -o /tmp/v_%d.mp4' % (source, i))
with Task('Adaptive'):
with Task('DASH'):
pass
with Task('HLS'):
pass
with Task('MSS'):
pass
Status
• 1,500,000-minute videos got encoded.
• 3,000 videos per day (max).
• 800 workers on 100 c3.8xlarge instances (max).
• spent lots of $.
• everyone is really happy for that performance.
Technical status
• Fault tolerance by retry. [decider]
• Workflow/task has priorities. [SWF]
• try..except..finally mechanism.
[-whendone, -whenerror, -precmds, -postcmds, ...]
Question:
Are you interested in this project?
To do:
• Use JSON or YAML for job script.
• A viewer to see the progress of workflows!
• Replace SWF by Apache Mesos or Mistral.
Thank You!
@drakeguan
We are hiring
• Video Engineer
• Full Stack Developer
• Python Developer

Más contenido relacionado

La actualidad más candente

Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05Alessandra Bilardi
 
Recent Change of cpm
Recent Change of cpmRecent Change of cpm
Recent Change of cpmShoichi Kaji
 
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...NETWAYS
 
Evolving big microservice architectures
Evolving big microservice architecturesEvolving big microservice architectures
Evolving big microservice architecturesNikolay Stoitsev
 
The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2Haggai Philip Zagury
 
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuff
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuffBuildinga billionuserloadbalancer may2015-sre-con15europe-shuff
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuffPatrick Shuff
 
Kamailio :: A Quick Introduction
Kamailio :: A Quick IntroductionKamailio :: A Quick Introduction
Kamailio :: A Quick IntroductionOlle E Johansson
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelinesSumant Tambe
 
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in MelbourneAnsible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in MelbourneKen Thompson
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesLars Rosenquist
 
Everything as code
Everything as codeEverything as code
Everything as codekloia
 
Modern Commandline Tool
Modern Commandline ToolModern Commandline Tool
Modern Commandline ToolYuji Shimada
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Navigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software FoundationNavigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software FoundationBrett Porter
 
Open stack gluon + opnfv netready
Open stack gluon + opnfv netreadyOpen stack gluon + opnfv netready
Open stack gluon + opnfv netreadyOPNFV
 
Modern Monitoring [ with Prometheus ]
Modern Monitoring [ with Prometheus ]Modern Monitoring [ with Prometheus ]
Modern Monitoring [ with Prometheus ]Haggai Philip Zagury
 
Using the FLiPN stack for edge ai (flink, nifi, pulsar)
Using the FLiPN stack for edge ai (flink, nifi, pulsar)Using the FLiPN stack for edge ai (flink, nifi, pulsar)
Using the FLiPN stack for edge ai (flink, nifi, pulsar)Timothy Spann
 
Everything as code
Everything as codeEverything as code
Everything as codeHepsiburada
 

La actualidad más candente (20)

Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05Automation: from local test to production deploy - 2020-11-05
Automation: from local test to production deploy - 2020-11-05
 
Recent Change of cpm
Recent Change of cpmRecent Change of cpm
Recent Change of cpm
 
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
 
Evolving big microservice architectures
Evolving big microservice architecturesEvolving big microservice architectures
Evolving big microservice architectures
 
The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2
 
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuff
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuffBuildinga billionuserloadbalancer may2015-sre-con15europe-shuff
Buildinga billionuserloadbalancer may2015-sre-con15europe-shuff
 
Scaling i/o bound Microservices
Scaling i/o bound MicroservicesScaling i/o bound Microservices
Scaling i/o bound Microservices
 
Kamailio :: A Quick Introduction
Kamailio :: A Quick IntroductionKamailio :: A Quick Introduction
Kamailio :: A Quick Introduction
 
Tuning kafka pipelines
Tuning kafka pipelinesTuning kafka pipelines
Tuning kafka pipelines
 
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in MelbourneAnsible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
 
Cloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud PipelinesCloud Native CI/CD with Spring Cloud Pipelines
Cloud Native CI/CD with Spring Cloud Pipelines
 
Everything as code
Everything as codeEverything as code
Everything as code
 
Modern Commandline Tool
Modern Commandline ToolModern Commandline Tool
Modern Commandline Tool
 
Natively clouded Journey
Natively clouded JourneyNatively clouded Journey
Natively clouded Journey
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Navigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software FoundationNavigating the Incubator at the Apache Software Foundation
Navigating the Incubator at the Apache Software Foundation
 
Open stack gluon + opnfv netready
Open stack gluon + opnfv netreadyOpen stack gluon + opnfv netready
Open stack gluon + opnfv netready
 
Modern Monitoring [ with Prometheus ]
Modern Monitoring [ with Prometheus ]Modern Monitoring [ with Prometheus ]
Modern Monitoring [ with Prometheus ]
 
Using the FLiPN stack for edge ai (flink, nifi, pulsar)
Using the FLiPN stack for edge ai (flink, nifi, pulsar)Using the FLiPN stack for edge ai (flink, nifi, pulsar)
Using the FLiPN stack for edge ai (flink, nifi, pulsar)
 
Everything as code
Everything as codeEverything as code
Everything as code
 

Destacado

KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享
KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享
KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享Shuen-Huei Guan
 
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章Shuen-Huei Guan
 
AWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardAWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardShuen-Huei Guan
 
Migrate the Mission Critical Application to AWS Cloud
Migrate the Mission Critical Application to AWS CloudMigrate the Mission Critical Application to AWS Cloud
Migrate the Mission Critical Application to AWS CloudShuen-Huei Guan
 
AWS reInvent 2016 recap Taiwan
AWS reInvent 2016 recap TaiwanAWS reInvent 2016 recap Taiwan
AWS reInvent 2016 recap TaiwanShuen-Huei Guan
 
Seamless service migration with AWS Enterprise Support
Seamless service migration with AWS Enterprise SupportSeamless service migration with AWS Enterprise Support
Seamless service migration with AWS Enterprise SupportShuen-Huei Guan
 
PyConTW 2013 經驗分享
PyConTW 2013 經驗分享PyConTW 2013 經驗分享
PyConTW 2013 經驗分享Shuen-Huei Guan
 
Python Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StylePython Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StyleShuen-Huei Guan
 
平行化你的工作 part1
平行化你的工作 part1平行化你的工作 part1
平行化你的工作 part1Shuen-Huei Guan
 
Python + NoSQL in Animations
Python + NoSQL in AnimationsPython + NoSQL in Animations
Python + NoSQL in AnimationsShuen-Huei Guan
 
Reyes and Shader Pipeline
Reyes and Shader PipelineReyes and Shader Pipeline
Reyes and Shader PipelineShuen-Huei Guan
 

Destacado (13)

KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享
KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享
KKBOX 建置日本百萬用戶等級 Video Streaming 服務的經驗分享
 
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章
從音樂走向影音服務 - KKBOX 的影音之路奮鬥史 - 序章
 
Streaming Experience
Streaming ExperienceStreaming Experience
Streaming Experience
 
AWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardAWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast Forward
 
Migrate the Mission Critical Application to AWS Cloud
Migrate the Mission Critical Application to AWS CloudMigrate the Mission Critical Application to AWS Cloud
Migrate the Mission Critical Application to AWS Cloud
 
AWS reInvent 2016 recap Taiwan
AWS reInvent 2016 recap TaiwanAWS reInvent 2016 recap Taiwan
AWS reInvent 2016 recap Taiwan
 
Seamless service migration with AWS Enterprise Support
Seamless service migration with AWS Enterprise SupportSeamless service migration with AWS Enterprise Support
Seamless service migration with AWS Enterprise Support
 
PyConTW 2013 經驗分享
PyConTW 2013 經驗分享PyConTW 2013 經驗分享
PyConTW 2013 經驗分享
 
Spatial Disorientation
Spatial DisorientationSpatial Disorientation
Spatial Disorientation
 
Python Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StylePython Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding Style
 
平行化你的工作 part1
平行化你的工作 part1平行化你的工作 part1
平行化你的工作 part1
 
Python + NoSQL in Animations
Python + NoSQL in AnimationsPython + NoSQL in Animations
Python + NoSQL in Animations
 
Reyes and Shader Pipeline
Reyes and Shader PipelineReyes and Shader Pipeline
Reyes and Shader Pipeline
 

Similar a Orchestrating the execution of workflows for media streaming service and even more

Criteo Labs Infrastructure Tech Talk Meetup Nov. 7
Criteo Labs Infrastructure Tech Talk Meetup Nov. 7Criteo Labs Infrastructure Tech Talk Meetup Nov. 7
Criteo Labs Infrastructure Tech Talk Meetup Nov. 7Shuo LI
 
Altitude San Francisco 2018: Video Workshop Docs
Altitude San Francisco 2018: Video Workshop DocsAltitude San Francisco 2018: Video Workshop Docs
Altitude San Francisco 2018: Video Workshop DocsFastly
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...Jérôme Petazzoni
 
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013Amazon Web Services
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Productiondevopsdaysaustin
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018Giulio Vian
 
Docker Internet Money Gateway
Docker Internet Money GatewayDocker Internet Money Gateway
Docker Internet Money GatewayMathieu Buffenoir
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systemssosorry
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Joe Arnold
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using SwiftDiego Freniche Brito
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019corehard_by
 
Chicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - MediaflyChicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - MediaflyMediafly
 
Возможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OSВозможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OSCisco Russia
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshopAssaf Gannon
 

Similar a Orchestrating the execution of workflows for media streaming service and even more (20)

Criteo Labs Infrastructure Tech Talk Meetup Nov. 7
Criteo Labs Infrastructure Tech Talk Meetup Nov. 7Criteo Labs Infrastructure Tech Talk Meetup Nov. 7
Criteo Labs Infrastructure Tech Talk Meetup Nov. 7
 
Altitude San Francisco 2018: Video Workshop Docs
Altitude San Francisco 2018: Video Workshop DocsAltitude San Francisco 2018: Video Workshop Docs
Altitude San Francisco 2018: Video Workshop Docs
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013
Automated Media Workflows in the Cloud (MED304) | AWS re:Invent 2013
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018
There and Back Again (My DevOps journey) - DevOps Days Copenhagen 2018
 
Docker Internet Money Gateway
Docker Internet Money GatewayDocker Internet Money Gateway
Docker Internet Money Gateway
 
Docker img-no-disclosure
Docker img-no-disclosureDocker img-no-disclosure
Docker img-no-disclosure
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
SDAccel Design Contest: Vivado HLS
SDAccel Design Contest: Vivado HLSSDAccel Design Contest: Vivado HLS
SDAccel Design Contest: Vivado HLS
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
Chicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - MediaflyChicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - Mediafly
 
Возможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OSВозможности интерпретатора Python в NX-OS
Возможности интерпретатора Python в NX-OS
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
 

Último

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Orchestrating the execution of workflows for media streaming service and even more

  • 1. Orchestrating the execution of workflows for media streaming service and even more Shuen-Huei (Drake) Guan sr. principal engineer, KKBOX vice chairperson, PyCon APAC 2015
  • 2. Who am I? • administrator, Ptt BBS • technical director / R&D manager, Digimax • team player, KKBOX • contributor, PyCon Taiwan
  • 3. Rather a story than tech sharing. No any KKBOX trade secrets get revealed.
  • 4. There're just some slides talking about Python. And, it's not about music streaming.
  • 5.
  • 6. 350 team players to serve 10M users across 6 countries
  • 10. If we can make music streaming work, how about video streaming? — KKBOX CxO
  • 11. Let's work on a video-on-demand service • Adaptive streaming. • DRM protection. • Video processing on cloud.
  • 12. We thought video streaming is similar to music streaming, but we were wrong.
  • 13. Issue 1. Workflow multiple distinct interconnected steps that need to be executed in a particular order in a distributed environment... — someone flickr:siddhu2020 flickr:siddhu2020 http://bit.ly/1FAukT2
  • 15. def run(source, secret_key, cipher): # verify if the source is ok. if not verify(source): return False # convert audio with different bitrates _ = [convert(source, i) for i in range(4)] # update id3 tag for all converted audios _ = update_id3_tag(_) # encrypt all audios _ = encrypt(_, secret_key, cipher) # deploy to backend DB deploy(_) return True
  • 16. Issue 2. Distribute tasks to the cloud, and use the cloud efficiently!
  • 19. Sample client code to submit a workflow1 $workflow = new Gearman_Workflow('KKBOX_Convert_Audio' 'source' => $source, 'args' => $args); $workflow->attachCallback(function () { }); $client->run($workflow); 1 warning, it's PHP.
  • 20. Sample worker (server) code to do things1 class KKBOX_Convert_Audio extends Gearman_Worker { public function run($arg) { // check the source if (!verify()) return; // convert audio with different bitrates for ($i=0; $i<4; $i++) { convert($i); } // update id3 tag for all audios update_id3_tag(); // encrypt audios encrypt(); // sequentially deploy to backend DB for ($i=0; $i<4; $i++) { deploy($i); } } 1 warning, it's PHP.
  • 21. Sample encoding workflow for video, a little bit complicated
  • 22. Sample worker (server) code to do things1 class KKBOX_Encode_Video extends Gearman_Worker { public function run($arg) { transcode(); encrypt(); } } class KKBOX_Convert_Video extends Gearman_Worker { public function run($arg) { if (!verify()) return; // create asynchronous sub-workflows $result = create_sub_workflow(KKBOX_Encode_Video); // wait for all sub-workflows to finish joint($result); create_sub_workflow(KKBOX_Package_DASH, $result->encrypted); create_sub_workflow(KKBOX_Package_HLS, $result->plain); joint(); deploy(); } 1 warning, it's PHP.
  • 23. The real gearman worker code is way more complicated w/o elegance we like to have
  • 24. Issue 3. Workflows would evolve... • Let's save file size and IO. • Let's make it faster. • Let's add some more profiles. • Let's fix some encoding.
  • 25.
  • 26. Everything fails all the time. — Werner Vogels, CTO of Amazon flickr:Bill Abbott flickr:Bill Abbott http://bit.ly/1GnrSGr
  • 27. Issue 4. Gearman server down!
  • 28. Factors we like to pay much attention in • Encoding workflow • Tasks distributing across machines on cloud. • Server maintenance.
  • 29. We hope ... 1. no need to maintain this system; 2. easier to distribute workflow/tasks, even to local machine; 3. with high-level workflow.As long as you can draw your processes on a paper, you can map it to a workflow!
  • 30. What Google suggests us... • Apache Kafka, Mesos, ... • Gearman (sorry, but we've tried.) • Luigi by Spotify • Celery • Potentially all message brokers with some additional work.
  • 32. class HelloWorker(swf.ActivityWorker): domain = DOMAIN version = VERSION task_list = TASKLIST def run(self): activity_task = self.poll() if 'activityId' in activity_task: print 'Hello, World!' self.complete() return True
  • 33. class HelloDecider(swf.Decider): domain = DOMAIN task_list = TASKLIST version = VERSION def run(self): history = self.poll() if 'events' in history: # Find workflow events not related to decision scheduling. workflow_events = [e for e in history['events'] if not e['eventType'].startswith('Decision')] last_event = workflow_events[-1] decisions = swf.Layer1Decisions() if last_event['eventType'] == 'WorkflowExecutionStarted': decisions.schedule_activity_task(...) elif last_event['eventType'] == 'ActivityTaskCompleted': decisions.complete_workflow_execution() self.complete(decisions=decisions) return True
  • 34. SWF • Decider defines the workflow. • We still need to write workflow logic in decider. • Workers do the action. • Everytime, we changed workflow or action, we need to re- deploy deciders and workers.
  • 35. Let's de-couple the workflow and action out of SWF
  • 36.
  • 37. Job script for a workflow Job {KKBOX Convert Video} -subtasks { Task {Source Inspection} -cmds { Cmd { emilia verify -i s3://bucket/source.mp4 } } Task {Transcode} --parallel -subtasks { Iterate i -from 0 -to 4 -by 1 -template { Task {Transcode Audio} -cmds { Cmd { ffmpeg -i s3://bucket/source.mp4 -o /tmp/converted_$i.mp4 } } } Iterate i -from 0 -to 8 -by 1 -template { Task {Transcode Video} -cmds { Cmd { ffmpeg -i s3://bucket/source.mp4 -o /tmp/converted_$i.mp4 } } } } Task {Adaptive} -subtasks { Task {DASH} -subtasks { } Task {HLS} -subtasks { } Task {MSS} -subtasks { } } }
  • 38. What is exactly a job script?
  • 39.
  • 40.
  • 41. Make it pythonic if that makes developers happier source = 's3://bucket/source.mp4' with Job(): with Task('Source Inspection'): Cmd('emilia verify -i %s' % source) with Task('Transcode', parallel=True): for i in range(4): with Task(): Cmd('ffmpeg -i %s ... -o /tmp/a_%d.mp4' % (source, i)) for i in range(9): with Task(): Cmd('ffmpeg -i %s ... -o /tmp/v_%d.mp4' % (source, i)) with Task('Adaptive'): with Task('DASH'): pass with Task('HLS'): pass with Task('MSS'): pass
  • 42. Status • 1,500,000-minute videos got encoded. • 3,000 videos per day (max). • 800 workers on 100 c3.8xlarge instances (max). • spent lots of $. • everyone is really happy for that performance.
  • 43. Technical status • Fault tolerance by retry. [decider] • Workflow/task has priorities. [SWF] • try..except..finally mechanism. [-whendone, -whenerror, -precmds, -postcmds, ...]
  • 44. Question: Are you interested in this project?
  • 45. To do: • Use JSON or YAML for job script. • A viewer to see the progress of workflows! • Replace SWF by Apache Mesos or Mistral.
  • 47. We are hiring • Video Engineer • Full Stack Developer • Python Developer