How socket.io-redis adapter works? 레디스 어댑터 동작원리

보통 실시간 메시징 처리에 socket.io와 redis를 많이 사용하는데, 그 동작 메커니즘이 자세히 소개된 글을 찾기 어려웠다. 이유는 간단한데, 소스코드가 그냥 간단해서 글로 쓰고 자시고 건더기도 없어 그런듯. 

기본적으로 socket.io는 Server, Namespace, Room, 그리고 Socket으로 구성되어있고 멀티 노드를 위해 pluggable 디자인 방식으로 Adapter라는 것이 존재한다. 

Default In-Memory 방식은 배열에 socket과 room 정보를 저장하기 때문에 웹 서버에 붙어있는 clients 외 에는 알 길이 없다. 이때 redis adapter를 사용하면 다음과 같이 동작하는데, sender가 원격에서 넘어왔다면 그냥 내 로컬 clients에게 deliver하는 것으로 종료하고 그렇지 않으면, 다른 노드에게 publish하여 메시지를 전달한다. 


분산 인프라 치고는 놀랍게도 Javascript 몇 줄 안되는 소스코드로 node, socket.io, 그리고 redis가 동작한다. 좀 이해하기 쉽게 도식화하면 다음과 같다:


17 comments:

  1. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I am looking forward to reading new articles. Keep up the good work!
    360DigiTMG

    ReplyDelete

  2. A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.
    iot course training in Hyderabad

    ReplyDelete
  3. I feel extremely glad to have seen your site page and anticipate such a large number of additionally engaging occasions perusing here. Much obliged again for all the subtleties.
    https://360digitmg.com/course/certification-program-in-iot

    ReplyDelete
  4. Your music is amazing. You have some very talented artists. I wish you the best of success.
    Best Data Science Courses in Hyderabad

    ReplyDelete
  5. It is a neat article without any clutter! The neatly organized content looks good. Can I quote a blog and write it on my blog? My blog has a diverse community, including these articles. Would you like to visit me later? 토토사이트

    ReplyDelete
  6. Your work is very good and I appreciate you and hopping for one of the finest sites on the internet. I will recommend this web site 토토사이트

    ReplyDelete
  7. Thanks for posting the best information and the blog is very informative.Data science course in Faridabad

    ReplyDelete
  8. You obviously know what youre talking about Guess I will just bookmark this site. 토토

    ReplyDelete
  9. my own blog and would like to find out where u got this from. Your post has really helped me a lot. 안전놀이터

    ReplyDelete
  10. Your writing is perfect and complete. 온라인바둑이 However, I think it will be more wonderful if your post includes additional topics that I am thinking of. I have a lot of posts on my site similar to your topic. Would you like to visit once?

    ReplyDelete
  11. Thank you for any other informative blog. Where else may just I am getting that kind of information written in such a perfect method? I have a mission that I’m simply now working on, and I have been on the glance out for such info. 먹튀검증

    ReplyDelete