Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Web ด้วย Rust

Frameworks ยอดนิยม

Frameworkคำอธิบาย
AxumModern, tower-based
Actix-webHigh performance
RocketEasy to use
WarpComposable filters

🏗️ Web Application Architecture

+-------------------------------------------------------------------+
|                    Rust Web Application Stack                     |
+-------------------------------------------------------------------+
|                                                                   |
|   Client (Browser/Mobile)                                         |
|         |                                                         |
|         v                                                         |
|   +---------------------------------------------------------------+
|   |                      Load Balancer                            |
|   |                    (nginx/traefik)                            |
|   +---------------------------------------------------------------+
|         |                                                         |
|         v                                                         |
|   +---------------------------------------------------------------+
|   |              Rust Web Server (Axum/Actix)                     |
|   |  +----------+  +----------+  +------------+                   |
|   |  | Routes   |  | Handlers |  | Middleware |                   |
|   |  +----------+  +----------+  +------------+                   |
|   +---------------------------------------------------------------+
|         |                                                         |
|         v                                                         |
|   +---------------------------------------------------------------+
|   |            Database (PostgreSQL/SQLite/Redis)                 |
|   +---------------------------------------------------------------+
|                                                                   |
+-------------------------------------------------------------------+

ทำไมใช้ Rust สำหรับ Web?

คุณสมบัติRustNode.jsPython
Performance⭐⭐⭐⭐⭐
MemoryLowMediumHigh
Concurrency⭐⭐⭐⭐⭐
Type Safety⭐⭐⭐

🚀 Deployment Options

Optionตัวอย่างเหมาะกับ
Dockerdocker build -t myapp .Production
CloudAWS ECS, Google Cloud RunScalable
ServerlessAWS Lambda (+ cargo-lambda)Low traffic
VPSDigitalOcean, LinodeSimple deploy

เราจะใช้ Axum

Axum เป็น framework จาก Tokio team:

  • ใช้ง่าย
  • Async native
  • Type-safe
  • Extensible

👉 ต่อไป: Axum พื้นฐาน