SlideShare a Scribd company logo
1 of 39
Download to read offline
A Jobs Queue for processing tasks
asynchronously
Guewen Baconnier & Leonardo Pistone
Camptocamp
1 / 32
Guewen Baconnier
Developer @ Camptocamp
OCA committer, OCA Delegate
Connector author
@guewenb
@guewen
Leonardo Pistone
Developer @ Camptocamp
OCA committer, OCA Delegate
@lepistone
About us
2 / 32
Computers are slow!
3 / 32
Computers are slow!
Humans want them to be fast!
3 / 32
The problem
4 / 32
User Odoo Server
Waiting
Heavytask!
5 / 32
Loading...
6 / 32
Still loading...
7 / 32
Still loading... Please be patient.
8 / 32
Don't leave yet, it's still loading
9 / 32
You may not believe it, but the application is
actually loading...
10 / 32
Take a minute to get a coffee, because it's
loading...
11 / 32
Come on...
12 / 32
We can try to save a few seconds
13 / 32
We can try to save a few seconds
But we have more radical solutions
13 / 32
User Odoo Server
Heavytask!
Connector
Runner
14 / 32
Connector
odoo-connector.com
15 / 32
Queue it!
Dependency on connector
16 / 32
Queue it!
Dependency on connector
Declare a job:
fromopenerp.addons.connector.queue.jobimportjob
@job
defa_heavy_task(session,model_name,record_id):
#doanheavytaskonrecord_idofmodel_name
16 / 32
Queue it!
Dependency on connector
Declare a job:
fromopenerp.addons.connector.queue.jobimportjob
@job
defa_heavy_task(session,model_name,record_id):
#doanheavytaskonrecord_idofmodel_name
Delay a job:
session=ConnectorSession.from_env(self.env)
a_heavy_task.delay(session,'res.partner',1)
16 / 32
Dequeue it!
Start the server with:
ODOO_CONNECTOR_CHANNELS=root:2./openerp-server--load=web,connector--workers=4
17 / 32
Dequeue it!
Start the server with:
ODOO_CONNECTOR_CHANNELS=root:2./openerp-server--load=web,connector--workers=4
ODOO_CONNECTOR_CHANNELS=root:3,root.csv:1,root.magento:3
./openerp-server--load=web,connector--workers=4
17 / 32
Channels
18 / 32
HTTPWorkers
csv
magento
root
Running jobs
Capacity
Channels
19 / 32
Properties
20 / 32
Priority
10 50 999
Priority
import_order.delay(session,1) #defaultis10
import_order.delay(session,2,priority=50)
import_order.delay(session,10,priority=999)
21 / 32
B C
Now + 6:00 + 12:00 +18:00 + 24:00
A
ETA
import_order.delay(session,1) #A
import_order.delay(session,1,eta=6*60*60) #B
import_order.delay(session,2,eta=datetime.now()+timedelta(days=1)) #C
22 / 32
Retries
import_order.delay(session,1,max_retries=3)
23 / 32
Retries
import_order.delay(session,1,max_retries=3)
Invoke a retry
@job
defimport_order(session,args):
try:
do_operation()
except(socket.gaierror,socket.error,socket.timeout)aserr:
raiseRetryableError(
'Anetworkerrorcausedthefailureofthejob:'
'%s'%err)
23 / 32
Best Practices
24 / 32
Outdating Data in jobs can become outdated.
No:
@job
defexample(session,record_id,vals):
export(record_id,vals)
Yes:
@job
defexample(session,record_id):
export(session.env['model'].browse(record_id))
25 / 32
Outdating
Existence
A job can refer to a record which has been deleted. Always
check if it still exists.
No:
@job
defexample(session,record_id):
export(session.env['model'].browse(record_id))
Yes:
@job
defexample(session,record_id):
record=session.env['model'].browse(record_id)
ifrecord.exists():
export(record)
26 / 32
Outdating
Existence
Idempotence
A job should, when possible, produce the same result
when executed several times.
No:
@job
defexample(session,record_id):
export(session.env['model'].browse(record_id))
Yes:
@job
defexample(session,record_id):
record=session.env['model'].browse(record_id)
ifrecord.exists():
ifnotrecord.exported:
export(session.env['model'].browse(record_id))
27 / 32
Useful Patterns
28 / 32
Fanout Job
A job generating other jobs.
@job
defimport_file(session,filepath):
withopen(filepath)asf:
forlineinf:
import_line.delay(session,line)
29 / 32
Try or delay
If an operation failed, try it later.
@job
defdo_operation(session,args):
#work
try:
do_operation(session,args)
exceptTimeoutError:
do_operation.delay(session,args,eta=10*60)
30 / 32
Extract highly concurrent tasks
And put them in a one-by-one channel.
31 / 32
Thanks!
32 / 32
Thanks!
OCA Sponsors
32 / 32

More Related Content

What's hot

RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
John Dalsgaard
 

What's hot (20)

Improving the performance of Odoo deployments
Improving the performance of Odoo deploymentsImproving the performance of Odoo deployments
Improving the performance of Odoo deployments
 
Common Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo appsCommon Performance Pitfalls in Odoo apps
Common Performance Pitfalls in Odoo apps
 
Linux networking
Linux networkingLinux networking
Linux networking
 
Spring Batch 2.0
Spring Batch 2.0Spring Batch 2.0
Spring Batch 2.0
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance Issues
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New ViewOdoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
Odoo Experience 2018 - Visualizing Data in Odoo: How to Create a New View
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
 
GRPC.pptx
GRPC.pptxGRPC.pptx
GRPC.pptx
 
Managing transactions on Ethereum with Apache Airflow
Managing transactions on Ethereum with Apache AirflowManaging transactions on Ethereum with Apache Airflow
Managing transactions on Ethereum with Apache Airflow
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Odoo Performance Limits
Odoo Performance LimitsOdoo Performance Limits
Odoo Performance Limits
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Installation configuration OpenERP 7 - Windows
Installation   configuration OpenERP 7 - WindowsInstallation   configuration OpenERP 7 - Windows
Installation configuration OpenERP 7 - Windows
 
Webpack slides
Webpack slidesWebpack slides
Webpack slides
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFuture
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 

Viewers also liked

Odoo - How to create awesome websites and e-commerce
Odoo - How to create awesome websites and e-commerceOdoo - How to create awesome websites and e-commerce
Odoo - How to create awesome websites and e-commerce
Odoo
 

Viewers also liked (8)

Why should integrate your ecommerce and odoo erp?
Why should integrate your ecommerce and odoo erp?Why should integrate your ecommerce and odoo erp?
Why should integrate your ecommerce and odoo erp?
 
ERP solution for eCommerce Business
ERP solution for eCommerce BusinessERP solution for eCommerce Business
ERP solution for eCommerce Business
 
Odoo - How to create awesome websites and e-commerce
Odoo - How to create awesome websites and e-commerceOdoo - How to create awesome websites and e-commerce
Odoo - How to create awesome websites and e-commerce
 
OpenERP Magento Connector "New Generation" Workflow
OpenERP Magento Connector "New Generation" WorkflowOpenERP Magento Connector "New Generation" Workflow
OpenERP Magento Connector "New Generation" Workflow
 
Odoo - Business intelligence: Develop cube views for your own objects
Odoo - Business intelligence: Develop cube views for your own objectsOdoo - Business intelligence: Develop cube views for your own objects
Odoo - Business intelligence: Develop cube views for your own objects
 
How to manage a service company with Odoo
How to manage a service company with OdooHow to manage a service company with Odoo
How to manage a service company with Odoo
 
Odoo Strategy and Roadmap
Odoo Strategy and RoadmapOdoo Strategy and Roadmap
Odoo Strategy and Roadmap
 
K Fund - Pitch to LPs
K Fund - Pitch to LPsK Fund - Pitch to LPs
K Fund - Pitch to LPs
 

Similar to A jobs queue for processing tasks asynchronously

stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
NETWAYS
 
HARD COPY REPORT CDAC
HARD COPY REPORT CDACHARD COPY REPORT CDAC
HARD COPY REPORT CDAC
Sarthak Dubey
 
Connect2014: BP105 A Performance Boost for your Notes Client
Connect2014: BP105 A Performance Boost for your Notes ClientConnect2014: BP105 A Performance Boost for your Notes Client
Connect2014: BP105 A Performance Boost for your Notes Client
Franziska Tanner
 
Eventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introductionEventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introduction
Marc Seeger
 

Similar to A jobs queue for processing tasks asynchronously (20)

How Kubernetes allows your Startup to scale
How Kubernetes allows your Startup to scaleHow Kubernetes allows your Startup to scale
How Kubernetes allows your Startup to scale
 
Overview
OverviewOverview
Overview
 
presentation
presentationpresentation
presentation
 
Treasure Data Summer Internship Final Report
Treasure Data Summer Internship Final ReportTreasure Data Summer Internship Final Report
Treasure Data Summer Internship Final Report
 
Bandwidth, Throughput, Iops, And Flops
Bandwidth, Throughput, Iops, And FlopsBandwidth, Throughput, Iops, And Flops
Bandwidth, Throughput, Iops, And Flops
 
Tuning Java Servers
Tuning Java Servers Tuning Java Servers
Tuning Java Servers
 
Loadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 PresentationLoadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 Presentation
 
Understanding and building Your Own Docker
Understanding and building Your Own DockerUnderstanding and building Your Own Docker
Understanding and building Your Own Docker
 
stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
stackconf 2023 | How the Network Protocols You Choose Ultimately Affect Your ...
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
MongoDB World 2019: Becoming an Ops Manager Backup Superhero!
 
HARD COPY REPORT CDAC
HARD COPY REPORT CDACHARD COPY REPORT CDAC
HARD COPY REPORT CDAC
 
SUTOL 2015 - A Performance Boost for your IBM Notes Client
SUTOL 2015 - A Performance Boost for your IBM Notes ClientSUTOL 2015 - A Performance Boost for your IBM Notes Client
SUTOL 2015 - A Performance Boost for your IBM Notes Client
 
Connect2014: BP105 A Performance Boost for your Notes Client
Connect2014: BP105 A Performance Boost for your Notes ClientConnect2014: BP105 A Performance Boost for your Notes Client
Connect2014: BP105 A Performance Boost for your Notes Client
 
Eventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introductionEventdriven I/O - A hands on introduction
Eventdriven I/O - A hands on introduction
 
DNUG Webcast: IBM Notes V10 Performance Boost
DNUG Webcast: IBM Notes V10 Performance BoostDNUG Webcast: IBM Notes V10 Performance Boost
DNUG Webcast: IBM Notes V10 Performance Boost
 
Users guide
Users guideUsers guide
Users guide
 
Using Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelinesUsing Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelines
 
DanNotes 2014 - A Performance Boost for your IBM Notes Client
DanNotes 2014 - A Performance Boost for your IBM Notes ClientDanNotes 2014 - A Performance Boost for your IBM Notes Client
DanNotes 2014 - A Performance Boost for your IBM Notes Client
 
report
reportreport
report
 

More from Camptocamp

GeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISGeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGIS
Camptocamp
 
NGEO – OpenLayers meets Angular
NGEO – OpenLayers meets AngularNGEO – OpenLayers meets Angular
NGEO – OpenLayers meets Angular
Camptocamp
 
OpenLayers 3 & Google Closure Compiler
OpenLayers 3 & Google Closure CompilerOpenLayers 3 & Google Closure Compiler
OpenLayers 3 & Google Closure Compiler
Camptocamp
 

More from Camptocamp (20)

ERP et customisation : comment éviter l’usine à gaz ?
ERP et customisation : comment éviter l’usine à gaz ?ERP et customisation : comment éviter l’usine à gaz ?
ERP et customisation : comment éviter l’usine à gaz ?
 
10 points-clés incontournables pour réussir votre projet ERP
10 points-clés incontournables pour réussir votre projet ERP10 points-clés incontournables pour réussir votre projet ERP
10 points-clés incontournables pour réussir votre projet ERP
 
Topsoft 2017: Praxisbericht: Welche Fehler bei der Implementierung eines ERP-...
Topsoft 2017: Praxisbericht: Welche Fehler bei der Implementierung eines ERP-...Topsoft 2017: Praxisbericht: Welche Fehler bei der Implementierung eines ERP-...
Topsoft 2017: Praxisbericht: Welche Fehler bei der Implementierung eines ERP-...
 
Geo mapfish 2_foss4g-eu_2017
Geo mapfish 2_foss4g-eu_2017Geo mapfish 2_foss4g-eu_2017
Geo mapfish 2_foss4g-eu_2017
 
Ge orchestra open_source_inspire_sdi-project_status_foss4g-eu_2017
Ge orchestra open_source_inspire_sdi-project_status_foss4g-eu_2017Ge orchestra open_source_inspire_sdi-project_status_foss4g-eu_2017
Ge orchestra open_source_inspire_sdi-project_status_foss4g-eu_2017
 
Data processing qgis3_foss4g-eu_2017
Data processing qgis3_foss4g-eu_2017Data processing qgis3_foss4g-eu_2017
Data processing qgis3_foss4g-eu_2017
 
AGIT 2017: GeoMapFish_2.2, the open source WebGIS
AGIT 2017: GeoMapFish_2.2, the open source WebGISAGIT 2017: GeoMapFish_2.2, the open source WebGIS
AGIT 2017: GeoMapFish_2.2, the open source WebGIS
 
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map EngineAGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
AGIT 2017: Cesium 1.35, WebGL Virtual Globe and Map Engine
 
AGIT 2017: geOrchestra 16.12, the open source INSPIRE SDI
AGIT 2017: geOrchestra 16.12, the open source INSPIRE SDIAGIT 2017: geOrchestra 16.12, the open source INSPIRE SDI
AGIT 2017: geOrchestra 16.12, the open source INSPIRE SDI
 
[Geocom2017] geOrchestra and ngeo
[Geocom2017] geOrchestra and ngeo[Geocom2017] geOrchestra and ngeo
[Geocom2017] geOrchestra and ngeo
 
[Geocom2017] Georchestra & monitoring
[Geocom2017] Georchestra & monitoring[Geocom2017] Georchestra & monitoring
[Geocom2017] Georchestra & monitoring
 
GeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISGeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGIS
 
NGEO – OpenLayers meets Angular
NGEO – OpenLayers meets AngularNGEO – OpenLayers meets Angular
NGEO – OpenLayers meets Angular
 
OpenLayers 3 & Google Closure Compiler
OpenLayers 3 & Google Closure CompilerOpenLayers 3 & Google Closure Compiler
OpenLayers 3 & Google Closure Compiler
 
MapFish Print 3
MapFish Print 3MapFish Print 3
MapFish Print 3
 
georchestra SDI: Project Status Report
georchestra SDI: Project Status Reportgeorchestra SDI: Project Status Report
georchestra SDI: Project Status Report
 
GeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISGeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGIS
 
Présentation GeoMapFish
Présentation GeoMapFishPrésentation GeoMapFish
Présentation GeoMapFish
 
OpenLayers 3
OpenLayers 3OpenLayers 3
OpenLayers 3
 
Une IDS scalable et résiliente avec geOrchestra & Docker
Une IDS scalable et résiliente avec geOrchestra & DockerUne IDS scalable et résiliente avec geOrchestra & Docker
Une IDS scalable et résiliente avec geOrchestra & Docker
 

Recently uploaded

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
panagenda
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 

A jobs queue for processing tasks asynchronously