Performance Tuning & Optimization
- Dapatkan link
- X
- Aplikasi Lainnya
⚡⚙️ Bab 21 – SOP Performance Tuning & Optimization di Ubuntu Server
Bab ini akan membuat servermu lebih gesit, efisien, dan hemat resource, sehingga bisa melayani lebih banyak pengguna tanpa harus upgrade hardware terlalu cepat.
๐ฏ Tujuan
- Mengoptimalkan performa sistem dan service.
- Mengurangi penggunaan resource berlebihan.
- Meningkatkan kecepatan respon server.
๐ง Lingkup
- Sistem operasi: Ubuntu Server
- Fokus: CPU, RAM, disk, network, web server (Apache/Nginx), database (MySQL/MariaDB)
3. Langkah Kerja
๐ง 3.1 Optimasi Sistem Dasar
- Matikan service tidak perlu:
sudo systemctl disable nama_service - Gunakan swap dengan bijak:
sudo swapon --showTambahkan swap jika RAM kecil.
- Optimasi kernel parameter (sysctl):
Edit/etc/sysctl.conf:net.ipv4.tcp_fin_timeout = 15 net.ipv4.tcp_tw_reuse = 1
Terapkan:
sudo sysctl -p
๐พ 3.2 Optimasi Disk & File System
- Gunakan
noatimeuntuk mengurangi penulisan disk:
Edit/etc/fstab:UUID=xxxx / ext4 defaults,noatime 0 1
- Gunakan
tmpfsuntuk file sementara:tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
๐ 3.3 Optimasi Web Server
Apache
- Aktifkan
mod_deflateuntuk kompresi:sudo a2enmod deflate sudo systemctl restart apache2 - Aktifkan
mod_expiresuntuk caching:sudo a2enmod expires sudo systemctl restart apache2 - Atur
KeepAlivedi/etc/apache2/apache2.conf:KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5
- Aktifkan
gzip:
Edit/etc/nginx/nginx.conf:gzip on; gzip_types text/plain text/css application/json application/javascript;
- Atur
worker process:worker_processes auto; worker_connections 1024;
๐️ 3.4 Optimasi Database (MySQL/MariaDB)
- Edit
/etc/mysql/my.cnf:[mysqld] innodb_buffer_pool_size = 512M query_cache_size = 64M max_connections = 200
- Gunakan
mysqltuneruntuk rekomendasi optimasi:sudo apt install mysqltuner -y mysqltuner
๐ 3.5 Optimasi Network
- Gunakan iptables atau ufw untuk memblokir trafik tidak perlu.
- Aktifkan caching DNS lokal:
sudo apt install dnsmasq -y
๐ 3.6 Monitoring Performa
- Gunakan
htopuntuk CPU/RAM. - Gunakan
iotopuntuk disk I/O:sudo apt install iotop -y sudo iotop - Gunakan
iftopuntuk network traffic:sudo apt install iftop -y sudo iftop
4. Command Ringkas
| Fungsi | Command |
|---|---|
| Disable service | sudo systemctl disable nama_service |
| Terapkan sysctl | sudo sysctl -p |
| Aktifkan mod_deflate | sudo a2enmod deflate |
| Aktifkan mod_expires | sudo a2enmod expires |
| Restart Apache | sudo systemctl restart apache2 |
| Restart Nginx | sudo systemctl restart nginx |
| Install mysqltuner | sudo apt install mysqltuner -y |
| Jalankan mysqltuner | mysqltuner |
| Monitor CPU/RAM | htop |
| Monitor disk I/O | sudo iotop |
| Monitor network | sudo iftop |
5. Catatan Penting
-
⚖️
Optimasi harus sesuai kapasitas hardware, jangan terlalu agresif.
-
๐
Gunakan monitoring untuk melihat efek optimasi.
-
๐งช
Lakukan uji beban (stress test) sebelum production.
-
๐
Simpan dokumentasi perubahan agar mudah rollback jika ada masalah.
๐ Dengan bab ini, servermu sudah bisa berjalan lebih cepat, efisien, dan stabil.
- Dapatkan link
- X
- Aplikasi Lainnya
Komentar
Posting Komentar