Vix は、次世代の オフラインファースト・ピアツーピア・超高速 C++ モダンランタイムです。
目標は明確です。
Node / Deno / Bun のようなアプリを実行でき、 しかも不安定で低品質な「現実世界のネットワーク」を前提に設計されたランタイム
Vix は単なるバックエンドフレームワークではありません。 これは モジュラー構成のランタイムであり、分散アプリケーション、エッジシステム、オフラインデバイス、そして従来のクラウド前提フレームワークが機能しない環境向けに設計されています。
FastAPI, Vue.js, React、最新のランタイムに着想を得つつ、 C++20 によってゼロから再設計され、圧倒的な速度と完全な制御性を実現しています。
すべてのベンチマークは wrk を使用して実行されました。 八スレッド / 八百接続 / 三十秒、同一マシンで測定しています。
環境 Ubuntu 二十四点〇四 — Intel Xeon — C++20 最適化ビルド — ログ無効
結果は "OK" を返すシンプルなエンドポイントでの 定常状態スループットです。
| フレームワーク | Requests/sec | 平均レイテンシ | 転送量/秒 |
|---|---|---|---|
| ⭐ Vix.cpp (v 一・一二・三) | 約 九万八千九百四十二(CPU 固定) | 七・三〜一〇・八 ms | 約 一三・八 MB/s |
| Vix.cpp(通常実行) | 八万一千三百 | 九・七〜一〇・八 ms | 約 一一・三 MB/s |
| Go(Fiber) | 八万一千三百三十六 | 〇・六七 ms | 一〇・一六 MB/s |
| Deno | 約 四万八千八百六十八 | 一六・三四 ms | 約 六・九九 MB/s |
| Node.js(Fastify) | 四千二百二十 | 一六・〇〇 ms | 〇・九七 MB/s |
| PHP(Slim) | 二千八百四 | 一六・八七 ms | 〇・四九 MB/s |
| Crow(C++) | 一千百四十九 | 四一・六〇 ms | 〇・三五 MB/s |
| FastAPI(Python) | 七百五十二 | 六三・七一 ms | 〇・一一 MB/s |
🔥 新記録 単一コアに固定(
taskset -c 2)した場合、 約 九万九千 req/s に到達し、Go を上回り、最速クラスの C++ マイクロフレームワークに並びました。
- ゼロコスト抽象化
- HTTP ワークロード向けに最適化された独自 ThreadPool
- 最適化された HTTP パイプライン
- 高速パスルーティング
- Beast ベースの I/O
- 最小限のメモリアロケーション
- 予測可能なスレッドモデル
wrk -t8 -c800 -d30s --latency http://127.0.0.1:8000
Requests/sec: 48,868.73Vix.cpp リポジトリ内(ビルトイン例を使用)でベンチマークを行う場合:
cd ~/vixcpp/vix
export VIX_LOG_LEVEL=critical
export VIX_LOG_ASYNC=false
# 最適化されたサンプルサーバーを起動
vix run example main次に、別のターミナルで実行します:
wrk -t8 -c800 -d30s --latency http://127.0.0.1:8080/benchより安定した結果を得たい場合は、CPU コアを固定してください:
taskset -c 2 ./build/main
wrk -t8 -c800 -d30s --latency http://127.0.0.1:8080/bench✔ Fast-path ルーティングにより 1〜3% の性能向上 ✔ /fastbench を使用すると RequestHandler のオーバーヘッドを回避できます
#include <vix.hpp>
using namespace vix;
int main() {
App app;
app.get("/", [](auto&, auto& res) {
res.json({ "message", "Hello world" });
});
app.run(8080);
}QueryBuilder qb;
qb.raw("UPDATE users SET age=? WHERE email=?")
.param(29)
.param("zoe@example.com");この例は 完全に動作する最小の HTTP + WebSocket ハイブリッドサーバーを示しています。
- 基本的な GET ルート
- シンプルな WebSocket 接続処理
- サーバーの自動起動
#include <vix.hpp>
#include <vix/websocket/AttachedRuntime.hpp>
using namespace vix;
int main()
{
// Use default config path "config/config.json" and port 8080
vix::serve_http_and_ws([](auto &app, auto &ws)
{
// Minimal HTTP route
app.get("/", [](auto&, auto& res) {
res.json({
"message", "Hello from Vix.cpp minimal example 👋",
"framework", "Vix.cpp"
});
});
// Minimal WebSocket handler: log and echo chat.message
ws.on_typed_message(
[&ws](auto& session,
const std::string& type,
const vix::json::kvs& payload)
{
(void)session;
if (type == "chat.message") {
ws.broadcast_json("chat.message", payload);
}
}); });
return 0;
}auto client = Client::create("localhost", "9090", "/");
client->on_open([] {
std::cout << "Connected!" << std::endl;
});
client->send("chat.message", {"text", "Hello world!"});app.get("/", [](Request req, Response res) {
return json::o("message", "Hello from Vix");
});app.get("/users/{id}", [](Request req, Response res) {
auto id = req.param("id");
return json::o("user_id", id);
});app.get("/search", [](Request req, Response res) {
auto q = req.query_value("q", "none");
auto page = req.query_value("page", "1");
return json::o(
"query", q,
"page", page
);
});app.get("/missing", [](Request req, Response res) {
res.status(404).json({"error", "Not found"});
});app.get("/go", [](Request req, Response res) {
res.redirect("https://vixcpp.com");
});app.get("/forbidden", [](Request req, Response res) {
res.status(403).send();
});app.post("/echo", [](Request req, Response res) {
return json::o(
"received", req.json()
);
});struct UserInput {
std::string name;
int age;
};
app.post("/users", [](Request req, Response res) {
UserInput input = req.json_as<UserInput>();
return std::pair{
201,
json::o(
"name", input.name,
"age", input.age
)
};
});app.get("/headers", [](Request req, Response res) {
res.header("X-App", "Vix")
.type("text/plain")
.send("Hello headers");
});app.get("/state", [](Request req, Response res) {
req.set_state<int>(42);
return json::o(
"value", req.state<int>()
);
});app.get("/manual", [](Request req, Response res) {
res.status(200)
.json(json::o("ok", true));
});app.get("/items/{id}", [](Request req, Response res) {
const auto& params = req.params();
return json::o("id", params.at("id"));
});app.delete("/items/{id}", [](Request req, Response res) {
res.status(204).send();
});クラウドファーストなフレームワークは次を前提としています。
- 安定したネットワーク
- 予測可能なレイテンシ
- 常時オンライン接続
しかし、世界の多くの環境ではそれは現実ではありません。
Vix は次のために設計されています。
インターネットがなくてもアプリは動作し続けます。
中央サーバーなしで、ノード同士がローカル同期・通信可能。
C++20 + Asio + ゼロオーバーヘッド抽象化。
- 🌍 オフラインファーストランタイム
- 🔗 P2P 対応通信モデル
- ⚙️ 非同期 HTTP サーバー
- 🧭 表現力の高いルーティング
- 💾 MySQL / SQLite 用 ORM
- 🧠 ミドルウェアシステム
- 📡 WebSocket エンジン
- 🧰 モジュラー設計
- 🚀 Node / Deno / Bun に近い開発体験
- ⚡ 秒間 80,000 件超の処理性能
Vix.cpp をお使いの環境にセットアップするには、以下の手順を実行してください:
git clone https://github.com/vixcpp/vix.git
cd vix
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
./build/hello_routesインストールが完了したら、CLI を使用して新しいプロジェクトを作成できます:
vix new myapp
cd myapp
vix build
vix run
vix dev file.cpp
vix run file.cpp
vix orm migrateVix は、単一の .cpp ファイルを スクリプトのように 実行できます。
vix run file.cpp
vix dev file.cpp./.vix-scripts/<ファイル名>/に一時 CMake プロジェクトを生成.cppを単体実行ファイルとしてコンパイル- 即座に実行
- Ctrl+C でクリーンに終了(gmake のノイズなし)
~/myapp/test$ vix run server.cpp
Script mode: compiling server.cpp
Using script build directory:
• .vix-scripts/server
✔ Build succeeded
[I] Server running on port 8080
^C
ℹ Server interrupted by user (SIGINT)- 🧭 Introduction
- ⚡ Quick Start
- 🧱 Architecture & Modules
- 💾 ORM Overview
- 📈 Benchmarks
- 🧰 Examples
- 🛠️ Build & Installation
- ⚙️ CLI Options
- 🧩 Core Module — docs/modules/core.md
- 📡 WebSocket Module — docs/modules/websocket.md
- 🗃️ ORM Module — docs/modules/orm.md
- 🔧 JSON Module — docs/modules/json.md
- 🛠️ Utils Module — docs/modules/utils.md
- 🧰 CLI Module — docs/modules/cli.md
- ⚙️ Rix Library (Essential C++ utilities) — docs/modules/rix.md
📊 サマリー
Vix.cpp は、Go Fiber に匹敵、あるいはそれを超える性能を持ち、 Deno、Node、PHP、Python、さらには Crow などの複数の C++ フレームワークをも上回る モダンバックエンドランタイムの最前線に位置しています。
Vix.cpp = 境界を押し広げる C++ ランタイム
コントリビューションは歓迎です。 詳細はコントリビューティングガイドをご覧ください。
MIT License で提供されています。
