Slack

Webhook이란?

ZzangHo 2022. 2. 23. 15:27
728x90

Webhook이란?

위키피디아에서는 다음과 같이 정의를 하고 있다. 

 

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Jeff Lindsay in 2007 from the computer programming term hook.[1] The format is usually JSON. The request is done as a HTTP POST request.
 

Webhook - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search Method of web development A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be

en.wikipedia.org

 

영어는 어려워서 내가 생각한 웹훅은 특정 작업이 끝난 경우 이벤트를 받을 수 있는 목적지?라고 생각하면 될 것 같다.

 

 

Polling vs Webhooks 비교

 

 

Webhook을 설명하는데 있어 위의 그림이 아주 유명하다.

 

  • Pooling
    Pooling 방식의 경우 App이 EndPoint에 주기적으로 이벤트가 발생하였는지 체크하는 방식으로 아주 비효율적이다.

  • Webhooks
    Webhooks의 경우 EndPoint에서 특정 이벤트가 발생할 경우에 App이 수신을 하는 케이스로 Pooling방식과 비교를 하였을 때 아주 효율적이다. 왜냐하면 App에서 주기적으로 EndPoint에 대해 체크를 할 필요가 없이 EndPoint에서 이벤트가 발생하면 이벤트를 보내주기 때문이다. 

 

Webhook 활용

그렇다면 어디에서 Webhook을 사용할까?

보통은 장애가 발생하였을 때 많이 사용하는 것으로 보인다. 그렇지만 꼭 장애 상황이 아니더라도 사용할 수 있다.

예를 들면 데일리 단위로 어떤 정보를 주기적으로 받아보고 싶을 경우이거나 특정 작업이 종료가 되면 이벤트를 보내도록 셋팅을 할 수도 있다.

 

나의 경우 이번에 데이터 파이프라인 프로젝트를 진행하면서 데일리 단위로 ElasticSearch에 Indexing을 하고 있는데 Indexing이 끝나면 어제 날짜의 Index에 걸려있는 Alias를 오늘 날짜 Index로 변경을 해주고 있다.

이때 오늘 날짜 Index에 Alias가 잘 변경이 되었는지?에 대해 Webhook으로 이벤트를 받고 있다.

(이 덕분에 매일 아침 Slack이 올때마다 심장이 떨린다는것~~)

 

 

'Slack' 카테고리의 다른 글

Slack Webhook API 셋팅  (0) 2022.02.24