
Pembuka
Rust merupakan system programming languages yang cukup performant dan populer. Bahasa ini populer selain karena memiliki typing system juga memiliki analyzer untuk pengamanan penggunaan memory.
Requirement
Ada beberapa kebutuhan yang perlu disiapkan sebelum mendevelop dan meluncurkan app/service ke production. Kebutuhan Development dan Production.
Development Requirement
Dalam mendevelop aplikasi performa tinggi membutuhkan spesifikasi hardware yang yang cukup untuk besar untuk mempercepat proses kompilasi dan simulasi.
Dari sisi hardware ada beberapa rekomendasi untuk proses development:
- CPU 64-Bit ARM/x86_64/aarch64 Architecture
- CPU Thread Minimal 8 Threads
- RAM Minimal 8 GB
- STORAGE Minimal 60 GB NVME/SSD
Dari sisi softare berikut rekomendasi nya:
- OS dengan support Bash terminal (WSL, Debian Base/Ubuntu, MacOS)
- Git untuk Source Code Management
- Docker/Podman/OrbStack untuk containerisasi (Pilih salah satu saja)
- IDE (Visual Studio Code, NeoVIM (LazyVIM) )
- NixPackage untuk standardisasi environments
Installation
Untuk Development Rust ada beberapa app yang perlu disiapkan
- Linux/Debian Base
# Update Dependency ke latest
sudo apt update -y
# Upgrade Dependency ke latest
sudo apt upgrade -y
# Install base untuk build binary tools
sudo apt install build-essential -y
# Install Rustup - All in one Rust Tools
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- MacOS
- Install XCode
- Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Windows
- Install Microsoft Visual Studio (Check C++ Compatibility)
- Install Rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Recommendation Configs
Berikut ada beberapa konfigurasi yang direkomendasikan untuk mempercepat proses development
- install SCCACHE untuk cache build agar proses build lebih cepat
cargo install sccache
- Install Redis Server / Redis Alternative seperty Dragonfly yang nantinya digunakan sebagai cache di dalam RAM
- Konfigurasi bash profile file. File bisa berupa
.bashrc/.zshrc/.zprofile/.bash_profile/.profiledan tambahkan config berikut:
export SCCACHE_REDIS=redis://127.0.0.1:6379/0
export RUSTC_WRAPPER=/Users/han/.cargo/bin/sccache
- Konfigurasi build cache menjadi 1 shared folder dengan mengedit bash profile file
export export CARGO_TARGET_DIR=/Users/han/.cargo/target
Recommendation Cargo Tools
# auto rebuild kode rust jika ada perubahan
cargo install cargo-watch
Production Requirement
Production Requirement Hardware dan Software cukup sederhana.
Hardware
Applikasi/service dapat berjalan di spec VPS yang sangat minimum misal 0.5vCPU, 0.5GB RAM dan 1GB Storage
Software
Service dapat dicontainerisasi menggunakan Google Distroless untuk deployment yang menggunakan orchestrator container (Docker/k8s/openshift). Base image distroless ini cukup mini yaitu berukuran sekitar ~30MB saja
Penutup
Semoga apa yang ditulis oleh Penulis bisa bermanfaat.