SlideShare una empresa de Scribd logo
1 de 62
Descargar para leer sin conexión
can you download
the whole Instagram?
A bold tale of struggle and friendship
Agenda
➔ start a demo
➔ understand the challenge
➔ integrate people
➔ HOW WE DID IT
➔ see demo results
CEO COO Prod. owner Developer CTO
BusinessAwareness
THE COMPANY GAP
Technical Awareness
making
instagram profiles
SEARCHABLE
THE NEW GUY
CEO COO Prod. owner Developer CTO
BusinessAwareness
THE COMPANY GAP
Technical Awareness
Getting into engineering
LevelofBlackMagic
Technical skills
Level zero in dev.
Study & Google
copy/paste

npm install
NEED TO REDUCE POINTS
Getting into engineering
Technical skills
New guy level
LevelofBlackMagic
Gained more knowledge
Introduced to “THE BACKEND”
First full-stack feature
A NEW HOPE
• Look at competitors data
• Find public API

(json bases)
What is a queue?
REQUIREMENTS ● PARALLEL JOBS
● FAULTS TOLERANCE
● UNIQUE DOCUMENTS
● RESCHEDULE DOCUMENTS
● AVOID RE-INSERT
● COST EFFICIENT
● JAVASCRIPT
CREATE TABLE tasks (
subject CHARACTER … PRIMARY KEY,
next_iteration TIMESTAMP,
attempts INTEGER,
payload JSONB
);
DISCOVERY
PROFILE

TRACKER
PROFILE

BUILDER
LEARN
Dataprocessing
Knowledge
300k
100M+
1 WORKERS ~ 10 profiles / minute
CHALLENGE
2 WORKERS ~ 13 profiles / minute
3 WORKERS ~ 14 profiles / minute
SELECT subject FROM tasks
WHERE next_iteration <= NOW()
LIMIT 1;
UPDATE tasks
SET next_iteration = NOW() + interval ‘5m’
WHERE subject = ‘xxx’;
SELECT subject FROM tasks
WHERE next_iteration <= NOW()
LIMIT 1;
UPDATE tasks
SET next_iteration = NOW() + interval ‘5m’
WHERE subject = ‘xxx’;
WORKERS GAP
UPDATE tasks SET
next_iteration = NOW() + interval ‘5m’
WHERE subject in (
SELECT subject FROM tasks
WHERE next_iteration <= NOW()
LIMIT 1
FOR UPDATE SKIP LOCKED
)
RETURNING subject;
Dataprocessing
Knowledge
300k
1M
100% CPU CREDITS LIMIT
CHALLENGE
100% DISK I/O LIMIT
~200 $/month “m4.large” machine
INSERT INTO tasks
(subject, next_iteration)
VALUES
(`xxx`, NOW() ),
(`yyy`, NOW() + INTERVAL ‘5m’ ),
(`zzz`, NOW() - INTERVAL ‘1y’ );
for (const task in stuff_to_insert) {
const exists = await query(`
SELECT subject FROM tasks
WHERE subject = '`${task}`' LIMIT 1
`);
if (!exists) {
await query("INSERT INTO ...")
}
}
INSERT INTO tasks
(subject, next_iteration)
VALUES
(`xxx`, NOW() ),
(`yyy`, NOW() + INTERVAL ‘5m’ ),
(`zzz`, NOW() - INTERVAL ‘1y’ )
ON CONFLICT
DO NOTHING;
Dataprocessing
Knowledge
300k
1M
5M
40s+ to pick a document!
CHALLENGE
SELECT FROM tasks
WHERE next_iteration < NOW()
AND attempts < 5
ORDER BY
next_iteration ASC,
attempts ASC
LIMIT 1;
CREATE TABLE tasks (
subject CHARACTER … PRIMARY KEY,
next_iteration TIMESTAMP,
status INTEGER,
attempts INTEGER,
payload JSONB
);
SELECT FROM tasks
WHERE status = 1
AND attempts < 5
ORDER BY
next_iteration ASC,
attempts ASC
LIMIT 1;
CREATE INDEX pending ON tasks(
next_iteration ASC,
attempts ASC
)
WHERE (
status = 1
AND
attempts < 5
);
Need to update STATUS
CHALLENGE
UPDATE tasks SET status = 1
WHERE subject IN (
SELECT subject FROM tasks
WHERE status = 0
AND next_iteration < NOW()
FOR UPDATE SKIP LOCKED
);
Dataprocessing
Knowledge
300k
1M
20M
5M
SCALE
Scaling in AWS
➔ EC2 Clicking
➔ Auto Scaling Groups
➔ CloudFormation
Speed differences among queues
Errors (thousands of them!)
CHALLENGE
WITH BIG DATA
COMES BIG TROUBLES
true story
MEET GRAFANA
What to measure?
# How much cumulated work?
SELECT COUNT (*) FROM tasks
WHERE status = 1;
# How much planned word?
SELECT COUNT (*) FROM tasks
WHERE status = 0;
# Other metrics…
CREATE TABLE metrics (
metric CHARACTER … NOT NULL,
value INTEGER
);
CREATE TABLE metrics_logs (
ctime TIMESTAMP,
metric CHARACTER … NOT NULL,
increment INTEGER
);
INSERT INTO metrics_logs (
ctime, metric, increment
) VALUES (
NOW(), `pending`, 1
);
FUNCTIONS
FOR VAR_r IN
SELECT
DISTINCT ON (metric),
metric, increment
FROM metrics_logs
ORDER BY ctime ASC
LOOP
…
END LOOP;
SELECT SUM(increment) INTO VAR_sum
FROM metrics_logs
WHERE metric = VAR_r.metric;
UPDATE metrics AS t
SET value = t.value + VAR_sum
WHERE metric = VAR_r.metric;
Dataprocessing
Knowledge
300k
1M
20M
100M+
5M
TAKEAWAY
➔ With good communication comes
good results
➔ Keep it simple
➔ No limits for new knowledge
➔ Mindset, curiosity, improvements
CEO COO Prod. owner Developer CTO
BusinessAwareness
THE COMPANY GAP
Technical Awareness

Más contenido relacionado

Similar a FetchQ - the origins

In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testing
Anna Khabibullina
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
Anton Arhipov
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
Raimonds Simanovskis
 
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdfOn SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
infomalad
 

Similar a FetchQ - the origins (20)

jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
In search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testingIn search of JavaScript code quality: unit testing
In search of JavaScript code quality: unit testing
 
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
 
Tddbdd workshop
Tddbdd workshopTddbdd workshop
Tddbdd workshop
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
 
Apache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customization
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript
 
How to Vim - for beginners
How to Vim - for beginnersHow to Vim - for beginners
How to Vim - for beginners
 
Good Practices On Test Automation
Good Practices On Test AutomationGood Practices On Test Automation
Good Practices On Test Automation
 
Intro to GraphQL on Android with Apollo DroidconNYC 2017
Intro to GraphQL on Android with Apollo DroidconNYC 2017Intro to GraphQL on Android with Apollo DroidconNYC 2017
Intro to GraphQL on Android with Apollo DroidconNYC 2017
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
 
On SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdfOn SQL Managment studioThis lab is all about database normalizatio.pdf
On SQL Managment studioThis lab is all about database normalizatio.pdf
 
Shibuya.js Lightning Talks
Shibuya.js Lightning TalksShibuya.js Lightning Talks
Shibuya.js Lightning Talks
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Know
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

FetchQ - the origins