SlideShare a Scribd company logo
Building a Real Time Analytics API
at Scale
DataXDay, May 17th 2018
Sylvain Friquet
@sylvainfriquet
Software Engineer
Algolia: Search as a Service
As-you-type Speed
Results in milliseconds
at every keystrokes.
Relevance
Finding the best content
for every intent.
User Experience
Delightfully engaging,
impressively intuitive.
@DataXDay
Algolia: Search as a Service
@DataXDay
Algolia by the numbers
16
Regions
55
Data centers
Offices
Regions
40B
Searches /mo
150B
API calls /mo
2012
Founded
200
Employees
4500
Customers
$74M
Funding
Algolia Search Analytics
@DataXDay@DataXDay
Where we started
> 4 years old project
> ElasticSearch
> Self Hosted
> 500M to 40B searches/month
> Upgrading ES Cluster too tedious
@DataXDay
What we wanted
> Sub second API response time
> Low latency
> Large retention
> Billions of events per day
> Scale with us
> Hosted solution
@DataXDay
The big picture
@DataXDay
Datastore we considered
> BigQuery
> RedShift
> Citus
Google BigQuery
@DataXDay
Citus
> Postgres Extension
> Distributed
> Multi Tenant
> Near real time analytics
> Scale Out
@DataXDay
Sub-second analytics query
> Ingesting raw events
> Rolling them up
> Sub-second API queries
@DataXDay
Rollup
> Aggregation
> Coarse grain analysis
> Pre determined queries
@DataXDay
Ingesting raw events
> Simple schema CREATE TABLE queries (
app_id text,
timestamp timestamp,
query text,
user_id text,
created_at timestamp default now()
);
@DataXDay
Ingesting raw events
> Simple schema
> Shard by tenant
CREATE TABLE queries (
app_id text,
timestamp timestamp,
query text,
user_id text,
created_at timestamp default now()
);
SELECT
create_distributed_table('queries',
'app_id');
@DataXDay
Ingesting raw events
> Simple schema
> Shard by tenant
> Batch insert (parallel COPY)
> Up to 7M rows/s
CREATE TABLE queries (
app_id text,
timestamp timestamp,
query text,
user_id text,
created_at timestamp default now()
);
SELECT
create_distributed_table('queries',
'app_id');
@DataXDay
Rollup table
CREATE TABLE rollups_5min (
timestamp timestamp,
app_id text,
query_count bigint,
user_count HLL,
top_queries JSONB
);
> Aggregate metrics per time window
@DataXDay
Rollup table
CREATE TABLE rollups_5min (
timestamp timestamp,
app_id text,
query_count bigint,
user_count HLL,
top_queries JSONB
);
> Aggregate metrics per time window
> TOPN and HLL extension
@DataXDay
Rollup table
CREATE TABLE rollups_5min (
timestamp timestamp,
app_id text,
query_count bigint,
user_count HLL,
top_queries JSONB
);
SELECT create_distributed_table('rollups_5min',
'app_id');
> Aggregate metrics per time window
> TOPN and HLL extension
> Collocated with raw event tables
@DataXDay
Rollup query
> Periodic rollup
INSERT INTO rollups_5min
SELECT
date_trunc('seconds', …) AS minute,
app_id,
count(*) AS query_count,
hll_add_agg(hll_hash_bigint(user_id)) AS user_count,
topn_add_agg(query) AS top_queries
FROM queries
WHERE created_at >= $1 AND created_at <= $2
GROUP BY app_id, minute
@DataXDay
Rollup query
INSERT INTO rollups_5min
SELECT
date_trunc('seconds', …) AS minute,
app_id,
count(*) AS query_count,
hll_add_agg(hll_hash_bigint(user_id)) AS user_count,
topn_add_agg(query) AS top_queries
FROM queries
WHERE created_at >= $1 AND created_at <= $2
GROUP BY app_id, minute
> Periodic rollup
> Concurrently executed across workers
@DataXDay
Rollup query
INSERT INTO rollups_5min
SELECT
date_trunc('seconds', …) AS minute,
app_id,
count(*) AS query_count,
hll_add_agg(hll_hash_bigint(user_id)) AS user_count,
topn_add_agg(query) AS top_queries
FROM queries
WHERE created_at >= $1 AND created_at <= $2
GROUP BY app_id, minute
> Periodic rollup
> Concurrently executed across workers
> Out of order events
@DataXDay
Rollup query
INSERT INTO rollups_5min
SELECT
date_trunc('seconds', …) AS minute,
app_id,
count(*) AS query_count,
hll_add_agg(hll_hash_bigint(user_id)) AS user_count,
topn_add_agg(query) AS top_queries
FROM queries
WHERE created_at >= $1 AND created_at <= $2
GROUP BY app_id, minute
ON CONFLICT (app_id, minute)
DO UPDATE SET
query_count = query + EXCLUDED.query_count,
user_count = user_count + EXCLUDED.user_count,
top_queries = top_queries + EXCLUDED.top_queries;
> Periodic rollup
> Concurrently executed across workers
> Out of order events
> Incremental or idempotent
@DataXDay
Rolling up the rollups
> Further aggregate 5min rollups into 1day rollups
> 200x to 50,000x compression ratio in our case
@DataXDay
API queries
Sample queries
> Count
SELECT sum(query_count) FROM … rollups_1day UNION ALL rollups_5min … WHERE …
> Distinct Approx Count
SELECT hll_cardinality(sum(user_count))::bigint FROM ...
> TopN
SELECT (topn(topn_union_agg(top_queries), 10)).* FROM ...
@DataXDay
Some numbers
> every 5min: ~20s to rollup 20M rows
> 64 shards, 48 vCPUs, 366G RAM
> API latency p99 < 800ms, p95 < 500ms
@DataXDay
Conclusion
> Rollup approach working at scale
> Citus becoming the foundation for several new
products (Click Analytics...)
@DataXDay
Thank you
The video of this presentation
will be soon available at dataxday.fr
Thanks to our sponsors
Stay tuned by following @DataXDay

More Related Content

Similar to DataXDay - Building a Real Time Analytics API at Scale

Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
Utilizing Microsoft Graph API and Office 365 Management Activity API during s...Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
Kirill Bogdanov
 
Building Streaming Applications with Streaming SQL
Building Streaming Applications with Streaming SQLBuilding Streaming Applications with Streaming SQL
Building Streaming Applications with Streaming SQL
Mohanadarshan Vivekanandalingam
 
Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
zrok
 
Bootstrapping an App for Launch
Bootstrapping an App for LaunchBootstrapping an App for Launch
Bootstrapping an App for Launch
Craig Phares
 
Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
Ruhani Arora
 
Google for モバイル アプリ 16:00: モバイル kpi 分析の新標準 fluentd + google big query
Google for モバイル アプリ   16:00: モバイル kpi 分析の新標準 fluentd + google big queryGoogle for モバイル アプリ   16:00: モバイル kpi 分析の新標準 fluentd + google big query
Google for モバイル アプリ 16:00: モバイル kpi 分析の新標準 fluentd + google big query
Google Cloud Platform - Japan
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
Johann de Boer
 
Supporting Enterprise System Rollouts with Splunk
Supporting Enterprise System Rollouts with SplunkSupporting Enterprise System Rollouts with Splunk
Supporting Enterprise System Rollouts with Splunk
Erin Sweeney
 
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
Krist Wongsuphasawat
 
Building the BI system and analytics capabilities at the company based on Rea...
Building the BI system and analytics capabilities at the company based on Rea...Building the BI system and analytics capabilities at the company based on Rea...
Building the BI system and analytics capabilities at the company based on Rea...
GameCamp
 
[WSO2Con USA 2018] Patterns for Building Streaming Apps
[WSO2Con USA 2018] Patterns for Building Streaming Apps[WSO2Con USA 2018] Patterns for Building Streaming Apps
[WSO2Con USA 2018] Patterns for Building Streaming Apps
WSO2
 
GIDS13 - Building Service for Any Clients
GIDS13 - Building Service for Any ClientsGIDS13 - Building Service for Any Clients
GIDS13 - Building Service for Any Clients
Lohith Goudagere Nagaraj
 
[@IndeedEng] Large scale interactive analytics with Imhotep
[@IndeedEng] Large scale interactive analytics with Imhotep[@IndeedEng] Large scale interactive analytics with Imhotep
[@IndeedEng] Large scale interactive analytics with Imhotep
indeedeng
 
Patterns for Building Streaming Apps
Patterns for Building Streaming AppsPatterns for Building Streaming Apps
Patterns for Building Streaming Apps
Mohanadarshan Vivekanandalingam
 
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
Amazon Web Services
 
AWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
AWS July Webinar Series: Amazon Redshift Reporting and Advanced AnalyticsAWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
AWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
Amazon Web Services
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at Twitter
Krist Wongsuphasawat
 
Evolution of a big data project
Evolution of a big data projectEvolution of a big data project
Evolution of a big data projectMichael Peacock
 
GA Konferenz-2011 Nick Mihailovski_API
GA Konferenz-2011 Nick Mihailovski_APIGA Konferenz-2011 Nick Mihailovski_API
GA Konferenz-2011 Nick Mihailovski_API
e-dialog GmbH
 
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York CityThe Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
Neo4j
 

Similar to DataXDay - Building a Real Time Analytics API at Scale (20)

Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
Utilizing Microsoft Graph API and Office 365 Management Activity API during s...Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
Utilizing Microsoft Graph API and Office 365 Management Activity API during s...
 
Building Streaming Applications with Streaming SQL
Building Streaming Applications with Streaming SQLBuilding Streaming Applications with Streaming SQL
Building Streaming Applications with Streaming SQL
 
Get up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or lessGet up and running with google app engine in 60 minutes or less
Get up and running with google app engine in 60 minutes or less
 
Bootstrapping an App for Launch
Bootstrapping an App for LaunchBootstrapping an App for Launch
Bootstrapping an App for Launch
 
Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
 
Google for モバイル アプリ 16:00: モバイル kpi 分析の新標準 fluentd + google big query
Google for モバイル アプリ   16:00: モバイル kpi 分析の新標準 fluentd + google big queryGoogle for モバイル アプリ   16:00: モバイル kpi 分析の新標準 fluentd + google big query
Google for モバイル アプリ 16:00: モバイル kpi 分析の新標準 fluentd + google big query
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
 
Supporting Enterprise System Rollouts with Splunk
Supporting Enterprise System Rollouts with SplunkSupporting Enterprise System Rollouts with Splunk
Supporting Enterprise System Rollouts with Splunk
 
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
Using Visualizations to Monitor Changes and Harvest Insights from a Global-sc...
 
Building the BI system and analytics capabilities at the company based on Rea...
Building the BI system and analytics capabilities at the company based on Rea...Building the BI system and analytics capabilities at the company based on Rea...
Building the BI system and analytics capabilities at the company based on Rea...
 
[WSO2Con USA 2018] Patterns for Building Streaming Apps
[WSO2Con USA 2018] Patterns for Building Streaming Apps[WSO2Con USA 2018] Patterns for Building Streaming Apps
[WSO2Con USA 2018] Patterns for Building Streaming Apps
 
GIDS13 - Building Service for Any Clients
GIDS13 - Building Service for Any ClientsGIDS13 - Building Service for Any Clients
GIDS13 - Building Service for Any Clients
 
[@IndeedEng] Large scale interactive analytics with Imhotep
[@IndeedEng] Large scale interactive analytics with Imhotep[@IndeedEng] Large scale interactive analytics with Imhotep
[@IndeedEng] Large scale interactive analytics with Imhotep
 
Patterns for Building Streaming Apps
Patterns for Building Streaming AppsPatterns for Building Streaming Apps
Patterns for Building Streaming Apps
 
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
(DAT308) Yahoo! Analyzes Billions of Events a Day on Amazon Redshift
 
AWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
AWS July Webinar Series: Amazon Redshift Reporting and Advanced AnalyticsAWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
AWS July Webinar Series: Amazon Redshift Reporting and Advanced Analytics
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at Twitter
 
Evolution of a big data project
Evolution of a big data projectEvolution of a big data project
Evolution of a big data project
 
GA Konferenz-2011 Nick Mihailovski_API
GA Konferenz-2011 Nick Mihailovski_APIGA Konferenz-2011 Nick Mihailovski_API
GA Konferenz-2011 Nick Mihailovski_API
 
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York CityThe Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
The Connected Data Imperative: Why Graphs? at Neo4j GraphDay New York City
 

More from DataXDay Conference by Xebia

DataXDay - Exploring graphs: looking for communities & leaders
DataXDay - Exploring graphs: looking for communities & leadersDataXDay - Exploring graphs: looking for communities & leaders
DataXDay - Exploring graphs: looking for communities & leaders
DataXDay Conference by Xebia
 
DataXDay - The wonders of deep learning: how to leverage it for natural langu...
DataXDay - The wonders of deep learning: how to leverage it for natural langu...DataXDay - The wonders of deep learning: how to leverage it for natural langu...
DataXDay - The wonders of deep learning: how to leverage it for natural langu...
DataXDay Conference by Xebia
 
DataXDay - A data scientist journey to industrialization of machine learning
DataXDay - A data scientist journey to industrialization of machine learning DataXDay - A data scientist journey to industrialization of machine learning
DataXDay - A data scientist journey to industrialization of machine learning
DataXDay Conference by Xebia
 
DataXDay - Real-Time Access log analysis
DataXDay - Real-Time Access log analysis DataXDay - Real-Time Access log analysis
DataXDay - Real-Time Access log analysis
DataXDay Conference by Xebia
 
DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML
DataXDay Conference by Xebia
 
DataXDay - Machine learning models at scale with Amazon SageMaker
DataXDay - Machine learning models at scale with Amazon SageMaker DataXDay - Machine learning models at scale with Amazon SageMaker
DataXDay - Machine learning models at scale with Amazon SageMaker
DataXDay Conference by Xebia
 

More from DataXDay Conference by Xebia (6)

DataXDay - Exploring graphs: looking for communities & leaders
DataXDay - Exploring graphs: looking for communities & leadersDataXDay - Exploring graphs: looking for communities & leaders
DataXDay - Exploring graphs: looking for communities & leaders
 
DataXDay - The wonders of deep learning: how to leverage it for natural langu...
DataXDay - The wonders of deep learning: how to leverage it for natural langu...DataXDay - The wonders of deep learning: how to leverage it for natural langu...
DataXDay - The wonders of deep learning: how to leverage it for natural langu...
 
DataXDay - A data scientist journey to industrialization of machine learning
DataXDay - A data scientist journey to industrialization of machine learning DataXDay - A data scientist journey to industrialization of machine learning
DataXDay - A data scientist journey to industrialization of machine learning
 
DataXDay - Real-Time Access log analysis
DataXDay - Real-Time Access log analysis DataXDay - Real-Time Access log analysis
DataXDay - Real-Time Access log analysis
 
DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML DataXDay - Tensors in the sky with CloudML
DataXDay - Tensors in the sky with CloudML
 
DataXDay - Machine learning models at scale with Amazon SageMaker
DataXDay - Machine learning models at scale with Amazon SageMaker DataXDay - Machine learning models at scale with Amazon SageMaker
DataXDay - Machine learning models at scale with Amazon SageMaker
 

Recently uploaded

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 

Recently uploaded (20)

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 

DataXDay - Building a Real Time Analytics API at Scale

  • 1. Building a Real Time Analytics API at Scale DataXDay, May 17th 2018 Sylvain Friquet @sylvainfriquet Software Engineer
  • 2. Algolia: Search as a Service As-you-type Speed Results in milliseconds at every keystrokes. Relevance Finding the best content for every intent. User Experience Delightfully engaging, impressively intuitive. @DataXDay
  • 3. Algolia: Search as a Service @DataXDay
  • 4. Algolia by the numbers 16 Regions 55 Data centers Offices Regions 40B Searches /mo 150B API calls /mo 2012 Founded 200 Employees 4500 Customers $74M Funding
  • 6. Where we started > 4 years old project > ElasticSearch > Self Hosted > 500M to 40B searches/month > Upgrading ES Cluster too tedious @DataXDay
  • 7. What we wanted > Sub second API response time > Low latency > Large retention > Billions of events per day > Scale with us > Hosted solution @DataXDay
  • 9. Datastore we considered > BigQuery > RedShift > Citus Google BigQuery @DataXDay
  • 10. Citus > Postgres Extension > Distributed > Multi Tenant > Near real time analytics > Scale Out @DataXDay
  • 11. Sub-second analytics query > Ingesting raw events > Rolling them up > Sub-second API queries @DataXDay
  • 12. Rollup > Aggregation > Coarse grain analysis > Pre determined queries @DataXDay
  • 13. Ingesting raw events > Simple schema CREATE TABLE queries ( app_id text, timestamp timestamp, query text, user_id text, created_at timestamp default now() ); @DataXDay
  • 14. Ingesting raw events > Simple schema > Shard by tenant CREATE TABLE queries ( app_id text, timestamp timestamp, query text, user_id text, created_at timestamp default now() ); SELECT create_distributed_table('queries', 'app_id'); @DataXDay
  • 15. Ingesting raw events > Simple schema > Shard by tenant > Batch insert (parallel COPY) > Up to 7M rows/s CREATE TABLE queries ( app_id text, timestamp timestamp, query text, user_id text, created_at timestamp default now() ); SELECT create_distributed_table('queries', 'app_id'); @DataXDay
  • 16. Rollup table CREATE TABLE rollups_5min ( timestamp timestamp, app_id text, query_count bigint, user_count HLL, top_queries JSONB ); > Aggregate metrics per time window @DataXDay
  • 17. Rollup table CREATE TABLE rollups_5min ( timestamp timestamp, app_id text, query_count bigint, user_count HLL, top_queries JSONB ); > Aggregate metrics per time window > TOPN and HLL extension @DataXDay
  • 18. Rollup table CREATE TABLE rollups_5min ( timestamp timestamp, app_id text, query_count bigint, user_count HLL, top_queries JSONB ); SELECT create_distributed_table('rollups_5min', 'app_id'); > Aggregate metrics per time window > TOPN and HLL extension > Collocated with raw event tables @DataXDay
  • 19. Rollup query > Periodic rollup INSERT INTO rollups_5min SELECT date_trunc('seconds', …) AS minute, app_id, count(*) AS query_count, hll_add_agg(hll_hash_bigint(user_id)) AS user_count, topn_add_agg(query) AS top_queries FROM queries WHERE created_at >= $1 AND created_at <= $2 GROUP BY app_id, minute @DataXDay
  • 20. Rollup query INSERT INTO rollups_5min SELECT date_trunc('seconds', …) AS minute, app_id, count(*) AS query_count, hll_add_agg(hll_hash_bigint(user_id)) AS user_count, topn_add_agg(query) AS top_queries FROM queries WHERE created_at >= $1 AND created_at <= $2 GROUP BY app_id, minute > Periodic rollup > Concurrently executed across workers @DataXDay
  • 21. Rollup query INSERT INTO rollups_5min SELECT date_trunc('seconds', …) AS minute, app_id, count(*) AS query_count, hll_add_agg(hll_hash_bigint(user_id)) AS user_count, topn_add_agg(query) AS top_queries FROM queries WHERE created_at >= $1 AND created_at <= $2 GROUP BY app_id, minute > Periodic rollup > Concurrently executed across workers > Out of order events @DataXDay
  • 22. Rollup query INSERT INTO rollups_5min SELECT date_trunc('seconds', …) AS minute, app_id, count(*) AS query_count, hll_add_agg(hll_hash_bigint(user_id)) AS user_count, topn_add_agg(query) AS top_queries FROM queries WHERE created_at >= $1 AND created_at <= $2 GROUP BY app_id, minute ON CONFLICT (app_id, minute) DO UPDATE SET query_count = query + EXCLUDED.query_count, user_count = user_count + EXCLUDED.user_count, top_queries = top_queries + EXCLUDED.top_queries; > Periodic rollup > Concurrently executed across workers > Out of order events > Incremental or idempotent @DataXDay
  • 23. Rolling up the rollups > Further aggregate 5min rollups into 1day rollups > 200x to 50,000x compression ratio in our case @DataXDay
  • 24. API queries Sample queries > Count SELECT sum(query_count) FROM … rollups_1day UNION ALL rollups_5min … WHERE … > Distinct Approx Count SELECT hll_cardinality(sum(user_count))::bigint FROM ... > TopN SELECT (topn(topn_union_agg(top_queries), 10)).* FROM ... @DataXDay
  • 25. Some numbers > every 5min: ~20s to rollup 20M rows > 64 shards, 48 vCPUs, 366G RAM > API latency p99 < 800ms, p95 < 500ms @DataXDay
  • 26. Conclusion > Rollup approach working at scale > Citus becoming the foundation for several new products (Click Analytics...) @DataXDay
  • 28. The video of this presentation will be soon available at dataxday.fr Thanks to our sponsors Stay tuned by following @DataXDay