Seastar

发布时间:2025-05-09 10:02

HomePage Blog List HomePage Practical Opensource Developer Languages & framework C/C++ Seastar

高性能服务器端应用程序框架。(High performance server-side application framework)

Owner: scylladb/seastar Platform: Docker, Linux, OSv License:: Apache License 2.0 Category:: Topic: Introduction Main metrics Readme projecs by owner(3)

Seastar(海星)

介绍

SeaStar 是一个事件驱动的框架,允许您以相对直接的方式(一旦理解)编写非阻塞的异步代码。它基于 futures。

Seastar 构建

有关更多详细信息和可选工作流程,请阅读 HACKING.md。

假设您想使用系统软件包(RPM 或 DEB)作为 Seastar 的依赖项,请首先安装它们:

$ sudo ./install-dependencies.sh

然后配置(在"release"模式下):

$ ./configure.py --mode=release

然后编译:

$ ninja -C build/release

如果您缺少 Seastar 的依赖项,则可以让配置过程在本地获取依赖项的版本以进行开发。

例如,要在本地获取 fmt,请按以下方式配置 Seastar:

$ ./configure.py --mode=dev --cook fmt

--cook 可以重复多次以选择多个依赖项。

构建模式

configure.p y脚本是 cmake 的包装。 --mode 参数映射到 CMAKE_BUILD_TYPE,并支持以下模式

| CMake mode | Debug info | Optimizations | Sanitizers | Allocator | Checks | Use for |

---------+-------------------+------------+----------------+--------------+-----------+----------+----------------------------------------| debug | Debug | Yes | -O0 | ASAN, UBSAN | System | All | gdb | release | RelWithDebInfo | Yes | -O3 | None | Seastar | Asserts | production | dev | Dev (Custom) | No | -O1 | None | Seastar | Asserts | build and test cycle | sanitize | Sanitize (Custom) | Yes | -Os | ASAN, UBSAN | System | All | second level of tests, track down bugs |

注意,seastar 对分配器和优化比平常更加敏感。有关性能的一个简单经验法则是,release 比 dev 快 2 倍,比 sanitize 快 150 倍,比 debug 快 300 倍。

从其构建目录使用 Seastar(无需安装)

可以使用 CMake 或 pkg-config 从其构建目录直接使用 Seastar。

我们假设 Seastar 存储库位于 $seastar_dir 的目录中。

通过 pkg-config:

$ g++ my_app.cc $(pkg-config --libs --cflags --static $seastar_dir/build/release/seastar.pc) -o my_app

以及使用 Seastar 软件包的 CMake:

my_app 的 CMakeLists.txt:

find_package (Seastar REQUIRED) add_executable (my_app my_app.cc) target_link_libraries (my_app Seastar::seastar)

$ mkdir $my_app_dir/build $ cd $my_app_dir/build $ cmake -DCMAKE_PREFIX_PATH="$seastar_dir/build/release;$seastar_dir/build/release/_cooking/installed" -DCMAKE_MODULE_PATH=$seastar_dir/cmake $my_app_dir

CMAKE_PREFIX_PATH 值可确保 CMake 可以定位 Seastar 及其编译的子模块。 CMAKE_MODULE_PATH 值可确保 CMake 可以使用 Seastar 的 CMake 脚本来查找其依赖项。

使用已安装的 Seastar

您也可以在将 Seastar 安装到文件系统后使用它。

重要:

Seastar 使用自定义版本的DPDK,因此默认情况下会构建DPDK子模块并将其安装到 $build_dir/_cooking/installed

首先,配置安装路径:

$ ./configure.py --mode=release --prefix=/usr/local

然后运行安装目标:

$ ninja -C build/release install

然后从 pkg-config 中使用它:

$ g++ my_app.cc $(pkg-config --libs --cflags --static seastar) -o my_app

或者使用与之前相同的 CMakeLists.txt,但使用更简单的 CMake 调用来使用它 :

$ cmake ..

(如果尚未将 Seastar 安装到 /usr 或 /usr/local 这样的“标准”位置,则可以使用 -DCMAKE_PREFIX_PATH=$my_install_root 调用 CMake。)

还有在任何支持 Docker 的主机上进行构建的说明。

DPDK 的使用是 可选的。

Seastar 的 C++ 方言:C++ 17 或 C++ 20

Seastar 支持 C++ 17 和 C++ 20。 可以使用 --c++-dialect=gnu++17 配置选项来选择它,或者,如果直接使用 CMake,则可以通过在 Seastar_CXX_DIALECT CMake 变量上进行设置来选择它。

有关更多信息,请参见兼容性声明。

入门

有一个迷你教程,一个更全面的教程。

该文档可从 web 上获得。

资源

在开发邮件列表中提出问题并发布补丁。订阅信息和档案可以在这里找到,或者发送电子邮件到[email protected]

信息可以在主项目网站上找到。

在项目问题跟踪器上记录错误报告。

本机 TCP/IP 堆栈

Seastar 带有自己的用户空间 TCP/IP 堆栈,以提高性能。

SeaStar的推荐硬件配置

CPU -- 随您所需。 SeaStar 对多核和 NUMA 非常友好。网卡 -- 尽可能快,我们建议使用 10G 或 40G 卡。也可以使用 1G,但可能会受到容量的限制。此外,每个 cpu 的硬件队列越多,对 SeaStar 越好。否则,我们必须在软件中进行仿真。磁盘 -- 具有高 IOPS 数量的快速 SSD。客户端计算机 -- 通常一台客户端计算机无法加载我们的服务器。 memaslap(memcached)和 WRK(httpd)都不能过载其匹配的服务器计数器部分。我们建议在不同的机器上运行客户机,而不是在服务器上运行,并使用多个服务器。

使用Seastar的项目

cpv-cql-driver:基于 seastar 框架的 Cassandra/Scylla C++ 驱动程序cpv-framework:一个基于 c++ 的基于 seastar 框架的 Web 框架redpanda:关键任务系统的 Kafka 替代品Scylla:与 Cassandra 和 DynamoDB 兼容的快速可靠的 NoSQL 数据存储smf:西方最快的RPC

(The first version translated by vz on 2020.07.04)

Main metrics Overview Name With Ownerscylladb/seastar Primary LanguageC++ Program languageC++ (Language Count: 6) PlatformDocker, Linux, OSv License:Apache License 2.0 所有者活动 Created At2014-08-18 07:01:07 Pushed At2025-05-07 11:16:19 Last Commit At2025-05-07 14:16:12 Release Count5 Last Release Nameseastar-22.11.0 (Posted on ) First Release Nameseastar-17.05.0 (Posted on ) 用户参与 Stargazers Count8.7k Watchers Count394 Fork Count1.6k Commits Count9k Has Issues Enabled Issues Count1298 Issue Open Count436 Pull Requests Count625 Pull Requests Open Count109 Pull Requests Close Count726 项目设置 Has Wiki Enabled Is Archived Is Fork Is Locked Is Mirror Is Private

Seastar


Version

Introduction

SeaStar is an event-driven framework allowing you to write non-blocking,
asynchronous code in a relatively straightforward manner (once understood).
It is based on futures.

Building Seastar

For more details and alternative work-flows, read HACKING.md.

Assuming that you would like to use system packages (RPMs or DEBs) for Seastar's dependencies, first install them:

$ sudo ./install-dependencies.sh

then configure (in "release" mode):

$ ./configure.py --mode=release

then compile:

$ ninja -C build/release

If you're missing a dependency of Seastar, then it is possible to have the configuration process fetch a version of the dependency locally for development.

For example, to fetch fmt locally, configure Seastar like this:

$ ./configure.py --mode=dev --cook fmt

--cook can be repeated many times for selecting multiple dependencies.

Build modes

The configure.py script is a wrapper around cmake. The --mode argument
maps to CMAKE_BUILD_TYPE, and supports the following modes

  961

Go

gocqlx

General purpose extensions to Go Cassandra driver - gocql

Go

go-set

Type-safe, zero-allocation sets for Go

系统和服务监控系统

Scylla监控栈

用 Grafana 对 Scylla 进行简单监控。「Simple monitoring of Scylla with ...

网址:Seastar http://c.mxgxt.com/news/view/1077387

相关内容

Linux内核与DPDK
「SEA STAR品牌」SEA STAR是哪个国家的品牌

随便看看