SlideShare a Scribd company logo
Go && Python
Event driven ML
Lalafo case
Taras Matsyk - Event Driven ML
How it all started
Part 1. The Phantom Menace
Taras Matsyk - Event Driven ML
StackOverflow: Ready to rescue
200 RPM
Taras Matsyk - Event Driven ML
$
Feedback
$
Feedback
Processes Monitoring
RAM - expiration?
Relational DB?
Any issues there?
1. Request monitoring (?)
2. Hard to reason GPU usage (varies 3 to 7GB)
3. ~5Gb RAM out of the box (scale?)
4. Redis is in-memory storage (temporary)
5. Threading != Parallel
http://www.nooooooooooooooo.com/
What if we split
API and ML
Part 2. A new hope
Requirements
Lalafo case
1. Single image/request processing time: < 2 seconds
2. Visibility
3. Persistence
4. Scalability
5. Make it extendable for new features
a. Price prediction
b. Similarity search
c. Segmentation
6. SDK friendly (well documented, tested etc)
$
Feedback
Processes Monitoring
RAM - expiration?
Relational DB?
After 2 months
API Listeners
Feedback
$
Requirements
Lalafo case
1. Single image/request processing time: < 2 seconds
2. Visibility - Decouple request and prediction
3. Persistence
4. Scalability
5. Make it extendable for new features
a. Price prediction
b. Similarity search
c. Segmentation
6. SDK friendly (well documented, tested etc)
2 seconds per request
Part 3. The Empire Strikes Back
4 seconds per request
API Listeners
1 second
0.01 sec
segmentio/kafka-go -> shopify/sarama
API Listeners
0.02 sec
0.01 sec
3 seconds per request
API Listeners
0.02 sec
0.3 second
0.3 second
Synchronous request
How large is every image
2.4 seconds per request
API Listeners
0.02 sec
Synchronous request
2.4 seconds per request
API Listeners
0.02 sec
Synchronous request
2 seconds per request
API Listeners
0.02 sec
Synchronous request
Add ThreadPool
2 seconds per request
Success?
Not yet
3 seconds per request
API Listeners
0.02 sec
3 seconds per request
API Listeners
0.02 sec
1 second and growing
3 seconds per request
2 seconds per request
¯_(ツ)_/¯
2 seconds per request
API Listeners
0.02 sec
200 RPM -> 1200 RPM
2 seconds per request
API Listeners
0.02 sec
Scale
Scale
Master -> Slave -> balancer
Topics -> Partitions
< 1 second per request
Success?
Not yet
Taras Matsyk - Event Driven ML
Out of 8Gb
How to PyTorch in production
7.6 Gb -> 600 Mb
1 second per request
Success?
Not yet
Back to 2, 5, 10 seconds per request
Troubleshooting
API Listeners
0.02 sec
? ?
Troubleshooting
API Listeners
0.02 sec
?
Troubleshooting
API Listeners
0.02 sec
?
175k records per request
Troubleshooting
API Listeners
0.02 sec
?
Troubleshooting
API
SELECT * FROM ads LIMIT 1
25 seconds -> 0.02 seconds
0.02 seconds -> 0.002 second
Success?
Not yet
Faust 1.4.6: No latest offset
https://github.com/robinhood/faust
3K images per minute 0_o
Success?
Not yet
Issues to solve
1. Occasional spikes in performance (GC, network latency)
2. Message broker (Kafka rebalancing, offset etc)
3. How to handle DB migrations
4. Something we are not aware of yet
Lessons learnt
1. CPU bound tasks != IO bound (¯_(ツ)_/¯)
2. High coupling - low cohesion
3. You need to know how to cook MongoDB
4. Go is not that obvious and library reach as Python
5. Simple != Easier
6. Concurrency != Parallelism (obviously)
< 1 second per request
+ Live statistics from PostgreSQL
API Listeners
Thank you everyone
Success?

More Related Content

KEY
Ruby 1.9 And Rails 3.0
PDF
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
PDF
Medindo performance do seu código Ruby, com Rafael França
PDF
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
KEY
Event machine
PPTX
2600Hz - The Next Wave - KazooCon 2015
KEY
Keg.io
PDF
Ignacy Kowalczyk
Ruby 1.9 And Rails 3.0
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
Medindo performance do seu código Ruby, com Rafael França
Blending django, Sockjs, Twisted, Celery, FTP and some magic sauce into a bla...
Event machine
2600Hz - The Next Wave - KazooCon 2015
Keg.io
Ignacy Kowalczyk

What's hot (20)

PDF
OpenRestyを用いてイケイケなサービスを作る方法
PPTX
How go makes us faster (May 2015)
PPTX
fsharp goodness for everyday work
PDF
Vinted life embetterment
PDF
The Puppet Master on the JVM - PuppetConf 2014
PDF
Pharo VM Performance
PDF
MySQL Tuning using digested slow-logs
PPT
How Typepad changed their architecture without taking down the service
PPT
Os Webb
PPTX
One Container, Two Container, Three Containers, Four
PDF
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
PPTX
KazooCon 2014 - Kazoo Scalability
KEY
Spork || How To Streamline Your TDD Process
PPTX
IronRuby on Teched Japan
PDF
Erlang Lightning Talk
PDF
Paris Monitoring meetup #1 - Zabbix at BlaBlaCar
PDF
Monitoring a billion kilometers of monthly ride sharing at BlaBlaCar - Zabbix...
PDF
Scaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy Carol
PPTX
Lab: JVM Production Debugging 101
PDF
Lightweight development (Lightning talk)
OpenRestyを用いてイケイケなサービスを作る方法
How go makes us faster (May 2015)
fsharp goodness for everyday work
Vinted life embetterment
The Puppet Master on the JVM - PuppetConf 2014
Pharo VM Performance
MySQL Tuning using digested slow-logs
How Typepad changed their architecture without taking down the service
Os Webb
One Container, Two Container, Three Containers, Four
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
KazooCon 2014 - Kazoo Scalability
Spork || How To Streamline Your TDD Process
IronRuby on Teched Japan
Erlang Lightning Talk
Paris Monitoring meetup #1 - Zabbix at BlaBlaCar
Monitoring a billion kilometers of monthly ride sharing at BlaBlaCar - Zabbix...
Scaling HBase (nosql store) to handle massive loads at Pinterest by Jeremy Carol
Lab: JVM Production Debugging 101
Lightweight development (Lightning talk)
Ad

Similar to Taras Matsyk - Event Driven ML (20)

PDF
WebPerformance: Why and How? – Stefan Wintermeyer
PDF
Introduction to Apache Kafka
PDF
Sloppy Little Serverless Stories
PDF
Lessons Learnt in 2009
PDF
3 Flink Mistakes We Made So You Won't Have To
PPT
Startups to Scale
PPTX
SQL Server On SANs
PDF
Capistrano && SystemD
PDF
Capistrano and SystemD
PPT
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
PDF
Fisl - Deployment
PPT
Life on the Edge with ESI
PDF
AF Ceph: Ceph Performance Analysis and Improvement on Flash
KEY
A rough guide to JavaScript Performance
PPTX
Day 2 General Session Presentations RedisConf
ODP
Performance Optimization of Rails Applications
PDF
"To cover uncoverable", Andrii Shumada
PDF
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
PDF
Scaling Twitter
PDF
20140425 ruby conftaiwan2014
WebPerformance: Why and How? – Stefan Wintermeyer
Introduction to Apache Kafka
Sloppy Little Serverless Stories
Lessons Learnt in 2009
3 Flink Mistakes We Made So You Won't Have To
Startups to Scale
SQL Server On SANs
Capistrano && SystemD
Capistrano and SystemD
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Fisl - Deployment
Life on the Edge with ESI
AF Ceph: Ceph Performance Analysis and Improvement on Flash
A rough guide to JavaScript Performance
Day 2 General Session Presentations RedisConf
Performance Optimization of Rails Applications
"To cover uncoverable", Andrii Shumada
Optimizing Tiered Storage for Low-Latency Real-Time Analytics at AI Scale
Scaling Twitter
20140425 ruby conftaiwan2014
Ad

More from PyCon Odessa (7)

PDF
Anton Caceres - The epic zoo of microservices
PDF
Christian Barra - Not just a Developer
PPTX
Gabriel Bianconi - Introduction to Face Processing with Computer Vision
PDF
Alexey Borisenko - Network Programmability using Python
PDF
Jorge Torres - Machine Learning Democratization with Python
PDF
Vsevolod Solovyov - Data science from the trenches
PPTX
Mikhail Faraponov - Overview of Kubernetes Metacontrollers with Python
Anton Caceres - The epic zoo of microservices
Christian Barra - Not just a Developer
Gabriel Bianconi - Introduction to Face Processing with Computer Vision
Alexey Borisenko - Network Programmability using Python
Jorge Torres - Machine Learning Democratization with Python
Vsevolod Solovyov - Data science from the trenches
Mikhail Faraponov - Overview of Kubernetes Metacontrollers with Python

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
“AI and Expert System Decision Support & Business Intelligence Systems”
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
Programs and apps: productivity, graphics, security and other tools
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25 Week I
sap open course for s4hana steps from ECC to s4
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The AUB Centre for AI in Media Proposal.docx
Mobile App Security Testing_ A Comprehensive Guide.pdf

Taras Matsyk - Event Driven ML