SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
CELERY
Fila de Tarefas Distribuídas
Pedro Henrique de Assumpção
FRONT-END
Tarefas do
Ações demoradas, como envio de e-mail, gerar
relatório, análise de dados, machine learning,
scraping
TIMEOUT
Enfileieirado a ação
BACK-END
Django + Celery + Rabbit
A tarefa chega ao back-end em forma de task
assíncrona, através do serviço de mensageria
do celery, que utilizam da estrutura do rabbit
para armazenamento
Enviar e-mail
d6afe61f-04d7-444d-
bf7e-b8ea159fd40b
queue: mail
Gerar relatório
ee8f7be9-7473-461d-
b370-950c04712d69
queue: report
Somar vendas
a2a3bd02-1c33-4860-
974e-e684cb2b6353
queue: report
Comprar café
9c8e1af2-560f-4c19-
bd6f-48def41f04f1
queue: please
FILAS
SETUP
ENFILEIRADO
EXECUTANDO
COMPLETO
STATUS
ERRO
WORKER
TRABALHADOR
CONCURRENCY
QUEUES
VERBOSE
DOCKER
APPLY_ASSYNC
Assyncrona, não aguardar o
resultado
DELAY (D)
Espera até o término
TASK
Tarefas
BIND
app.task
self
TASK INHERITANCE
Herança de classe
Task Timeout.
Tarefas pequenas sem impacto
umas nas outras.
Processos que podem ser
divididos e então somados.
CUIDADO
TIMEOUT
MyRequest
on_timeout
SENTRY
Logs
Worker Lost
Unrecoverable error
MemoryError()
RETURN
JSON
SERIALIZABLE
Evocar resposta da task, necessita de um observador, oque
não é performático
dumps
$ pip install django-celery-results
REDIS
$ pip install -U "celery[redis]"


Visibility Timeout
Exchange
Queue
RABBITMQ
Broker Sugerido
Consumers (0)
Bindings (2)
Publish message
Get messages
Move messages
Delete
Purge
Runtime Metrics (Advanced)
Outros como: Redis, AMAZON SQS
PRIORITY
Task
Apply_assync
Exchange
Fila Lotada
BEAT
PERIODIC
TASKS model:
django_celery_beat.periodictask
EXTRA_APPS: django_celery_beat
DJANGO_CELERY_BEAT_TZ_AWARE
celery -A hermes beat -l info --
scheduler django_celery_beat
Cadastro de qualquer task via
interface, loaddata, migração.
Visibility timeout
solar, data, gerar gatilho, ciclo,
empilhamento
The Primitives
add.chunks(items, 10)
lista de tarefas que
devem ser aplicadas
em paralelo
group
uma tarefa chamada
após a outra
chain
grupo de cabeçalho e
um corpo, onde o
corpo é uma tarefa
que deve ser
executada após a
conclusão de todas as
tarefas no cabeçalho
chord
divide uma longa
lista de argumentos
em partes
chunks
única tarefa sendo
chamada, aplicando os
argumentos em ordem
à função
map
INSTANTÂNEO
Existe mesmo?
tarefas sazionais,
recursos
dinâmico
kubernets
portainer
worker especializados ou gerais.
Especializados fariam cada um uma parte do
processo.
Gerais, fariam todo o processo. Bastando replicar
workers para ter mais processos.
OTIMIZAÇÃO
DE RECURSOS
Horizontalização ou Verticalização.
Onde botar recursos?
task_time_limit
task_acks_on_failure_
or_timeout
task_store_errors_eve
n_if_ignored.
CONFIG ON SETTING OF DJANGO
CELERY_*
task_acks_late
task_reject_on_worke
r_lost
task_always_eager
TASK
CONFIG
PLUS
DEPLOY
PROGRAMAÇÃO
IPYTHON
WINDOWS
GEVENT
ASYNCIO
SLEEP
LIMPAR
QUEUE
TASK_ALWAYS_EAGER
ASSYNC ON TEST
PERGUNTAS
O que é?

Contenu connexe

En vedette

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

En vedette (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

CELERY