1. 程式人生 > >網路程式設計實踐陳碩筆記零

網路程式設計實踐陳碩筆記零

1、理查德森的unix網路程式設計有兩樣不足:一訊息格式處理,特別是非阻塞IO上處理TCP分包問題;二是併發模型稍顯陳舊,傳統高併發採用事件驅動加非阻塞IO方式。

2、程式設計師面對的網路術語

Ethernet        frame(幀)

IP                  packet(分組)

TCP              segment(分節)

Application    message(訊息)

3、TCP協議棧開銷不大,在千兆乙太網(1Gbit/s=120MB/s)的頻寬中,TCP的有效頻寬118MB/s(112MiB/s)(dd命令測試)

本機測試:


4、課程安排,講解網路程式設計的例子

a、non-concurrent exapmples  基本的非並行阻塞式網路程式設計

TTCP

Round-trip  (clockerror between two hosts)UDP

NetCat

slow source 慢發,從應用層模擬網速慢的情景,特別在非阻塞時能否應對接受慢

b、concurrent examples  非阻塞式的並行網路程式設計

SOCKS proxy server (relay two TCP connections)request-response

Sudoku solver

Simple memecached

Broadcasting to multiple TCP peers (how to deal with slow receiver?)

c、Data processing with multiple machines 使用多臺機器並行處理資料

(現在流行使用hadoop、Spark執行緒分散式計算框架來做)

Parallel N-queues 例子經典的N皇后問題

Median of numbers across machines 多機求解中值

frequent queries 多級找出最頻繁的問題

Distributed sorting 分散式排序

d、advanced topics 高階話題

RPC

load balancing 

capacity of a serving system  (QPS)

Fight for latency 延遲時間