ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • How to use Airflow celery executor with redis sentinel
    개발/Airflow 2021. 5. 21. 00:59

    Airflow 를 사용할 때 병렬화 처리가 필요하다면, celery executor나 kubernetes excutor의 사용이 필요하다.

    이때 queue에 대한 broker 로 rabbitMQ나 redis를 사용할 수 있는데 이 글은 redis를 broker로 사용할때에 대한 이야기를 하려고 한다.

     

    Broker로 더 추천되는건 rabbitMQ이나 High Availability(HA)의 필요성이 있을때 redis가 구성에 잇점이 있다.

     

    Redis cluster with Sentinel and HAProxy

    Redis master-slave cluster를 구성한 후 Sentinel을 붙여 Redis의 고가용성을 보장하고, Airflow 의 read/write를 위하여 master로 연결하기위해 HAProxy를 연결할 수 있다. HAProxy역시 고가용성 구성을 위해 active/standby 구성을 할 수 있고 이를 load balancer를 이용해 구성할 수 있다. 추가로 Keepalive같은 어플리케이션으로 active/standby 구성을 할 수 있다.

    celery 의 redis 설정 문서 참고
    https://docs.celeryproject.org/en/stable/getting-started/brokers/redis.html

     

    추가로 Celery v4.2.0 버전부터는 Redis sentinel로 직접 Broker_url을 설정할 수 있어 위의 구성보다 훨씬 단순하고, redis failover시 더욱 빠르게 전환이 이루어지기에 특별한 상황이 아니라면 Sentinel로 직접 연결을 하는것이 낫다고 본다.

    Direct connect celery broker_url to sentinel

    app.conf.broker_url = 'sentinel://localhost:26379;sentinel://localhost:26380;sentinel://localhost:26381' app.conf.broker_transport_options = { 'master_name': "cluster1" }

    broker_transport_options 에 redis master의 이름 (ex: mymaster)을 넣어줘야 redis master를 찾아갈 수 있으며, redis cluster에 authentication 설정이 되어있다면, 아래 포멧대로 입력이 필요하다. 

    sentinel://{user}:{password}@{hostname}:{port}

    * 주의: 위 포멧은 공식문서에 포함되지 않은 사항이며, 추후 동작하지 않을 가능성이 있음

    '개발 > Airflow' 카테고리의 다른 글

    Airflow 의 Celery executor 의 custom configuration  (0) 2023.01.09
    Use Airflow broker with redis sentinel  (0) 2023.01.09

    댓글

Designed by Tistory.