Bandwidth
Bandwidth
The maximum amount of data a network can transmit. Measured in Mbps and Gbps.
Bandwidth
The maximum amount of data a network can transmit. Measured in Mbps and Gbps.
Bandwidth is the maximum amount of data that a network connection can transmit over a given period of time. It is often compared to the "number of lanes on a highway." The more lanes there are (the greater the bandwidth), the more vehicles (data) can pass through at the same time. The units used are bps (bits per second), Mbps (Megabits per second), and Gbps (Gigabits per second).
A concept often confused with bandwidth is throughput. If bandwidth is the "theoretical maximum transmission capacity," throughput is the "amount of data actually transmitted." Even on a 100Mbps line, actual throughput is typically around 70–80Mbps due to network congestion, packet loss, protocol overhead, and so on. Think of bandwidth as the thickness of a pipe and throughput as the amount of water actually flowing through it.
A network bottleneck is a phenomenon in which the bandwidth of the entire system is determined by the limited bandwidth of a particular segment. For example, even if there is a 1Gbps server and a 1Gbps client, if the router in between supports only 100Mbps, the overall transmission speed is limited to 100Mbps. The key to network optimization is finding and resolving such bottleneck segments.
Bandwidth monitoring is essential in modern cloud environments. Bandwidth usage is tracked in real time through AWS CloudWatch, Grafana, Prometheus, and the like, and bottlenecks are detected early. Especially in AI/ML workloads, bandwidth becomes a key factor in performance for large dataset transfers, GPU-to-GPU communication during distributed training, and so on.
| Category | Bandwidth | Throughput |
|---|---|---|
| Definition | Theoretical maximum transmission capacity | Amount of data actually transmitted |
| Analogy | Thickness of a pipe / number of highway lanes | Amount of water actually flowing / number of vehicles passing through |
| When Measured | Fixed value at network design time | Fluctuates in real time |
| Influencing Factors | Physical line, equipment specifications | Congestion, packet loss, latency, protocol overhead |
| Example | 1Gbps Ethernet line | Actual transmission speed of 850Mbps |
import psutil
import time
import speedtest # pip install speedtest-cli
# 실시간 네트워크 대역폭 모니터링
def monitor_bandwidth(interval=1):
"""초당 네트워크 사용량 모니터링"""
old_value = psutil.net_io_counters()
while True:
time.sleep(interval)
new_value = psutil.net_io_counters()
# 초당 전송량 계산 (bytes → Mbps)
sent_mbps = (new_value.bytes_sent - old_value.bytes_sent) * 8 / 1_000_000
recv_mbps = (new_value.bytes_recv - old_value.bytes_recv) * 8 / 1_000_000
print(f"↑ Upload: {sent_mbps:.2f} Mbps | ↓ Download: {recv_mbps:.2f} Mbps")
old_value = new_value
# 인터넷 속도 테스트 (대역폭 측정)
def test_bandwidth():
"""speedtest.net으로 실제 대역폭 측정"""
st = speedtest.Speedtest()
st.get_best_server()
download_speed = st.download() / 1_000_000 # Mbps
upload_speed = st.upload() / 1_000_000 # Mbps
ping = st.results.ping
print(f"Download: {download_speed:.2f} Mbps")
print(f"Upload: {upload_speed:.2f} Mbps")
print(f"Ping: {ping:.2f} ms")
return download_speed, upload_speed
# 대역폭 단위 변환
def convert_bandwidth(value, from_unit, to_unit):
"""대역폭 단위 변환 (bps, Kbps, Mbps, Gbps)"""
units = {'bps': 1, 'Kbps': 1e3, 'Mbps': 1e6, 'Gbps': 1e9}
bps = value * units[from_unit]
return bps / units[to_unit]
# 사용 예시
print(f"1 Gbps = {convert_bandwidth(1, 'Gbps', 'Mbps')} Mbps")
print(f"100 Mbps = {convert_bandwidth(100, 'Mbps', 'Kbps')} Kbps")
# iperf3 - 네트워크 대역폭 측정 (서버-클라이언트)
# 서버 측에서 실행
iperf3 -s
# 클라이언트에서 테스트
iperf3 -c 192.168.1.100 # TCP 테스트 (기본)
iperf3 -c 192.168.1.100 -u -b 1G # UDP 1Gbps 테스트
iperf3 -c 192.168.1.100 -P 4 # 4개 병렬 스트림
iperf3 -c 192.168.1.100 -R # 역방향 테스트 (다운로드)
# speedtest-cli - 인터넷 속도 테스트
speedtest-cli
speedtest-cli --simple # 간단 출력
speedtest-cli --json # JSON 형식 출력
# nload - 실시간 대역폭 모니터링
nload eth0 # 특정 인터페이스 모니터링
# vnstat - 대역폭 사용량 통계
vnstat # 일별 통계
vnstat -h # 시간별 통계
vnstat -l # 실시간 모니터링
# iftop - 연결별 대역폭 사용량
sudo iftop -i eth0 # 인터페이스별 트래픽 확인
# 네트워크 인터페이스 대역폭 확인
ethtool eth0 | grep Speed # 링크 속도 확인
cat /sys/class/net/eth0/speed # 현재 대역폭 (Mbps)
# tc (traffic control) - 대역폭 제한 테스트
# 대역폭을 1Mbps로 제한
sudo tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
# 제한 해제
sudo tc qdisc del dev eth0 root
// 브라우저에서 대역폭 측정 (Network Information API)
if ('connection' in navigator) {
const conn = navigator.connection;
console.log(`예상 대역폭: ${conn.downlink} Mbps`);
console.log(`연결 타입: ${conn.effectiveType}`); // 4g, 3g, 2g, slow-2g
console.log(`RTT: ${conn.rtt} ms`);
// 연결 변경 감지
conn.addEventListener('change', () => {
console.log(`대역폭 변경: ${conn.downlink} Mbps`);
});
}
// 파일 다운로드로 실제 대역폭 측정
async function measureBandwidth(testUrl, fileSizeBytes) {
const startTime = performance.now();
const response = await fetch(testUrl, { cache: 'no-store' });
await response.blob();
const endTime = performance.now();
const durationSeconds = (endTime - startTime) / 1000;
// bits per second → Mbps
const bps = (fileSizeBytes * 8) / durationSeconds;
const mbps = bps / 1_000_000;
console.log(`측정된 대역폭: ${mbps.toFixed(2)} Mbps`);
return mbps;
}
// Node.js - 서버 대역폭 모니터링
const os = require('os');
function getNetworkStats() {
const interfaces = os.networkInterfaces();
const stats = {};
for (const [name, addrs] of Object.entries(interfaces)) {
stats[name] = addrs.filter(a => a.family === 'IPv4');
}
return stats;
}
// 데이터 전송량 단위 변환
function formatBandwidth(bps) {
if (bps >= 1e9) return `${(bps / 1e9).toFixed(2)} Gbps`;
if (bps >= 1e6) return `${(bps / 1e6).toFixed(2)} Mbps`;
if (bps >= 1e3) return `${(bps / 1e3).toFixed(2)} Kbps`;
return `${bps.toFixed(2)} bps`;
}
console.log(formatBandwidth(1500000000)); // 1.50 Gbps
"We're seeing database replication delays, and it looks like network bandwidth is the bottleneck. It's currently a 1Gbps line, and the actual throughput is close to 900Mbps. We should consider upgrading to 10Gbps or compressing the replication data before transmitting it."
"GPU-to-GPU communication in an AI training cluster requires at least 25Gbps of bandwidth. With regular Ethernet, the bandwidth bottleneck during distributed training drops GPU utilization to 50% or below. We should consider InfiniBand or a 100Gbps NIC."
"To explain the difference between bandwidth and throughput, bandwidth is the theoretical maximum and throughput is the actual amount transmitted. For example, even on a 1Gbps line, an actual throughput of around 940Mbps is realistic due to TCP overhead, congestion control, packet loss, and so on. When monitoring, consider expanding capacity once bandwidth utilization exceeds 80%."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Mbps (Megabits per second) and MBps (MegaBytes per second) differ by a factor of 8. The actual download speed of a 100Mbps line is about 12.5MB/s. ISPs use Mbps while file transfers use MBps, so be careful.
Even if bandwidth is sufficient, perceived performance is poor when latency is high. Especially for real-time services (games, video conferencing), latency matters more than bandwidth. Both must be monitored.
Even if average bandwidth utilization is 30%, services are delayed if it reaches 100% during peak hours. Secure headroom by taking burst traffic into account, and plan capacity based on the 95th percentile.
Set up warning alerts when bandwidth utilization reaches 80% or higher. Monitor in real time with Prometheus + Grafana. Assign priority to critical traffic with QoS (Quality of Service). Regularly test actual throughput with tools such as iperf3.