Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

m-lab/ndt-server 技术分析

项目背景与痛点

m-lab/ndt-server 是一个基于 Docker 的 NDT5 和 NDT7 服务器实现,不仅能提供网络测量服务,还集成了 Prometheus 监控支持。Nuttcp 数据传输工具(NDT)是用于测量网络带宽、时延和丢包率的标准工具。该项目主要解决在易于部署和监控的微服务架构中实现高性能网络测量的问题。它通过提供一个容器化的解决方案,解决了传统NDT服务器复杂部署与集成难度的问题。

核心技术揭秘

技术架构

该项目的实现采用了现代化的技术栈,包括 Docker 和监控工具 Prometheus,数据流简要设计如下:

graph TD A[客户端发起测试请求] --> B[路由到 ndt-server] B --> C[校验测试参数] C -->|"参数有效"| D[启动 TCP/UDP 会话] C -->|"参数无效"| E[返回错误] D --> F{"Nuttcp 处理数据传输测试"} F -->|"NDT5/NDT7 测试结束"| G[存储测试结果] G --> H[返回结果] G --> I[Prometheus 监控数据]

核心算法

该项目的核心在于提供高效的数据传输测试。它使用两种实现协议,NDT5 和 NDT7。其中 ND7 是一种升级版协议,速度快,同时能够提供更详细的测量数据。测试流程包括初始化 TCP 或 UDP 连接,发送和接收数据包,以及记录性能指标。

数据流控制

在项目实现中,数据流主要由 Nuttcp 负责控制。客户端根据请求类型启动相应的数据传输测试,服务器端通过 Nuttcp 进行处理,并实时监控性能指标。

功能亮点与差异

相比一些其他第三方实现,m-lab/ndt-server 通过利用 Docker 提供了极佳的可移植性和简单部署,同时也集成了 Promethus 监控服务来提升运维效率。这些功能提升了部署、管理和监控测试服务的效率,并且更重要的是,流畅的用户交互和性能分析使得这个工具处于同类产品中的领先地位。

应用场景与落地建议

在生产环境中使用 m-lab/ndt-server,我们推荐用户基于 Docker 进行部署,这样可以更方便进行横向扩展,也方便进行灰度发布。此外,对于监控需求较高的生产环境,可以通过 Prometheus 模块进行实时监控性能指标。

适用场景

  1. 网络服务供应商:用于提供给用户实时的网络性能测试服务。
  2. 研究机构:研究网络优化与性能参数。

综合评价

优点

  • 基于 Docker 的标准化输出,易于部署和管理。
  • 集成 Prometheus,异步监控,数据流设计优化,提供全方位性能指标监控。
  • 利用 NDT7 协议提升性能测试速度与质量。

缺点

  • 项目依赖 Nuttcp 等工具提供服务支持,不如自实现的工具拥有更高的项目可控制性。
  • 限制了部分极端个性化定制需求的探索性。

通过本次分析,我们可以看到 m-lab/ndt-server 以其稳健性、灵活性和集成度为特点,不失为一个值得企业级用户深入利用的网络性能测试工具。

关于

GitHub 原始描述(英文)

docker native ndt5 and ndt7 server with prometheus integration

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
247
价值分
93
活跃状态
活跃

语言占比

CSS
Dockerfile
Go
HTML
JavaScript
Shell

Release

README

GoDoc CI Coverage Status Go Report Card

ndt-server

This repository contains a ndt5 and ndt7 server written in Go. This code may compile under many systems, including macOS and Windows, but is specifically designed and tested for running on Linux 4.19+.

Clients

Depending on your needs, there are several ways to perform a client measurement using the NDT7 protocol.

Officially supported by members of M-Lab staff.

Unofficially supported by members of the M-Lab community.

Setup

Primary setup & running (Linux)

Prepare the runtime environment

install -d certs datadir

To run the server locally, generate local self signed certificates (key.pem and cert.pem) using bash and OpenSSL

./gen_local_test_certs.bash

build the docker container for ndt-server

docker build . -t ndt-server

enable BBR (with which ndt7 works much better)

sudo modprobe tcp_bbr

and run the ndt-server binary container

docker run --network=bridge                \
           --publish 443:4443              \
           --publish 80:8080               \
           --volume `pwd`/certs:/certs:ro  \
           --volume `pwd`/datadir:/datadir \
           --read-only                     \
           --user `id -u`:`id -g`          \
           --cap-drop=all                  \
           ndt-server                      \
           -cert /certs/cert.pem           \
           -key /certs/key.pem             \
           -datadir /datadir               \
           -ndt7_addr :4443                \
           -ndt7_addr_cleartext :8080

Alternate setup & running (Windows & MacOS)

These instructions assume you have Docker for Windows/Mac installed.

Note: NDT5 does not work on Docker for Windows/Mac as it requires using the host’s network, which is only supported on Linux

docker-compose run ndt-server ./gen_local_test_certs.bash
docker-compose up

After making changes you will have to run docker-compose up --build to rebuild the ntd-server binary.

Accessing the service

Once you have done that, you should have a ndt5 server running on ports 3001 (legacy binary flavour), 3002 (WebSocket flavour), and 3010 (secure WebSocket flavour); a ndt7 server running on port 443 (over TLS and using the ndt7 WebSocket protocol); and Prometheus metrics available on port 9990.

Try accessing these URLs in your browser (for URLs using HTTPS, certs will appear invalid to your browser, but everything is safe because this is a test deployment, hence you should ignore this warning and continue):

Replace localhost with the IP of the server to access them externally.

评论

暂无评论