[ํ’€์Šคํƒ] ZMQ Pattern

2023. 4. 18. 00:43ใ†ComputerScience/FullStackProgramming

 

 

 

ZMQ Request-Reply pattern

  • ‘Hello World’ client/server example
    • Client sends “Hello” to the server
    • Server replies with “World”
    • 1:1 TCP echo ์„œ๋ฒ„์™€ ์œ ์‚ฌ
  • Synchronous REQ-REP socket
    • ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋™๊ธฐ, ํ†ต์‹ ์— ๋Œ€ํ•œ ๋ถ€๋ถ„์€ ์•Œ์•„์„œ ๋น„๋™๊ธฐ๋กœ ์ฒ˜๋ฆฌ๋จ
    • Client issues send() and then recv(), in a loop
    • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„ ํƒํ•œ ํŒจํ„ด - ๋ฆฌํ€˜์ŠคํŠธ ํŒจํ„ด / ์„œ๋ฒ„๋Š” ๋ฆฌํ”Œ๋ผ์ด ํŒจํ„ด
    • Doing any other sequence (e.g., sending two messages in a row) will result in a return code of -1 from the send or recv call

 

 

 

request - reply

 

 

 

< server >

  • basic class -> import zmq
  • ์ผ์ข…์˜ ZMQ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ์ฒด ์ƒ์„ฑ
  • ์†Œ์ผ“ ํƒ€์ž…์€ REP (์‘๋‹ต)
  • ์„œ๋ฒ„๋ฅผ ๋ฐ”์ธ๋“œ .bind ์‹œํ‚จ๋‹ค -> ์„œ๋ฒ„(socket)์ด ์‚ด์•„๋‚˜๊ณ , ๋ฐ”์ธ๋“œ ์‹œํ‚ด (tcp์™€ ์œ ์‚ฌ)
  • 1์ดˆ ์‰ฌ๋Š” ํ•จ์ˆ˜๋ฅผ ์“ฐ๋ ค๊ณ  import time 

 

 

< client >

  • client๋Š” request pattern 
    context.socket(zmq.REQ)
  • ์„œ๋ฒ„์˜ bind์— ์ƒ์‘ํ•˜๋Š” connect
  • app ์ด ๋™๊ธฐ๋ผ๋Š” ์ด์œ 
    -> ๋™๊ธฐ ๋ฐฉ์‹์œผ๋กœ ์„œ๋ฒ„์˜ ๊ฐ’์„ ๊ธฐ๋‹ค๋ฆฌ๊ณ , ์ถœ๋ ฅํ•˜๊ณ , ๋ฐ˜๋ณต 

 

 

 

  • Autonomous 1:N REQ-REP socket
    • You could throw thousands of clients at this server, all at once, and it would continue to work happily and quickly
    • tcp server - multi-thread -> ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ๊ตฌํ˜„ ์ผ์ผ์ด ํ•ด์•ผ ํ•จ
    • Example:
      • Single server : lec-05-prg-01-req-rep-basic-server.py (NO modification)
      • Three clients : lec-05-prg-02-req-rep-basic-client.py
      • ์„œ๋ฒ„๋ฅผ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ , ํด๋ผ์ด์–ธํŠธ 3๊ฐœ ๋„์›Œ์„œ ๋ถ™์—ฌ๋ฒ„๋ฆฐ๋‹ค.
      • ํ†ต์‹ ์— ๋Œ€ํ•œ ๋น„๋™๊ธฐ ์ฒ˜๋ฆฌ, ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ๊ธฐ๋Šฅ์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•œ๋‹ค. 
      • ๊ฐœ๋ฐœ์ž๊ฐ€ ๊ตฌํ˜„ํ•ด์•ผ ํ–ˆ๋˜ ๋กœ์ง์„ ์•Œ์•„์„œ ์ฒ˜๋ฆฌํ•œ ๊ฒƒ!

 

 

 

ZMQ Publish-Subscribe pattern

  • Connects a set of publishers to a set of subscribers
  • One-way data distribution pattern
  • Server pushes updates to a set of clients
  • stableํ•œ ์• ๋ฅผ ์„œ๋ฒ„(bind)๋กœ ์žก๋Š”๋‹ค - ํ•ด๋‹น ํŒจํ„ด์—์„œ๋Š” PUB 
  • ํ•˜๋‚˜์˜ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ผ ๋•Œ, ์—ฌ๋Ÿฌ ๋ช…์˜ subscriber์—๊ฒŒ ๋ณด๋‚ด๋Š” ๊ฒƒ

 

 

 

publish - subscribe pattern https://zguide.zeromq.org/docs/chapter5/

 

 

 

  •  PUB-SUB weather broadcasting example
    • Server pushes out weather updates consisting of a zip code, temperature, and relative humidit
    • Client listens to the stream of updates and grabs anything to do with a specified zip code
    • zip_filter at setsockopt_string (line number 21)
    • Client must set a subscription using setsockopt() and SUBSCRIBE, as in line number 21
    • ๋‚ ์”จ ์„œ๋ฒ„๋Š” ์ฃผ๊ธฐ์ ์œผ๋กœ ์ „ ์ง€์—ญ์˜ ์ •๋ณด๋ฅผ ๋ณด๋‚ธ๋‹ค
    • ์Šค๋งˆํŠธํฐ (ํด๋ผ์ด์–ธํŠธ) ๋ณธ์ธ์˜ ์œ„์น˜ ์ •๋ณด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ, ์„ ํƒ์ ์œผ๋กœ ์ •๋ณด๋ฅผ ๋ฐ›๋Š”๋‹ค

 

 

 

< server >

  • ํด๋ผ์ด์–ธํŠธ์˜ ์‘๋‹ต์„ ๋ฐ›๋Š” ์ฝ”๋“œ X
  • ๋ฉ”์„ธ์ง€๋ฅผ ์ „๋‹ฌํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋จ
  • ๊ฐœ๋ฐœ์ž๊ฐ€ ์ฒ˜๋ฆฌํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค -> zmp์—๊ฒŒ ๋ณด๋‚ผ ์ •๋ณด๋งŒ ์ฃผ๋ฉด, ์•Œ์•„์„œ ์ฒ˜๋ฆฌํ•จ
  • socket type - PUB, bind() -> server ์—ญํ• 
  • ์šฐํŽธ ๋ฒˆํ˜ธ, ์˜จ๋„, ์Šต๋„๋ฅผ ๋žœ๋ค์œผ๋กœ ์ƒ์„ฑํ•˜์—ฌ ๋ณด๋‚ด๋Š” ์ƒํ™ฉ

 

 

< client > 

  • SUB ์—ญํ• ์„ ๋งก๋Š”๋‹ค
  • ์‚ฌ์šฉ์ž๊ฐ€ ํ•ญ๋ชฉ์„ ์ฃผ๋ฉด, sys.argv -> zip_filter์— ๋‹ด๊น€ 
  • zip_filter๋ฅผ ํ†ตํ•ด ์›ํ•˜๋Š” ์ •๋ณด๋งŒ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

 

 

 

  • PUB-SUB socket characteristics
    • PUB-SUB socket pair is asynchronous
    • PUB-SUB socket is unidirectional
    • ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์งœ๋Š” ์‚ฌ๋žŒ ์ž…์žฅ์—์„œ, ๋‚ด์šฉ๋งŒ ์ดํ•ดํ•˜๊ณ  ์ฝ”๋“œ๋Š” ๊ตฌํ˜„ํ•  ํ•„์š” ์—†์ด zmp ์“ฐ๋ฉด ๋จ
    • ์„œ๋ฒ„๋Š” ์•Œ์•„์„œ ๋น„๋™๊ธฐ๋กœ ์ฒ˜๋ฆฌ๋จ
    • Client does recv(), in a loop (or once if that’s all it needs).
      Trying to send a message to a SUB socket will cause an error
    • server - send - PUB / client - receive - SUB (๋ฐ”๋€Œ๋ฉด ์—๋Ÿฌ ๋ฐœ์ƒ)
    • Similarly, the service does send() as often as it needs to, but must not do recv() on a PUB socket.

 

 

 

Publish-Subscribe with Pipeline pattern

  • Pipeline pattern
    • ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ -> ํŒŒ์ดํ”„๋ผ์ธ์ด๋ผ๋Š” ์šฉ์–ด ์‚ฌ์šฉ 
    • Connects nodes in a fan-out/fan-in pattern that can have multiple steps and loops
    • Parallel task distribution and collection pattern
    • ๋ถ„์‚ฐ ์ฒ˜๋ฆฌ์—์„œ ์ด๋Ÿฌํ•œ ๋ฐฉ์‹์œผ๋กœ ์งœ๋Š” ๊ฒฝ์šฐ ๋งŽ๋‹ค.  
      • push ๋ฐ€์–ด๋‚ด๋Š” ๊ฒƒ
        pull ๋‹น๊ธฐ๋Š” ๊ฒƒ
      • ์ž‘์—…์„ 3๊ฐœ์˜ ์ผ๊พผ์—๊ฒŒ ๋ฟŒ๋ฆฐ ํ›„, ํ•˜๋‚˜๋กœ ๋ชจ์œผ๊ธฐ 
        ๋น…๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ๋“ฑ๋“ฑ ๋ถ„์‚ฐ ์ฒ˜๋ฆฌ์—์„œ ๋งŽ์ด ํ™œ์šฉ

 

 

 

pipeline pattern

 

 

 

  •  PUB/SUB with PUSH/PULL example
    • Server 
      • PUB & PULL ๊ธฐ๋Šฅ
      • ๊ตฌ๋™์‹œ PUBlish ๋ฐ PULL ์„œ๋ฒ„ ๊ธฐ๋Šฅ์„ ํ™œ์„ฑํ™” ํ•จ
      • Client๋“ค์ด ์ฃผ๊ธฐ์ ์œผ๋กœ ๋ณด๊ณ ํ•˜๋Š” ์ƒํƒœ ์ •๋ณด๋ฅผ PULL ํ•œ ํ›„, ๋‹ค์‹œ ๋ชจ๋“  Client๋“ค์— PUBlish ํ•จ
    •  Client
      • SUB & PUSH ๊ธฐ๋Šฅ
      • ์ฃผ๊ธฐ์ ์œผ๋กœ ์ž์‹ ์˜ ์ƒํƒœ ์ •๋ณด๋ฅผ Server์— PUSH ํ•จ
      • Server๊ฐ€ PUBlishํ•œ (๋ณธ์ธ ํฌํ•จ) ์ „์ฒด Client๋“ค์˜ ์ƒํƒœ๋ฅผ SUBscribe ๊ธฐ๋Šฅ์„ ํ†ตํ•ด์„œ ์ˆ˜์‹ ํ•จ
      • state๋ฅผ ์ฃผ๊ณ  ๋ฐ›์œผ๋‚˜, ์ฑ„ํŒ…๊ณผ ๋‹ค๋ฅผ ๋ฐ”๊ฐ€ ์—†๋‹ค

  

 

 

https://zguide.zeromq.org/docs/chapter5/

 

  • ์˜ค๋ž˜ ๋ฒ„ํ‹ฐ๋Š” ์• ๋ฅผ ์„œ๋ฒ„๋กœ ์œ„์น˜์‹œํ‚จ๋‹ค
  • ์‚ด์•˜๋‹ค ์ฃฝ์—ˆ๋‹ค, ๋™์ ์ธ ์•  -> ํด๋ผ์ด์–ธํŠธ
  • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์„œ๋ฒ„์—๊ฒŒ state๋ฅผ ๋ณด๋ƒ„
    ex) ๋ณธ์ธ์ด ๋กœ๊ทธ์ธ ์ƒํƒœ๋ผ๋Š” ๊ฒƒ์„ ์„œ๋ฒ„์—๊ฒŒ ์•Œ๋ฆผ
    PC ๋ฒ„์ „ ์นดํ†ก or ๋„ค์ดํŠธ์˜จ ๋“ฑ๋“ฑ -> ์ƒํƒœ ์ •๋ณด: active or inactive 
    ํ•œ ์‹œ๊ฐ„ ๋™์•ˆ ์•Œ๋žŒ์„ ๋ฐ›์ง€ ์•Š๊ฒ ๋‹ค ๋“ฑ๋“ฑ ์ด๋Ÿฌํ•œ ์ƒํƒœ๋ฅผ ๋‹ด์•„์„œ ๋ณด๋‚ด๋Š” ๊ฒƒ
  • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ณธ์ธ์˜ ์ •๋ณด๊ฐ€ ๋ฐ”๋€Œ์—ˆ์„ ๊ฒฝ์šฐ -> state update
  • ์ด๋ ‡๊ฒŒ ๋ฐ›์€ ์ƒํƒœ๋ฅผ, ์„œ๋ฒ„๊ฐ€ sub ์• ๋“คํ•œํ…Œ ๋ณด๋‚ด์ฃผ๋Š” ๊ฒƒ
    ๋ˆ„๊ตฌ๋ˆ„๊ตฌ๋Š” ์ง€๊ธˆ ์•กํ‹ฐ๋ธŒํ•˜์ง€ ์•Š์•„ (์ž๋ฆฌ ๋น„์›€ ์ƒํƒœ์•ผ)

 

 

 

ZMQ Dealer-Router pattern

  •  Asynchronous version of REQ-REP pattern
  • N-to-1 architecture where various clients talk to a single server, and do this asynchronously
  • 1-to-N use case where one server talks asynchronously to multiple workers
  • N๊ฐœ ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ์„ 1๊ฐœ์˜ ์„œ๋ฒ„๊ฐ€ ๋ฐ›์œผ๋‹ˆ, ๋ˆ„๊ตฌ์—๊ฒŒ ๋Œ๋ ค์ฃผ์–ด์•ผ ํ•˜๋Š”์ง€ 

 

 

 

Asynchronous version of REQ-REP pattern

 

 

 

  • Asynchronous version of REQ-REP pattern -> ๋‚˜๋„ ์ด ๋ฌธ๊ตฌ๊ฐ€ ๊ฐ€์žฅ ์ž˜ ์ดํ•ด๋œ๋‹ค ! 
    • Clients connect to the server and send requests
    • For each request, the server sends 0 or more replies
    • Clients can send multiple requests without waiting for a reply -> async 
    • Servers can send multiple replies without waiting for new requests -> async 

 

 

 

Asynchronous Client/Server example

 

 

 

Asynchronous Client/Server example

  • ํด๋ผ์ด์–ธํŠธ๋“ค์˜ ์š”์ฒญ์„ ๋ฐ›๋Š” ๊ด€๋ฌธ, load balancer -> ๋ผ์šฐํ„ฐ
  • ์ด ์„œ๋ฒ„๋“ค ์ค‘์— ๋ˆ„๊ฐ€ ์ข€ ๋” stableํ•˜๋ƒ -> ๋ˆ„๊ฐ€ ์„œ๋ฒ„๋ƒ๊ฐ€ ์•„๋‹ˆ๋‹ค, ๋ชจ๋‘ ๋‹ค ์„œ๋ฒ„์ž„! 
  • ๋’ค์— ์žˆ๋Š” ์ผ๊พผ๋“คํ•œํ…Œ ์ „๋‹ฌ
    ์ผ ์—…๋ฌด ๋ถ„๋ฐฐ ํ•˜๊ณ , ๋๋‚˜๋ฉด ์ทจํ•ฉ
    ์›๋ž˜ ์‘๋‹ตํ•œ ์• ๋“คํ•œํ…Œ ๋‹ค์‹œ ์ „๋‹ฌ

 

  • ํ•„์š”ํ•  ๋•Œ ํ•„์š”ํ•œ ๋งŒํผ 
    worker๋ฅผ ๋Š˜๋ฆฌ๊ฑฐ๋‚˜ ์ค„์ด๋Š” ํ–‰์œ„ -> ๊ฐœ๋ฐœ์ž์˜ ๋ชซ
  • multi-threading
  • ์›Œ์ปค๋ฅผ ๋„์šฐ๋Š” ๊ธฐ๋Šฅ์€ ์ง์ ‘ ํ•ด์•ผ ํ•จ
  • zmq๊ฐ€ ํ•ด์ฃผ๋Š” ๊ฑด ํ†ต์‹  ๊ธฐ๋Šฅ์— ๊ตญํ•œํ•œ ๊ฒƒ!
  • application ์˜์—ญ์˜ ์กฐ์ž‘์€ ๊ฐœ๋ฐœ์ž์˜ ๋ชซ 

 

 

 

Dealer-Router pattern with Multi-thread Client

  • Separe send and recv features in a client
  • Enhanced version of lec-05-prg-10-dealer-router- async-client.py
  • Recv feature in a client is impelled as a thread
  • ๋ฆฌ์‹œ๋ธŒ ํ•ธ๋“ค๋Ÿฌ๋ฅผ thread ํ™” 
    zmq -> ํด๋ผ์ด์–ธํŠธ, ์„œ๋ฒ„, ์›Œ์ปค -> ์›Œ์ปค๋ฅผ ์กฐ์ • ๊ฐ€๋Šฅ
    ํด๋ผ์ด์–ธํŠธ๋“ค๋„ fulled flex๋กœ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋งŒ๋“  ๊ฒƒ

 

 

 

Dirty P2P example

  • Self-Healing P2P network with brute-force discovery
  • Just for learning purpose (too heavy)
  • Connect to every IP address in the room
  • If your network segment is 192.168.55.x, for instance, you do this:
    • ์„œ๋ฒ„ ์—†์ด P2P๊ฐ€ ๊ตฌํ˜„๋˜๋ฉด ์–ด๋–ป๊ฒŒ ๋ ๊นŒ?
    • ํ˜„์žฌ ๋„คํŠธ์›Œํฌ์— ์žˆ๋Š” ๋ชจ๋“  ์ปดํ“จํ„ฐ๋ฅผ ๋‹ค ๋ถ™์ด๋Š” ๊ฒƒ 
      255 * 255 ๊ฐœ connection์„ ๋งŒ๋“œ๋Š” ๊ฒƒ -> ๊ฐ ๋…ธํŠธ๋ถ์ด 1: 255
    • ๋‚ด๊ฐ€ ๋ณด๋‚ด๊ณ  ์‹ถ์„ ๋•Œ, ๋ฉ”์„ธ์ง€๋ฅผ 255ํšŒ ์ „์†ก
      ์†Œ์ผ“์„ ๋‚ด ํ”„๋กœ๊ทธ๋žจ ํ˜ผ์ž 255๊ฐœ ์—ถ 
      ์šด์˜์ฒด์ œ๊ฐ€ 255๊ฐœ์˜ ์†Œ์ผ“์„ ๋™์‹œ๋‹ค๋ฐœ์ ์œผ๋กœ ์—ฐ๋‹ค? -> ๋ฉ”๋ชจ๋ฆฌ or ํ”„๋กœ์„ธ์Šค ๋ถ€ํ•˜, ๋‹จ์ˆœ ๋ฌด์‹ํ•œ ๋ฐฉ๋ฒ•
    • WebRTC๋ฅผ ํ™œ์šฉํ•œ p2p ํ†ต์‹  -> ์›น ๋ธŒ๋ผ์šฐ์ € ์œ„์—์„œ ๋Œ์•„๊ฐ€๋Š” API 
    • ์œ ๋ฌด์„  ๊ณต์œ ๊ธฐ๋ฅผ ๋„˜์–ด๊ฐ€๋Š” ์• ๋“ค์€ ๋‹ต์ด ์—†๋Š” ๊ฒƒ 
      -> ์œ ๋ฌด์„  ๊ณต์œ ๊ธฐ๋ฅผ ๋„˜์–ด๊ฐ€๋ ค๋ฉด ํŠธ๋ž˜ํ”ฝ์ด ๋„ˆ๋ฌด ๋งŽ์•„์„œ, ๋„คํŠธ์›Œํฌ ๋ง๊ฐ€์ง
    • 24์‹œ๊ฐ„ ์‚ด์•„์žˆ๋Š” ์„œ๋ฒ„๋Š” ์—†์ง€๋งŒ, 
      255๊ฐœ์˜ peer node์ค‘ ํ•˜๋‚˜๊ฐ€ ์ด๋Œ€ ๋งค๊ณ , ์ž ์‹œ ์„œ๋ฒ„ ๊ธฐ๋Šฅ์„ ๋งก๋Š”๋‹ค. 
      -> ์กฐ์ •ํ•˜๋Š” ์• ๊ฐ€ ํ•˜๋‚˜ ๋œธ -> ์ด ๋…ธ๋“œ์˜ ์ง€ํœ˜ ํ•˜์— ํ†ต์‹ ์ด ์ด๋ฃจ์–ด์ง

 

 

 

  • ํ™œ์„ฑํ™” ๋œ ์„œ๋ฒ„ ์—ญํ• ์„ ํ•˜๋Š” ์• ๊ฐ€ ์žˆ๋Š”์ง€ check
  • ๋น„์ฝ˜ ํ•จ์ˆ˜๋ฅผ ์Šค๋ ˆ๋“œ๋กœ ๋„์›Œ์„œ ๋ณ‘๋ ฌ ์‹œ์ž‘
  • IP์ฃผ์†Œ์™€ ์•„์ด๋””๋ฅผ ํ†ตํ•ด ๋“ฑ๋ก

 

  • ์‚ด์•„์žˆ๋Š” ์„œ๋ฒ„๊ฐ€ ์žˆ์–ด์š”? 
    ์‚ด์•„๋‚˜์„œ 1๋ฒˆ๋ถ€ํ„ฐ 255 ๊นŒ์ง€, ํ˜„์žฌ ์ด ๋„คํŠธ์›Œํฌ ์•ˆ์—, ์„œ๋ฒ„ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ์žˆ๋Š” ์• (๋น„์ฝ˜)๊ฐ€ ์žˆ๋Š”์ง€ ์ฐพ๋Š”๊ฒƒ
    ๋น„์ฝ˜์ด 1์ดˆ ๋‹จ์œ„๋กœ ์ •๋ณด๋ฅผ ๋ฟŒ๋ฆฌ๋‹ˆ๊น, ์ปค๋„ฅ์…˜ํ•˜๊ณ  ๋น„์ฝ˜ ๋ณด๋‚ด๋‹ˆ? -> 2์ดˆ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์•„๋‹ˆ๋ฉด ์—ฐ๊ฒฐ ๋Š๊ณ 
    ๋งŒ์•ฝ์— ๋น„์ฝ˜ ์ •๋ณด๊ฐ€ ์˜ค๋ฉด -> ๋ณธ์ธ์ด ์„œ๋ฒ„ ์—ญํ• ์„ ํ•  ํ•„์š”๊ฐ€ X
    ๋น„์ฝ˜ ์—ญํ• ์ด ์•„๋ฌด๋„ ์—†๋‹ค๋ฉด -> ์„œ๋ฒ„๊ฐ€ ์—†๋‹ค -> ๋ณธ์ธ์ด ์„œ๋ฒ„๊ฐ€ ๋˜์–ด์•ผ ํ•œ๋‹ค.  

 

  • ๋ˆ„๊ตฐ๊ฐ€ ์ด๋Œ€๋ฅผ ๋งค๋Š” ๊ฒฝ์šฐ
    ์„œ๋ฒ„ ๊ธฐ๋Šฅ์„ ๋„์šฐ๋Š” ๋ฐ, ํ•„์ˆ˜์ ์ธ ๊ธฐ๋Šฅ์„ ๋ช‡ ๊ฐœ ๋งŒ๋“ฆ
  • beacon - ์ฃผ๊ธฐ์ ์œผ๋กœ ์ฃผ๊ณ  ๋ฐ›๋Š” ์ •๋ณด๋ฅผ ๋น„์ฝ˜์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. 
    256๊ฐœ์˜ ๋…ธ๋“œ ์ค‘, ๋ˆ„๊ตฐ๊ฐ€ ์ด๋Œ€๋ฅผ ๋งค๊ณ , ๋ณธ์ธ์ด ์„œ๋ฒ„ ์—ญํ• ์„ ํ•ด์ฃผ๊ธฐ๋กœ ํ–ˆ๋‹ค๋ฉด
    ๋‹ค๋ฅธ ์• ๋“ค์€ ๋ชจ๋ฅด๋‹ˆ๊นŒ, ๋‚ด๊ฐ€ ์ž„์‹œ ์„œ๋ฒ„ ์—ญํ• ์„ ํ•ด์ค„๊ฒŒ! ์ด๋Ÿฐ ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ๊ฒƒ 
    temperalํ•œ server๊ฐ€ activate ๋˜์—ˆ๋Š”๋ฐ, ๊ทธ๊ฒŒ ๋‚˜์•ผ! ๋ฟŒ๋ฆฌ๋Š” ๊ฒƒ 
  • 1์ดˆ ์‰ฌ๊ณ , ๋ฉ”์„ธ์ง€๋กœ ip ์ฃผ์†Œ ๋ณด๋‚ด์คŒ

 

  • ์—ฐ๊ฒฐ ๋˜๋Š”์ง€ ํ™•์ธ -> ์ƒ๋Œ€๋ฐฉ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด, ๋“ฑ๋ก ์„œ๋ฒ„ ํ•„์š”
    ์ด ๋„คํŠธ์›Œํฌ ์•ˆ์— ์‚ด์•„์žˆ๋Š” peer node๋“ค์ด ๋ˆ„๊ตฌ์ธ์ง€ ์•Œ์•„์•ผ์ง€  
    p2p node๊ฐ€ ์‚ด์•„๋‚˜๋ฉด, ๋น„์ฝ˜(์„œ๋ฒ„) ํ™•์ธ, ๋‚˜๋Š” ๋ˆ„๊ตฌ์ธ์ง€ ์„œ๋ฒ„์—๊ฒŒ ๋“ฑ๋ก
  • ์„œ๋ฒ„ ๊ธฐ๋Šฅ์„ ํ•˜๋Š” ์• ๋Š” reply (reply request pattern์œผ๋กœ ๊ตฌํ˜„๋จ)
  • user manager
    Node๊ฐ€ ์‚ด์•„๋‚ฌ์„ ๋•Œ, ์–˜ํ•œํ…Œ(์ž„์‹œ ์„œ๋ฒ„)ํ•œํ…Œ ํด๋ผ์ด์–ธํŠธ id, ip address ์ฃผ๋Š” ๊ฒƒ
    ์ฆ‰, user ๋“ฑ๋ก์„ ํ•˜๋Š” ๊ณผ์ •๊ณผ ๋งค์„ธ์ง€ ๋ณด๋‚ด๋Š” ๊ธฐ๋Šฅ์„ ๋ถ„๋ฆฌํ•จ!

 

  • ๋ชจ๋‘ ์„œ๋ฒ„์— ๋ถ™์—ˆ๋‹ค (๋ˆ„๊ฐ€ ์„œ๋ฒ„์ธ์ง€ ์•Œ๊ณ , ๋ณธ์ธ์˜ ์ •๋ณด๋ฅผ ๋“ฑ๋กํ–ˆ์œผ๋‹ˆ)
    ์„œ๋ฒ„๋ฅผ ํ†ตํ•ด ๋ฉ”์„ธ์ง€๋ฅผ ์ฃผ๊ณ  ๋ฐ›์œผ๋ฉด ๋œ๋‹ค. 
  • pub ํ˜•ํƒœ๋กœ ๋ฟŒ๋ฆฌ๊ณ , pull๋กœ ๊ฐ€์ ธ์˜ด
  • ๋ฉ”์„ธ์ง€ ๋ฐ›๊ณ , ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๊ณ , ํ†ต์‹  ์•ˆ์— ์žˆ๋Š” ์• ๋“คํ•œํ…Œ ๋ฟŒ๋ฆผ (-> ๋ฐฉ์†ก์„ ํ•จ) -> ๋ฌดํ•œ ๋ฐ˜๋ณต
  • ์ผ๋ฐ˜์ ์ธ ์ฑ„ํŒ… ํ”„๋กœ๊ทธ๋žจ๊ณผ ์œ ์‚ฌํ•˜๊ฒŒ p2p๋„ ๊ตฌํ˜„๋จ 
    24์‹œ๊ฐ„ ์‚ด์•„์žˆ๋Š” ์• ๊ฐ€ ์„œ๋ฒ„๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด, ์ด๋ฒˆ์—๋Š” ๋น„์ฝ˜ ๊ธฐ๋Šฅ

 

  •  ๊ฐœ์„ ํ•  ์ 
    • ๊ฐ€์ž…์ž ๊ด€๋ฆฌ - ์ €๋Ÿฐ ๋ฐฉ์‹์œผ๋กœ ๋ฟŒ๋ฆฌ๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์˜๋ฏธ ์žˆ๋Š” ์• ๋“ค๋ผ๋ฆฌ ๋ฌถ์–ด์„œ ํ†ต์‹ ํ•˜์ž
    • ๊ฐ€์ž…์ž ๊ด€๋ฆฌ์ž ์ฐพ๋Š” ๋ฐฉ๋ฒ•
    • ์†Œ์ผ“ ๋“ฑ ์ž์› ์‚ฌ์šฉ์˜ ํšจ์œจํ™”
    • Python์™ธ ์–ธ์–ด๋ฅผ ํ†ตํ•œ ์‹ค์ œ ๋ชจ๋ฐ”์ผ ์•ฑ ๊ฐœ๋ฐœ

 

 

 

  • codon python
    • ์ƒˆ๋กœ์šด ์„ฑ๋Šฅ์ด ์ข‹์€ ํŒŒ์ด์ฌ compiler
    • cpython -> native machine code 
    • virtual machine ์ด ์•„๋‹ˆ๋ผ, mac ๋„ค์ดํ‹ฐ๋ธŒ๋กœ
    • ๋จธ์‹ ๋Ÿฌ๋‹, ์ฒœ์ฒด๋ฌผ๋ฆฌ ๋“ฑ๋“ฑ ๋ณต์žกํ•œ ๊ณ„์‚ฐ์„ ํ•œ๋‹ค๋ฉด ์ถ”์ฒœ