Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Очереди задач без купюр, Артем Малышев, Positiv...
Search
IT-People
July 25, 2016
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Очереди задач без купюр, Артем Малышев, Positive Technologies
Выступление на конференции PyCon Russia 2016
IT-People
July 25, 2016
More Decks by IT-People
See All by IT-People
Александр Кошкин, Positive Technologies: Знай и люби свой CPython во имя луны и великой справедливости
itpeople123
1
210
How Python was Shaped by leaky Internals, Armin Ronacher, Flask framework
itpeople123
1
240
Building social network with Neo4j and Python, Андрей Солдатенко, Toptal
itpeople123
1
240
Осторожно, DSL! Иван Цыганов, Positive Technologies
itpeople123
0
130
Докеризация веб-приложения на Python Антон Егоров, Ostrovok.ru
itpeople123
0
200
Python Robot Operating System вместо Middleware framework Дмитрий Киселев, Endpoint.com
itpeople123
0
120
Falcon — очередная WSGI библиотека? Дмитрий Кукушкин, Wargaming
itpeople123
0
290
Flame graph: новый взгляд на привычное профилирование, Кирилл Борисов, Яндекс
itpeople123
1
270
Как добавить scripting в веб приложение, Константин Лопухин, Scrapinghub
itpeople123
0
150
Other Decks in Programming
See All in Programming
What's New in Android 2026
veronikapj
0
260
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
220
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.6k
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
270
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
250
React本体のコードリーディング
high_g_engineer
1
140
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
380
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
400
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
220
今さら聞けない .NET CLI
htkym
0
190
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.8k
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
370
Featured
See All Featured
Music & Morning Musume
bryan
47
7.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
A Soul's Torment
seathinner
6
3.4k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
430
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.7k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
Measuring & Analyzing Core Web Vitals
bluesmoon
9
950
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
430
Transcript
TASK QUEUES UNCUT МАЛЫШЕВ АРТЁМ
None
None
None
None
CELERY app = Celery(__name__) @app.task def add(x, y): return x
+ y add.delay(1, 2)
RQ def add(x, y): return x + y queue =
rq.Queue('default') queue.enqueue(add, 1, 2)
RABBITMQ QUEUES Name Ready Unacked Total celery 1 0 1
PAYLOAD { "task": "app.add", "args": [1, 2], "kwargs": {}, "id":
"27ebcaee-444f-4379-a438-04c3b5bb0fc3", "callbacks": null, "errbacks": null, "eta": null, "expires": null, "timelimit": [null, null], "taskset": null, "chord": null, "retries": 0 }
REDIS QUEUES >>> KEYS * 1) "celery" >>> LRANGE celery
0 -1 1) { "properties": { "body_encoding": "base64", "delivery_info": { "exchange": "celery", "routing_key": "celery" } }, "body": "eyJ0aW1lbGltaXQiOiBbbnVsb...", "content-type": "application/json" }
RQ >>> SMEMBERS rq:queues 1) "rq:queue:default" >>> LRANGE rq:queue:default 0
-1 1) "be58515f-9f330470995d" >>> HGETALL rq:job:be58515f-9f330470995d 1) "status" "queued" 2) "enqueued_at" "2016-06-14T19:45:39Z" 3) "created_at" "2016-06-14T19:45:39Z" 4) "origin" "default" 5) "description" "lib.add(1, 2)" 6) "data" "\x80\x04\x95\x17\x00\x00..." 7) "timeout" "180"
ACCEPT TASK # celery $ celery -A myapp worker -Q
queue1,queue2 # rq $ rq worker queue1 queue2
RABBITMQ QUEUES Name Ready Unacked Total celery 0 1 1
REDIS QUEUES >>> KEYS * 1) "celery" 2) "unacked" 3)
"unacked_index" 4) "unacked_mutex" >>> HGETALL unacked 1) "13ce9ff2-c596-4471" "[{...}, \"celery\", \"celery\"]"
RQ >>> HGETALL rq:job:be58515f-9f330470995d 1) "status" "started" 2) "enqueued_at" "2016-06-14T19:45:39Z"
3) "created_at" "2016-06-14T19:45:39Z" 4) "origin" "default" 5) "description" "lib.add(1, 2)" 6) "data" "\x80\x04\x95\x17\x00..." 7) "timeout" "180" 8) "started_at" "2016-06-14T21:21:14Z" >>> ZRANGE rq:wip:default 0 -1 WITHSCORES 1) "be58515f-9f330470995d" "1465939514"
FRAGILE ACKNOWLEDGMENT
RPOPLPUSH LUA SCRIPTS
None
None
None
TASK EXECUTION # celery def trace_task(uuid, args, kwargs, request=None): R
= retval = fun(*args, **kwargs) # rq class Job: def perform(self): self._result = self.func( *self.args, **self.kwargs)
CONCURRENCY ✓ gevent ✗ twisted ✗ tornado ✗ asyncio
None
None
None
None
None
CALLBACK app.add.apply_async((1, 2), link=app.mul.s(3)) PAYLOAD "callbacks": [ { "task": "app.mul",
"args": [3], "kwargs": {}, "options": {}, "chord_size": null, "immutable": false, "subtask_type": null } ]
CHAINS c = chain(app.add.s(1, 2), app.add.s(3), app.mul.s(6)) c()
RQ DEPENDENTS job = q.enqueue(lib.add, 1, 2) delayed = q.enqueue(lib.add,
1, 2, depends_on=job) REDIS >>> SMEMBERS rq:job:1183256d-2cf952c76:dependents 1) "00b70a47-bba9051bd7da" >>> HGETALL rq:job:00b70a47-bba9051bd7da 1) "status" "deferred" 2) "dependency_id" "1183256d-2cf952c76"
GROUPS g = group(app.add.s(1, 2), app.mul.s(3, 4)) g()
CHORD ch = chord([app.add.s(1, 2), app.add.s(3, 4)]) ch(app.mul.s(5)) PAYLOAD "chord":
{ "task": "app.mul", "chord_size": 3, "args": [7], "kwargs": null, "options": { "task_id": "2f0f2a7f-e249828b3fc9", "reply_to": "a53cb689-85a86c447428" } }
None
None
Celery: Redis as a broker deprecated in 4.0 Ask Solem
(@asksol) June 28, 2016 So I’m late for work, and seems like Redis as a broker is no longer deprecated :) Ask Solem (@asksol) June 28, 2016
None
THANKS
[email protected]