Celery架构介绍

2024年1月20日 18:35 by wst

异步处理

1Celery简介

         Celery 是一个强大的分布式任务队列,它可以让任务的执行完全脱离主程序,甚至可以被分配到其他主机上运行。

         我们通常使用它来实现异步任务( async task )和定时任务( crontab )。 异步任务比如是发送邮件、或者文件上传, 图像处理等等一些比较耗时的操作 ,定时任务是需要在特定时间执行的任务。它的架构组成如下图:

         

应用场景大致如下:

  1. 分布式任务:Celery 可以将任务分发到多个工作者进程或机器上执行,以提高任务处理速度。

  2. 定时任务:Celery 可以在指定时间执行任务,例如每天定时备份数据。

  3. 后台任务:Celery 可以在后台执行耗时任务,例如图像处理、数据分析等,不影响用户界面的响应。

  4. 解耦任务:Celery 可以将任务与主程序解耦,以提高代码的可读性和可维护性。

  5. 实时处理:Celery 可以支持实时处理任务,例如即时通讯、消息队列等。

2组件介绍

         从上图我们可以看到,它是一个简单的生产者、消费者模型。接着对其中的组件分别详细介绍。

2.1生产者

          顾名思义,它是产生任务的部分。主要包括两种:异步任务和定时任务。

1)异步任务一般是比较耗时或者延迟执行的任务,比如用户上传了一批数据,需要做统计分析,此时会产生一个异步任务丢到消息队列(中间件)中。

2)定时任务即那些需要定时执行的任务,比如每天早上给CEO发送某APP的统计结果。定时任务需要一个单独的进程(Celery Beat)去收集,启动命令大致为

celery beat -A wedo.period_task

2.2中间件

         这是一个消息队列,用于存储任务,不管是异步任务还是定时任务都会放到这个中间件中。一般采用Redis或者rabbitMQ作为中间件。

2.3消费者

         它的作用是从中间件中读取任务并执行。执行单元可以有多个,以提高任务的执行效率。即是Celery Worker,它在系统中是一个单独的进程。甚至可以分布于不同的机器上。启动命令大致为

# -A wedo为应用模块
# -l为日志level
# -c 为进程数
celery worker -A wedo  -l debug -c 4

2.4结果存储

         当异步任务执行完毕之后,要把结果存储起来以便后期查看。比如用户上传了一个大文件,文件的分析结果需要存储起来以便用户查看。

3总结

          本文主要介绍了Celery架构及各部分是干什么的。有很多工具引用了celery,比如airflow、redash。

           后面还会对Celery的实际应用做详细介绍,比如怎么设置Celery为常驻进程、怎么配合Django使用。敬请期待!如有高见,请不吝指教。


Comments(127) Add Your Comment

Qyvszu
buy lipitor generic <a href="https://lipiws.top/">lipitor 20mg brand</a> lipitor 40mg generic
Bdqqdq
cost ciprofloxacin 1000mg - <a href="https://metroagyl.top/">order generic cipro</a> augmentin 1000mg uk
Ckhxml
how to buy baycip - <a href="https://cipropro.top/gemyambutol/">ethambutol online buy</a> buy augmentin 375mg for sale
Bvnxdc
flagyl 400mg ca - <a href="https://metroagyl.top/">order flagyl 200mg online cheap</a> buy zithromax 250mg generic
Xdyddw
purchase ciplox without prescription - <a href="https://septrim.top/chloromycetin/">buy chloramphenicol paypal</a> buy generic erythromycin
Qycxfo
buy valtrex - <a href="https://gnantiviralp.com/zovirax/">buy zovirax for sale</a> order acyclovir without prescription
Cnyadb
ivermectin 6 mg pills - <a href="https://keflexin.top/sumycin/">order generic sumycin</a> brand sumycin
Rvswjh
buy metronidazole pill - <a href="https://metroagyl.top/azithromycin/">zithromax online order</a> purchase azithromycin online
Aicuhb
buy acillin generic <a href="https://ampiacil.top/">how to buy ampicillin</a> amoxicillin ca
Yvzjkt
buy generic lasix over the counter - <a href="https://antipathogenc.com/capoten/">order captopril 25mg pill</a> oral captopril 25 mg
Rhvjlc
glycomet order online - <a href="https://gnantiacidity.com/combivir/">buy cheap combivir</a> buy lincomycin 500mg online
Jxbqru
buy generic retrovir for sale - <a href="https://canadiangnp.com/avapro/">buy avapro without prescription</a> zyloprim usa
Mgojoz
buy generic clozapine over the counter - <a href="https://genonlinep.com/pepcid/">pepcid 40mg pill</a> how to get pepcid without a prescription
Ydvpvy
purchase seroquel generic - <a href="https://gnkantdepres.com/zoloft/">order sertraline 50mg generic</a> where can i buy eskalith
Vkmtcf
anafranil 25mg brand - <a href="https://antdeponline.com/abilify/">buy abilify pills for sale</a> sinequan 75mg generic
Urgmiw
buy hydroxyzine for sale - <a href="https://antdepls.com/lexapro/">escitalopram pills</a> endep over the counter
Aervnl
purchase amoxil without prescription - <a href="https://atbioxotc.com/trimox/">buy amoxicillin generic</a> purchase ciprofloxacin pill
Ovvevc
where can i buy augmentin - <a href="https://atbioinfo.com/ampicillin/">acillin tablet</a> ciprofloxacin us
Nietvn
buy cleocin paypal - <a href="https://cadbiot.com/chloramphenicol/">chloromycetin medication</a> cheap chloromycetin generic
Rionkh
azithromycin 500mg drug - <a href="https://gncatbp.com/emetronidazole/">brand metronidazole 400mg</a> ciplox 500 mg tablet
Rkqrvo
buy stromectol - <a href="https://antibpl.com/tylquin/">levofloxacin canada</a> cefaclor sale
Ilvkgg
buy ventolin no prescription - <a href="https://antxallergic.com/xsseroflo/">purchase seroflo inhalator online</a> order generic theophylline
Ikpfye
purchase desloratadine online - <a href="https://rxtallerg.com/">order clarinex 5mg pills</a> purchase albuterol generic
Hytbbp
cheap depo-medrol - <a href="https://ntallegpl.com/loratadine/">loratadine uk</a> order generic astelin 10ml
Qvqwpd
buy cheap generic glyburide - <a href="https://prodeprpl.com/">glyburide 2.5mg tablet</a> dapagliflozin 10mg brand
Rukpax
buy prandin medication - <a href="https://depressinfo.com/jardiance25/">order empagliflozin 10mg</a> jardiance price
Osapjc
buy metformin for sale - <a href="https://arxdepress.com/sitagliptin50/">order januvia sale</a> order acarbose 50mg for sale
Ogxldf
order terbinafine 250mg online - <a href="https://treatfungusx.com/xgrifulvinvs/">griseofulvin online buy</a> buy generic grifulvin v online
Hizbeq
buy rybelsus 14mg generic - <a href="https://infodeppl.com/ddavpspray/">DDAVP drug</a> buy desmopressin sale
Xmywdt
buy ketoconazole pills for sale - <a href="https://antifungusrp.com/butenafinecream/">where to buy butenafine without a prescription</a> oral itraconazole 100mg
Zpccwm
oral famvir 500mg - <a href="https://amvinherpes.com/acyclovircream/">purchase acyclovir pills</a> order valcivir 500mg for sale
Fwhdtt
digoxin cost - <a href="https://blpressureok.com/avalidemed/">order irbesartan 300mg generic</a> order lasix 100mg pill
Cblewn
order hydrochlorothiazide 25mg pills - <a href="https://norvapril.com/felodipine/">order felodipine without prescription</a> zebeta 10mg for sale
Uwathg
where can i buy lopressor - <a href="https://bloodpresspl.com/propranolol/">buy propranolol medication</a> buy nifedipine paypal
Ruaqbe
purchase nitroglycerin - <a href="https://nitroproxl.com/indapamide/">buy cheap generic indapamide</a> buy valsartan pill
Jlgasi
simvastatin autumn - <a href="https://canescholest.com/gemfibrozil/">lopid solution</a> lipitor whence
Zdquhz
crestor conversation - <a href="https://antcholesterol.com/">rosuvastatin online instant</a> caduet pills shrill
Rxptlq
buy viagra professional den - <a href="https://edsildps.com/superavana/">avana considerable</a> levitra oral jelly online offend
Sdefoh
priligy orange - <a href="https://promedprili.com/sildigra/">sildigra situation</a> cialis with dapoxetine talent
Dpwglb
cenforce online sock - <a href="https://xcenforcem.com/silagrasildenafil/"></a> brand viagra pills cost
Fiuoyg
brand cialis farm - <a href="https://probrandtad.com/brandlevitra/">brand levitra correct</a> penisole gasp
Expppp
cialis soft tabs pills here - <a href="https://supervalip.com/tadarisepills/">tadarise own</a> viagra oral jelly online papa
Vfzasj
brand cialis stay - <a href="https://probrandtad.com/brandlevitra/">brand levitra whatever</a> penisole side
Rtxmvz
cialis soft tabs toe - <a href="https://supervalip.com/cialissuperactive/">cialis super active online disgust</a>1 viagra oral jelly online amid
Mnqcwf
cenforce online fix - <a href="https://xcenforcem.com/brandviagrasildenafil/">brand viagra profound</a> brand viagra pills library
Wtwaye
acne treatment double - <a href="https://placnemedx.com/">acne medication endure</a> acne medication guess
Zywvvo
asthma medication fury - <a href="https://bsasthmaps.com/">asthma medication dean</a> inhalers for asthma click
Ktpaua
treatment for uti elder - <a href="https://amenahealthp.com/">treatment for uti west</a> treatment for uti panic
Uqdrsi
pills for treat prostatitis daughter - <a href="https://xprosttreat.com/">pills for treat prostatitis wheel</a> prostatitis medications bat
Zxedul
valtrex pills retire - <a href="https://gnantiviralp.com/">valtrex online tongue</a> valtrex online puff
Ssgkxh
claritin pills stand - <a href="https://clatadine.top/">claritin pills gentle</a> claritin project
Hvngky
loratadine medication funny - <a href="https://clatadine.top/">claritin pills yeah</a> claritin pills lash
Fgncwu
priligy creature - <a href="https://prilixgn.top/">dapoxetine heap</a> dapoxetine force
Uoscea
promethazine legend - <a href="https://prohnrg.com/">promethazine thy</a> promethazine peep
Bhbdlp
ascorbic acid thousand - <a href="https://ascxacid.com/">ascorbic acid grandfather</a> ascorbic acid common
Pqlntt
clarithromycin breast - <a href="https://gastropls.com/gncytotec/">cytotec pills bore</a> cytotec flicker
Pjnizq
florinef fever - <a href="https://gastroplusp.com/nexesomeprazole/">nexium shelf</a> lansoprazole pills excitement
Scspne
buy generic bisacodyl 5 mg - <a href="https://gastroinfop.com/">purchase bisacodyl without prescription</a> order liv52 20mg generic
Efgbtn
cost aciphex 10mg - <a href="https://gastrointesl.com/domperidone/">domperidone 10mg cost</a> cheap domperidone
Lscjqw
purchase cotrimoxazole generic - <a href="https://ketiracet.com/">cost levetiracetam</a> tobramycin 5mg cheap
Jrpobd
buy cheap generic zovirax - <a href="https://cerazestrel.com/">desogestrel order</a> duphaston 10 mg without prescription
Qdytrd
forxiga drug - <a href="https://sineqpin.com/">sinequan 25mg for sale</a> order acarbose 25mg online cheap
Xgzepj
order griseofulvin 250mg generic - <a href="https://gemfilopi.com/">lopid 300 mg generic</a> order gemfibrozil 300mg for sale
Mzkoyv
buy vasotec 5mg pills - <a href="https://doxapisin.com/">buy doxazosin paypal</a> zovirax cost
Hrdecw
where can i buy dramamine - <a href="https://bisacolax.com/">order dramamine 50 mg pills</a> risedronate over the counter
Scmkre
order etodolac 600mg sale - <a href="https://cilosetal.com/">buy cilostazol pills for sale</a> cilostazol cost
Dqikgy
cheap piroxicam 20mg - <a href="https://feldexicam.com/">where to buy feldene without a prescription</a> order rivastigmine online cheap
Ttmivh
how to buy hydrea - <a href="https://hydroydrinfo.com/disulfiram/">buy disulfiram 250mg for sale</a> brand robaxin 500mg
Ivllbd
divalproex 250mg pill - <a href="https://adepamox.com/mefloquine/">buy cheap lariam</a> order topiramate 200mg without prescription
Erdlkw
cheap generic disopyramide phosphate - <a href="https://anorpica.com/pregabal/">pregabalin 75mg for sale</a> order chlorpromazine 100mg generic
Thhckf
cheap cyclophosphamide online - <a href="https://cycloxalp.com/antivert/">order antivert 25mg pills</a> cheap vastarel for sale
Avoshz
buy aldactone generic - <a href="https://aldantinep.com/naltrexone/">naltrexone where to buy</a> revia 50mg cost
Jnvyxl
cheap flexeril 15mg - <a href="https://abflequine.com/enalapril/">vasotec 10mg us</a> enalapril 5mg over the counter
Iukvyw
ondansetron tablet - <a href="https://azofarininfo.com/oxybutynin/">oxybutynin online buy</a> requip online buy
Uqjqmx
ascorbic acid pill - <a href="https://mdacidinfo.com/isosorbidedinitrate/">purchase isordil for sale</a> order compro online
Gldulw
order durex gel online - <a href="https://xalaplinfo.com/durexcondoms/">purchase durex condoms</a> buy xalatan for sale
Wkkgjd
buy minoxidil online cheap - <a href="https://hairlossmedinfo.com/finasteridehl/">propecia generic</a> order propecia online
Ctkvdq
order generic arava - <a href="https://infohealthybones.com/calciumcarbonate/">buy calcium carbonate pills</a> buy cartidin generic
Yciyfm
buy atenolol 50mg pills - <a href="https://heartmedinfox.com/">tenormin canada</a> buy generic carvedilol
Jjhrub
calan 120mg drug - <a href="https://infoheartdisea.com/atenolol/">buy generic tenoretic over the counter</a> tenoretic online
Bwbjgv
cheap atorvastatin for sale - <a href="https://infoxheartmed.com/">atorlip without prescription</a> order bystolic 20mg pill
Hnjvaf
gasex over the counter - <a href="https://herbalinfomez.com/diabecon/">purchase diabecon sale</a> buy diabecon generic
Mptzyt
buy lasuna pill - <a href="https://infoherbalmz.com/diarex/">diarex price</a> buy himcolin generic
Whpnpx
cheap generic speman - <a href="https://spmensht.com/himplasia/">himplasia brand</a> cheap fincar without prescription
Jpuqzs
buy noroxin cheap - <a href="https://gmenshth.com/">noroxin tablets</a> buy cheap generic confido
Titaxj
buy finax for sale - <a href="https://finmenura.com/">purchase finax generic</a> uroxatral 10mg without prescription
Bnntsj
hytrin 1mg without prescription - <a href="https://hymenmax.com/">buy terazosin online</a> priligy 60mg over the counter
Zkdchv
order trileptal 300mg generic - <a href="https://trileoxine.com/">oxcarbazepine 300mg tablet</a> order synthroid 150mcg generic
Sfvqhn
buy lactulose without a prescription - <a href="https://duphalinfo.com/betahistine/">betahistine 16mg generic</a> buy betahistine 16mg generic
Ygzbpo
buy imusporin generic - <a href="https://asimusxate.com/methotrexate/">methotrexate 10mg usa</a> where can i buy colcrys
Cdspse
buy deflazacort cheap - <a href="https://lazacort.com/brimonidine/">buy brimonidine</a> how to buy brimonidine
Fszxlr
besivance order - <a href="https://besifxcist.com/">buy besifloxacin eye drops for sale</a> sildamax for sale
Oxgdjw
buy generic neurontin 800mg - <a href="https://aneutrin.com/ibuprofen/">cost ibuprofen</a> azulfidine 500 mg price
Gahgqt
probenecid 500 mg drug - <a href="https://bendoltol.com/">where to buy probenecid without a prescription</a> purchase carbamazepine
Zevywz
order celebrex 100mg online cheap - <a href="https://celespas.com/">buy celecoxib 100mg generic</a> buy indocin 75mg for sale
Rmacgp
colospa over the counter - <a href="https://coloxia.com/">buy colospa 135 mg online</a> cheap pletal
Czciyl
order voltaren 100mg generic - <a href="https://dicloltarin.com/">cambia usa</a> cost aspirin 75 mg
Xgafrd
buy rumalaya without a prescription - <a href="https://rumaxtol.com/amitriptyline/">buy amitriptyline 10mg pill</a> buy endep 10mg online
Hisuwc
mestinon oral - <a href="https://mestonsx.com/asumatriptan/">imitrex 50mg without prescription</a> buy azathioprine 25mg for sale
Kkqtiq
buy voveran no prescription - <a href="https://vovetosa.com/">voveran tablet</a> nimotop order
Fmreip
order baclofen 25mg generic - <a href="https://baclion.com/">ozobax tablet</a> piroxicam where to buy
Jskcmq
periactin 4 mg canada - <a href="https://periheptadn.com/">periactin 4mg usa</a> zanaflex cheap
Oqagla
trihexyphenidyl pills - <a href="https://voltapll.com/diclofenacgel/">diclofenac gel online buy</a> order cheap voltaren gel
Fkslet
brand cefdinir 300 mg - <a href="https://omnixcin.com/clindamycin/">where can i buy cleocin</a> buy clindamycin generic
Hduydn
accutane canada - <a href="https://aisotane.com/asavlosulfon/">dapsone pill</a> buy deltasone 40mg
Irujeu
deltasone order - <a href="https://apreplson.com/permethrin/">elimite over the counter</a> purchase zovirax online cheap
Podprc
order acticin cream - <a href="https://actizacs.com/">acticin cream</a> buy retin cream for sale
Phbqls
betamethasone 20 gm without prescription - <a href="https://betnoson.com/awdifferin/">buy differin cream for sale</a> benoquin where to buy
Aekdyw
purchase flagyl sale - <a href="https://ametronles.com/">order metronidazole for sale</a> order generic cenforce 50mg
Zrrzgy
augmentin 375mg uk - <a href="https://baugipro.com/">buy augmentin 625mg pills</a> buy generic synthroid over the counter
Gfvhwp
cost cleocin 300mg - <a href="https://indometnp.com/">indocin cheap</a> order indocin 75mg sale
Vwbfkr
losartan 50mg over the counter - <a href="https://acephacrsa.com/">buy keflex 500mg sale</a> cephalexin online
Isnvob
purchase eurax without prescription - <a href="https://aeuracream.com/">purchase crotamiton online cheap</a> buy aczone online cheap
Lzwrzd
modafinil 200mg over the counter - <a href="https://sleepagil.com/phenergan/">order promethazine 25mg online</a> meloset 3mg usa
Tpmjom
bupropion 150mg generic - <a href="https://bupropsl.com/">zyban 150 mg cost</a> generic shuddha guggulu
Opnfpj
buy xeloda 500mg generic - <a href="https://xelocap.com/naproxen/">order naprosyn 250mg</a> order danocrine 100mg without prescription
Kgkoej
prometrium buy online - <a href="https://apromid.com/clomiphene/">serophene uk</a> clomiphene medication
Pasmir
buy alendronate 70mg online cheap - <a href="https://pilaxmax.com/">order fosamax 70mg pill</a> provera medication
Wqpvqy
order norethindrone 5 mg for sale - <a href="https://norethgep.com/">buy norethindrone paypal</a> order yasmin online cheap
Ambxsd
buy dostinex paypal - <a href="https://adostilin.com/alesse/">alesse for sale online</a> alesse over the counter
Jfmvxp
estrace 2mg sale - <a href="https://festrolp.com/">order estradiol 2mg pill</a> anastrozole without prescription
Pkxvka
г‚·гѓ«гѓ‡гѓЉгѓ•г‚Јгѓ« еЂ‹дєєијёе…Ґ гЃЉгЃ™гЃ™г‚Ѓ - <a href="https://jpedpharm.com/tadalafil/">г‚·г‚ўгѓЄг‚№йЂљиІ©</a> г‚·г‚ўгѓЄг‚№ гЃ®иіје…Ґ
Jcolnp
гѓ—гѓ¬гѓ‰гѓ‹гѓі гЃЇйЂљиІ©гЃ§гЃ®иіј - <a href="https://jpaonlinep.com/jamoxicillin/">г‚ўгѓўг‚­г‚·г‚·гѓЄгѓійЂљиІ©гЃЉгЃ™гЃ™г‚Ѓ</a> г‚ёг‚№гѓ­гѓћгѓѓг‚Ї гЃЇйЂљиІ©гЃ§гЃ®иіј
Jpdchl
プレドニン 薬局で買える - <a href="https://jpanfarap.com/jpaaccutane/">アキュテイン 市販 おすすめ</a> アキュテインの購入
Aohdgx
eriacta trail - <a href="https://eriagra.com/fforzestf/">forzest laughter</a> forzest blaze
Gpwepb
order indinavir generic - <a href="https://confindin.com/confido/">order confido without prescription</a> how to order diclofenac gel
Tdmcmt
valif undoubted - <a href="https://avaltiva.com/awsustiva/">order sustiva 10mg generic</a> order sinemet generic