본문 바로가기

Celery 시작하기

Celery Getting Started


샐러리 정식 문서 를 기반으로 번역 및 보충하여 작성하였습니다.



Celery는 비동기 Task Queue 입니다.


Task 를 Message Broker 를 통해 전달하면 Worker가 이를 처리하는 구조입니다.



튜토리얼 단계

  • Choosing and installing a message transport (broker).
  • Installing Celery and creating your first task.
  • Starting the worker and calling tasks.
  • Keeping track of tasks as they transition through different states, and inspecting return values.




Step 1. 브로커를 선택하여 설치하기



Celery 는 메세지를 보내고 받기 위해 솔루션을 필요로합니다.

보통 이는 message broker 라고 불리는 분리된 서비스 형태가 됩니다.


아래에 여러가지 선택지가 있습니다.


RabbitMQ


RabbitMQ 는 feature-complete 하고, 안정적이며 설치하기도 쉽습니다.

Production 환경에 사용하기에 좋은 서비스입니다.


Ubuntu 또는 Debian 을 사용한다면, 다음 명령어로 쉽게 설치할 수 있습니다.

$ sudo apt-get install rabbitmq-server

명령어가 완료될때 브로커는 이미 백그라운드에서 돌고 있을 것입니다.


Ubuntu 또는 Debian 이 아닌 다른 플랫폼을 사용 중이라면 (Microsoft Windows 같은) 다음 사이트로 이동하여 유사한 설치 문서를 참고하시면 됩니다.

http://www.rabbitmq.com/download.html


Redis


Redis 또한 feature-complete 하지만 power failure 또는 abrupt termination 상황에서 데이터 손실에 영향받기 쉽습니다.


자세한 정보는 다음 문서를 참고 바랍니다.

http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview


그 외 브로커들


http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview





Step 2. Celery 설치하기


Celery 는 Python Package Index (PyPI) 위에 있으므로, pip 같은 표준 파이썬 도구를 사용하여 설치할 수 있습니다.


$ pip install celery


Application