{"id":463491,"date":"2025-06-15T21:01:03","date_gmt":"2025-06-15T21:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463491"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463491","title":{"rendered":"<span>\u041a\u0430\u043a \u0438 \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Celery \u2014 \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u043d\u0430 \u043f\u0440\u043e\u0434\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u0439 API, \u0438 \u044f \u0432\u043d\u0435\u0434\u0440\u0438\u043b Celery. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440:<\/p>\n<ul>\n<li>\n<p> \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Celery,<\/p>\n<\/li>\n<li>\n<p> \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d,<\/p>\n<\/li>\n<li>\n<p>\u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0435\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0434\u0435.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Celery (\u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0442\u043a\u043e)<\/h3>\n<p>Celery \u2014 \u044d\u0442\u043e \u0442\u0430\u0441\u043a-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 <strong>\u0432 \u0444\u043e\u043d\u0435<\/strong>, <strong>\u0432\u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430<\/strong> \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u2192 \u043e\u043d\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 (\u0432\u043e\u0440\u043a\u0435\u0440) \u0431\u0435\u0440\u0451\u0442 \u0435\u0451 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0440\u043a\u0435\u0440\u044b, \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0443\u043f\u0430\u0432\u0448\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0435\u0439\u0441: \u0432\u043d\u0435\u0448\u043d\u044f\u044f AI-API \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/h3>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u0430 \u2192 \u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0435\u0433\u043e \u0432 \u0432\u043d\u0435\u0448\u043d\u044e\u044e API (\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0418\u0418).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API = ~10 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 10 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0436\u0434\u0451\u0442 100 \u0441\u0435\u043a\u0443\u043d\u0434. \u0416\u0443\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u21161 \u2014 asyncio<\/h3>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b: &#171;\u041e\u043a\u0435\u0439, \u0434\u0430\u0432\u0430\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u043c <code>asyncio<\/code>&#171;:<\/p>\n<pre><code class=\"python\">async def call_api():     response = await aiohttp.request(...) <\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<br \/> \u2013 <code>asyncio<\/code> \u043d\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438,<br \/> \u2013 API \u2014 \u0432\u043d\u0435\u0448\u043d\u044f\u044f, \u044f \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0443 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p><strong>\u0412\u0435\u0440\u0434\u0438\u043a\u0442:<\/strong> \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<h3>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u21162 \u2014 multiprocessing<\/h3>\n<p>\u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">from multiprocessing import Pool  with Pool(10) as pool:     results = pool.map(call_api, data) <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u0431\u043b\u0438\u0436\u0435 \u2014 <code>multiprocessing<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<br \/> \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f I\/O-\u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0433\u0440\u0443\u0437\u044f\u0442 CPU.<\/p>\n<p>\u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 <strong>\u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e<\/strong>, \u043d\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439, \u043d\u0435\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043d\u0435\u0442 \u0440\u0435\u0442\u0440\u0430\u0435\u0432.<\/p>\n<h3>\u041f\u043e\u0431\u0435\u0434\u0430 \u2014 Celery + Redis<\/h3>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043f\u0440\u043e Celery. \u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u0438, \u0432\u043e\u0440\u043a\u0435\u0440\u044b, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u0435\u0442 \u0440\u0435\u0442\u0440\u0430\u0438\u0442\u044c, \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Redis \u0438 RabbitMQ \u043a\u0430\u043a \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">pip install celery redis<\/code><\/pre>\n<p><code>tasks.py<\/code>:<\/p>\n<pre><code class=\"python\">from celery import Celery  app = Celery('my_app', broker='redis:\/\/localhost:6379\/0')  @app.task def call_ai_api(data):     # \u0412\u044b\u0437\u043e\u0432 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 API     ... <\/code><\/pre>\n<h3>\u0411\u0440\u043e\u043a\u0435\u0440\u044b: Redis vs RabbitMQ<\/h3>\n<ul>\n<li>\n<p><strong>Redis<\/strong> \u2014 \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u044b\u0441\u0442\u0440\u043e, \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f 80% \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>RabbitMQ<\/strong> \u2014 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u0435\u043d \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Amazon SQS \/ Kafka<\/strong> \u2014 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043e\u0431\u043b\u0430\u043a\u043e \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0432\u044b\u0431\u0440\u0430\u043b Redis \u2014 \u043e\u043d \u0443\u0436\u0435 \u0441\u0442\u043e\u044f\u043b.<\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u2014 Celery Flower<\/h3>\n<pre><code class=\"bash\">pip install flower celery -A celery_app flower<\/code><\/pre>\n<p>Flower \u2014 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442:<br \/> \u2013 \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447,<br \/> \u2013 \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b,<br \/> \u2013 \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f,<br \/> \u2013 \u041e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u26a0\ufe0f \u041d\u043e: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b <strong>\u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435<\/strong>. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 UI, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0435\u0441\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0420\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<h3>\u0413\u0440\u0430\u0431\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0435: pool \u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0448\u043b\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (~10+ \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443), Celery \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f.<\/p>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f: Celery \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <strong>execution pools<\/strong> \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432. \u0415\u0441\u0442\u044c \u0442\u0440\u0438:<\/p>\n<ul>\n<li>\n<p><code>prefork<\/code> \u2014 \u0444\u043e\u0440\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u0430\u0434\u0451\u0436\u043d\u043e),<\/p>\n<\/li>\n<li>\n<p><code>eventlet<\/code> \/ <code>gevent<\/code> \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u044b async-\u0442\u0430\u0441\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p><code>solo<\/code> \u2014 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a, \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b <code>--pool=gevent<\/code>, \u043d\u043e \u0432\u0441\u0451 \u043f\u0430\u0434\u0430\u043b\u043e.<br \/> \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">celery -A celery_app worker --concurrency=30 --pool=prefork<\/code><\/pre>\n<p>\u0418 \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u044b.<\/p>\n<h3>\u0421\u043e\u0432\u0435\u0442\u044b \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a<\/h3>\n<ul>\n<li>\n<p>\u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0430\u0441\u043a\u0438 <code>async def<\/code> \u2014 Celery \u0438\u0445 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 async-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>asyncio.run()<\/code>, \u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 loop-\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u0435 \u043b\u043e\u0433\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0439\u0442\u0435 \u0432 \u0444\u0430\u0439\u043b\u044b \u2014 Flower \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438 \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u0432\u0441\u0435 \u0442\u0440\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0440\u0435\u0442\u0440\u0430\u0438, \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b, <code>acks_late<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0443\u043c\u0430\u044e \u043d\u0430\u0434 <strong>\u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043b\u043e\u0433\u043e\u0432 \u0437\u0430\u0434\u0430\u0447<\/strong> \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0430\u0437\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Celery \u0432\u0441\u0451 \u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0435 \u2014 \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c \u0438\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 API \u0438\u043b\u0438 \u0442\u044f\u0436\u0435\u043b\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u2014 Celery \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<br \/>\u041d\u043e \u043a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430: \u043c\u0430\u0433\u0438\u0438 \u043d\u0435\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0432\u043d\u0443\u0442\u0440\u0438&#187;.<\/p>\n<p>\u0425\u043e\u0447\u0435\u0448\u044c \u2014 \u043c\u043e\u0433\u0443 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u043a\u0443 (\u043a\u0430\u043a \u0438\u0434\u0451\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u2192 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2192 \u0432\u043e\u0440\u043a\u0435\u0440 \u2192 API \u2192 \u043e\u0442\u0432\u0435\u0442) \u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e?<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/918592\/\"> https:\/\/habr.com\/ru\/articles\/918592\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0432\u043d\u0435\u0448\u043d\u0435\u0439 API, \u0438 \u044f \u0432\u043d\u0435\u0434\u0440\u0438\u043b Celery. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0430\u0437\u0431\u043e\u0440:<\/p>\n<ul>\n<li>\n<p> \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Celery,<\/p>\n<\/li>\n<li>\n<p> \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d,<\/p>\n<\/li>\n<li>\n<p>\u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0435\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0434\u0435.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Celery (\u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0442\u043a\u043e)<\/h3>\n<p>Celery \u2014 \u044d\u0442\u043e \u0442\u0430\u0441\u043a-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 <strong>\u0432 \u0444\u043e\u043d\u0435<\/strong>, <strong>\u0432\u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430<\/strong> \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u2192 \u043e\u043d\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 (\u0432\u043e\u0440\u043a\u0435\u0440) \u0431\u0435\u0440\u0451\u0442 \u0435\u0451 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0440\u043a\u0435\u0440\u044b, \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0443\u043f\u0430\u0432\u0448\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0435\u0439\u0441: \u0432\u043d\u0435\u0448\u043d\u044f\u044f AI-API \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<\/h3>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0442\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0442\u0432\u0435\u0442\u0430 \u2192 \u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0435\u0433\u043e \u0432 \u0432\u043d\u0435\u0448\u043d\u044e\u044e API (\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0418\u0418).<\/p>\n<\/li>\n<li>\n<p>\u041e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a API = ~10 \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 10 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0436\u0434\u0451\u0442 100 \u0441\u0435\u043a\u0443\u043d\u0434. \u0416\u0443\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u21161 \u2014 asyncio<\/h3>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b: &#171;\u041e\u043a\u0435\u0439, \u0434\u0430\u0432\u0430\u0439 \u0441\u0434\u0435\u043b\u0430\u0435\u043c <code>asyncio<\/code>&#171;:<\/p>\n<pre><code class=\"python\">async def call_api():     response = await aiohttp.request(...) <\/code><\/pre>\n<p>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<br \/> \u2013 <code>asyncio<\/code> \u043d\u0435 \u0434\u0430\u0441\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438,<br \/> \u2013 API \u2014 \u0432\u043d\u0435\u0448\u043d\u044f\u044f, \u044f \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0443 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p><strong>\u0412\u0435\u0440\u0434\u0438\u043a\u0442:<\/strong> \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<h3>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u21162 \u2014 multiprocessing<\/h3>\n<p>\u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">from multiprocessing import Pool  with Pool(10) as pool:     results = pool.map(call_api, data) <\/code><\/pre>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u0431\u043b\u0438\u0436\u0435 \u2014 <code>multiprocessing<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<br \/> \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f I\/O-\u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0433\u0440\u0443\u0437\u044f\u0442 CPU.<\/p>\n<p>\u041d\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 <strong>\u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e<\/strong>, \u043d\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0435\u0439, \u043d\u0435\u0442 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043d\u0435\u0442 \u0440\u0435\u0442\u0440\u0430\u0435\u0432.<\/p>\n<h3>\u041f\u043e\u0431\u0435\u0434\u0430 \u2014 Celery + Redis<\/h3>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043f\u0440\u043e Celery. \u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u0438, \u0432\u043e\u0440\u043a\u0435\u0440\u044b, \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u0435\u0442 \u0440\u0435\u0442\u0440\u0430\u0438\u0442\u044c, \u043e\u0442\u043c\u0435\u043d\u044f\u0442\u044c, \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Redis \u0438 RabbitMQ \u043a\u0430\u043a \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"bash\">pip install celery redis<\/code><\/pre>\n<p><code>tasks.py<\/code>:<\/p>\n<pre><code class=\"python\">from celery import Celery  app = Celery('my_app', broker='redis:\/\/localhost:6379\/0')  @app.task def call_ai_api(data):     # \u0412\u044b\u0437\u043e\u0432 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 API     ... <\/code><\/pre>\n<h3>\u0411\u0440\u043e\u043a\u0435\u0440\u044b: Redis vs RabbitMQ<\/h3>\n<ul>\n<li>\n<p><strong>Redis<\/strong> \u2014 \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u044b\u0441\u0442\u0440\u043e, \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f 80% \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>RabbitMQ<\/strong> \u2014 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u0435\u043d \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439, \u0433\u0438\u0431\u043a\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>Amazon SQS \/ Kafka<\/strong> \u2014 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043e\u0431\u043b\u0430\u043a\u043e \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0432\u044b\u0431\u0440\u0430\u043b Redis \u2014 \u043e\u043d \u0443\u0436\u0435 \u0441\u0442\u043e\u044f\u043b.<\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u2014 Celery Flower<\/h3>\n<pre><code class=\"bash\">pip install flower celery -A celery_app flower<\/code><\/pre>\n<p>Flower \u2014 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442:<br \/> \u2013 \u0421\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447,<br \/> \u2013 \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b,<br \/> \u2013 \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f,<br \/> \u2013 \u041e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u26a0\ufe0f \u041d\u043e: \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b <strong>\u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435<\/strong>. \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0432 UI, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0435\u0441\u0442\u044c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0420\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<h3>\u0413\u0440\u0430\u0431\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0434\u0435: pool \u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u0448\u043b\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (~10+ \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443), Celery \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u043b\u0441\u044f.<\/p>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f: Celery \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <strong>execution pools<\/strong> \u2014 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432. \u0415\u0441\u0442\u044c \u0442\u0440\u0438:<\/p>\n<ul>\n<li>\n<p><code>prefork<\/code> \u2014 \u0444\u043e\u0440\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u0430\u0434\u0451\u0436\u043d\u043e),<\/p>\n<\/li>\n<li>\n<p><code>eventlet<\/code> \/ <code>gevent<\/code> \u2014 \u0437\u0435\u043b\u0451\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u044b async-\u0442\u0430\u0441\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p><code>solo<\/code> \u2014 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a, \u0434\u043b\u044f \u0434\u0435\u0431\u0430\u0433\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b <code>--pool=gevent<\/code>, \u043d\u043e \u0432\u0441\u0451 \u043f\u0430\u0434\u0430\u043b\u043e.<br \/> \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">celery -A celery_app worker --concurrency=30 --pool=prefork<\/code><\/pre>\n<p>\u0418 \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u044b.<\/p>\n<h3>\u0421\u043e\u0432\u0435\u0442\u044b \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a<\/h3>\n<ul>\n<li>\n<p>\u041d\u0435 \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0442\u0430\u0441\u043a\u0438 <code>async def<\/code> \u2014 Celery \u0438\u0445 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 async-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>asyncio.run()<\/code>, \u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 loop-\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u0435 \u043b\u043e\u0433\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0439\u0442\u0435 \u0432 \u0444\u0430\u0439\u043b\u044b \u2014 Flower \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438 \u043f\u043e\u0441\u043b\u0435 \u0435\u0433\u043e \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u0432\u0441\u0435 \u0442\u0440\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u0440\u0435\u0442\u0440\u0430\u0438, \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u044b, <code>acks_late<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0434\u0443\u043c\u0430\u044e \u043d\u0430\u0434 <strong>\u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043b\u043e\u0433\u043e\u0432 \u0437\u0430\u0434\u0430\u0447<\/strong> \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0430\u0437\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u044b. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Celery \u0432\u0441\u0451 \u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0435 \u2014 \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c \u0438\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 API \u0438\u043b\u0438 \u0442\u044f\u0436\u0435\u043b\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u2014 Celery \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<br \/>\u041d\u043e \u043a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430: \u043c\u0430\u0433\u0438\u0438 \u043d\u0435\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 &#171;\u0432\u043d\u0443\u0442\u0440\u0438&#187;.<\/p>\n<p>\u0425\u043e\u0447\u0435\u0448\u044c \u2014 \u043c\u043e\u0433\u0443 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u0445\u0435\u043c\u043a\u0443 (\u043a\u0430\u043a \u0438\u0434\u0451\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u2192 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2192 \u0432\u043e\u0440\u043a\u0435\u0440 \u2192 API \u2192 \u043e\u0442\u0432\u0435\u0442) \u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u0443\u0436\u043d\u043e?<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/918592\/\"> https:\/\/habr.com\/ru\/articles\/918592\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-463491","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463491"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463491\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}