Giter VIP home page Giter VIP logo

jarkom-modul-3-f12-2023's Introduction

Jarkom-Modul-3-F12-2023

Nama NRP
Aurelio Killian Lexi Verrill 5025211126
Rano Noumi Sulistyo 5025211185

Daftar Isi

Topologi

Topologi

Konfigurasi

Aura
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
    address 192.227.1.111
    netmask 255.255.255.0

auto eth2
iface eth2 inet static
    address 192.227.2.111
    netmask 255.255.255.0

auto eth3
iface eth3 inet static
    address 192.227.3.111
    netmask 255.255.255.0

auto eth4
iface eth4 inet static
    address 192.227.4.111
    netmask 255.255.255.0
Himmel
auto eth0
iface eth0 inet static
	address 192.227.1.1
	netmask 255.255.255.0
	gateway 192.227.1.111
Heiter
auto eth0
iface eth0 inet static
	address 192.227.1.2
	netmask 255.255.255.0
	gateway 192.227.1.111
Denken
auto eth0
iface eth0 inet static
	address 192.227.2.1
	netmask 255.255.255.0
	gateway 192.227.2.111
Eisen
auto eth0
iface eth0 inet static
	address 192.227.2.2
	netmask 255.255.255.0
	gateway 192.227.2.111
Lugner
auto eth0
iface eth0 inet static
	address 192.227.3.1
	netmask 255.255.255.0
	gateway 192.227.3.111
Linie
auto eth0
iface eth0 inet static
	address 192.227.3.2
	netmask 255.255.255.0
	gateway 192.227.3.111
Lawine
auto eth0
iface eth0 inet static
	address 192.227.3.3
	netmask 255.255.255.0
	gateway 192.227.3.111
Fern
auto eth0
iface eth0 inet static
	address 192.227.4.1
	netmask 255.255.255.0
	gateway 192.227.4.111
Flamme
auto eth0
iface eth0 inet static
	address 192.227.4.2
	netmask 255.255.255.0
	gateway 192.227.4.111
Frieren
auto eth0
iface eth0 inet static
	address 192.227.4.3
	netmask 255.255.255.0
	gateway 192.227.4.111
Client (Revolte, Richter, Stark, Sein)
auto eth0
iface eth0 inet dhcp

Prerequisite

Aura
  1. Jalankan command berikut
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE -s 192.227.0.0/16
  1. Install isc-dhcp-relay
apt-get update
apt-get install -y isc-dhcp-relay
  1. Masukkan konfigurasi berikut pada /etc/default/isc-dhcp-relay
SERVERS="192.227.1.1"
INTERFACES="eth1 eth3 eth4"
OPTIONS=
  1. Uncomment net.ipv4.ip_forward = 1 pada /etc/sysctl.conf kemudian restart isc-dhcp-relay
Semua node kecuali client dan aura
  1. Tambahkan isi /etc/resolv.conf dari Aura pada tiap node
nameserver 192.168.122.1

Soal 0

Register domain berupa riegel.canyon.yyy.com untuk worker Laravel dan granz.channel.yyy.com untuk worker PHP, mengarah pada worker yang memiliki IP [prefix IP].x.1.

  1. Install bind9 pada Heiter
apt-get update
apt-get install -y bind9
  1. Tambahkan zone berikut pada /etc/bind/named.conf.local
zone "riegel.canyon.f12.com" {
        type master;
        file "/etc/bind/f12/riegel.canyon.f12.com";
};

zone "granz.channel.f12.com" {
        type master;
        file "/etc/bind/f12/granz.channel.f12.com";
};
  1. Buat file /etc/bind/f12/riegel.canyon.f12.com dan /etc/bind/f12/granz.channel.f12.com.

  2. Masukkan konfigurasi berikut pada file yang bersesuaian

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     riegel.canyon.f12.com. root.riegel.canyon.f12.com. (
			    2023110101    ; Serial
                        604800        ; Refresh
                        86400         ; Retry
                        2419200       ; Expire
                        604800 )      ; Negative Cache TTL
;
@               IN      NS      riegel.canyon.f12.com.
@               IN      A       192.227.4.1 ; IP Fern
www             IN      CNAME   riegel.canyon.f12.com.

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     granz.channel.f12.com. root.granz.channel.f12.com. (
			    2023110101    ; Serial
                        604800        ; Refresh
                        86400         ; Retry
                        2419200       ; Expire
                        604800 )      ; Negative Cache TTL
;
@               IN      NS      granz.channel.f12.com.
@               IN      A       192.227.3.1 ; IP Lugner
www             IN      CNAME   granz.channel.f12.com.

  1. Restart bind9

  2. Lakukan test

ping riegel.canyon.f12.com
ping granz.channel.f12.com

Soal 0

Soal 1

Lakukan konfigurasi sesuai dengan peta yang sudah diberikan.

  1. Install isc-dhcp-server pada Himmel
apt-get update
apt-get install -y isc-dhcp-server
  1. Masukkan konfigurasi berikut pada /etc/default/isc-dhcp-server
INTERFACES="eth0"
  1. Buat subnet berikut pada /etc/dhcp/dhcpd.conf
subnet 192.227.1.0 netmask 255.255.255.0 {
}

subnet 192.227.3.0 netmask 255.255.255.0 {
    range 192.227.3.16 192.227.3.32;
    range 192.227.3.64 192.227.3.80;
    option routers 192.227.3.111;
    option broadcast-address 192.227.3.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 180;
    max-lease-time 5760;
}

subnet 192.227.4.0 netmask 255.255.255.0 {
    range 192.227.4.12 192.227.4.20;
    range 192.227.4.160 192.227.4.168;
    option routers 192.227.4.111;
    option broadcast-address 192.227.4.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 720;
    max-lease-time 5760;
}
  1. Restart isc-dhcp-server
service isc-dhcp-server stop
service isc-dhcp-server start
  1. Client akan mendapat IP dari DHCP Server (Himmel). Cek dengan mematikan dan menghidupkan kembali node Client.

Soal 2

Client yang melalui Switch3 mendapatkan range IP dari [prefix IP].3.16 - [prefix IP].3.32 dan [prefix IP].3.64 - [prefix IP].3.80

  1. Tambahkan baris range 192.227.3.16 192.227.3.32; dan range 192.227.3.64 192.227.3.80; di dalam blok subnet 192.227.3.0 netmask 255.255.255.0 pada /etc/dhcp/dhcpd.conf Himmel
subnet 192.227.3.0 netmask 255.255.255.0 {
    range 192.227.3.16 192.227.3.32;
    range 192.227.3.64 192.227.3.80;
    option routers 192.227.3.111;
    option broadcast-address 192.227.3.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 180;
    max-lease-time 5760;
}

Soal 3

Client yang melalui Switch4 mendapatkan range IP dari [prefix IP].4.12 - [prefix IP].4.20 dan [prefix IP].4.160 - [prefix IP].4.168

  1. Tambahkan baris range 192.227.4.12 192.227.4.20; dan range 192.227.4.160 192.227.4.168; di dalam blok subnet 192.227.4.0 netmask 255.255.255.0 pada /etc/dhcp/dhcpd.conf Himmel
subnet 192.227.4.0 netmask 255.255.255.0 {
    range 192.227.4.12 192.227.4.20;
    range 192.227.4.160 192.227.4.168;
    option routers 192.227.4.111;
    option broadcast-address 192.227.4.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 720;
    max-lease-time 5760;
}

Soal 4

Client mendapatkan DNS dari Heiter dan dapat terhubung dengan internet melalui DNS tersebut

  1. Masukkan konfigurasi DNS Forwarding berikut pada Heiter
options {
      directory "/var/cache/bind";

      forwarders {
              192.168.122.1;
      };

      // dnssec-validation auto;
      allow-query{any;};
      auth-nxdomain no;    # conform to RFC1035
      listen-on-v6 { any; };
}; 
  1. Client berhasil mendapatkan nameserver 192.227.1.2 secara otomatis dari DHCP Server (Heiter) dan dapat terhubung ke internet

Soal 4

Soal 5

Lama waktu DHCP server meminjamkan alamat IP kepada Client yang melalui Switch3 selama 3 menit sedangkan pada client yang melalui Switch4 selama 12 menit. Dengan waktu maksimal dialokasikan untuk peminjaman alamat IP selama 96 menit

  1. Tambahkan baris default-lease-time 180; dan max-lease-time 5760; di dalam blok subnet 192.227.3.0 netmask 255.255.255.0 pada /etc/dhcp/dhcpd.conf Himmel
subnet 192.227.3.0 netmask 255.255.255.0 {
    range 192.227.3.16 192.227.3.32;
    range 192.227.3.64 192.227.3.80;
    option routers 192.227.3.111;
    option broadcast-address 192.227.3.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 180;
    max-lease-time 5760;
}
  1. Tambahkan baris default-lease-time 720; dan max-lease-time 5760; di dalam blok subnet 192.227.4.0 netmask 255.255.255.0 pada /etc/dhcp/dhcpd.conf Himmel
subnet 192.227.4.0 netmask 255.255.255.0 {
    range 192.227.4.12 192.227.4.20;
    range 192.227.4.160 192.227.4.168;
    option routers 192.227.4.111;
    option broadcast-address 192.227.4.255;
    option domain-name-servers 192.227.1.2;
    default-lease-time 720;
    max-lease-time 5760;
}

Soal 6

Pada masing-masing worker PHP, lakukan konfigurasi virtual host untuk website berikut dengan menggunakan php 7.3.

  1. Install beberapa tools
apt-get update
apt-get install -y wget unzip nginx php php-fpm htop
  1. Download file dan unzip
wget -O 'granz.channel.yyy.com.zip' 'https://drive.usercontent.google.com/download?id=1ViSkRq7SmwZgdK64eRbr5Fm1EGCTPrU1'
unzip granz.channel.yyy.com.zip
mv modul-3/* /var/www/html
  1. Masukkan konfigurasi berikut pada /etc/nginx/sites-available/default
server {

listen 80;

root /var/www/html;

index index.php index.html index.htm;
server_name _;

location / {
        try_files $uri $uri/ /index.php?$query_string;
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

location ~ /\.ht {
        deny all;
}

error_log /var/log/nginx/jarkom_error.log;
access_log /var/log/nginx/jarkom_access.log;
}
  1. Restart service
service php7.3-fpm start
service nginx restart
  1. Akses website dari client atau worker
lynx localhost
lynx granz.channel.f12.com

Soal 6

Soal 7

Kepala suku dari Bredt Region memberikan resource server sebagai berikut:

  • Lawine, 4GB, 2vCPU, dan 80 GB SSD.
  • Linie, 2GB, 2vCPU, dan 50 GB SSD.
  • Lugner 1GB, 1vCPU, dan 25 GB SSD. aturlah agar Eisen dapat bekerja dengan maksimal, lalu lakukan testing dengan 1000 request dan 100 request/second.
  1. Ubah konfiguarsi /etc/bind/f12/granz.channel.f12.com pada Heiter untuk menuju ke IP Eisen kemudian restart bind9
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     granz.channel.f12.com. root.granz.channel.f12.com. (
			    2023110101    ; Serial
                        604800        ; Refresh
                        86400         ; Retry
                        2419200       ; Expire
                        604800 )      ; Negative Cache TTL
;
@               IN      NS      granz.channel.f12.com.
@               IN      A       192.227.2.2 ; IP Eisen
www             IN      CNAME   granz.channel.f12.com.

  1. Pada Eisen, masukkan konfigurasi berikut pada /etc/nginx/sites-available/lb-php
upstream backendphp  {
server 192.227.3.1 weight=1; #IP Lugner
server 192.227.3.2 weight=4; #IP Linie
server 192.227.3.3 weight=8; #IP Lawine
}

server {
        listen 80;
        server_name granz.channel.f12.com;

        location / {
                include /etc/nginx/conf.d/ip-restrictions.conf;

                proxy_pass http://backendphp;
                proxy_set_header    X-Real-IP $remote_addr;
                proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header    Host $http_host;

                auth_basic "Administrator'\''s Area";
                auth_basic_user_file /etc/nginx/rahasiakita/.htpasswd;
        }

        location ~ /\.ht {
                deny all;
        }

        location ~ /its {
                proxy_pass https://www.its.ac.id;
        }

        error_log /var/log/nginx/lb_php_error.log;
        access_log /var/log/nginx/lb_php_access.log;

}
  1. Restart nginx Eisen

  2. Lakukan benchmark dari Client

ab -n 1000 -c 100 http://granz.channel.f12.com/

Weighted Round Robin

Soal 8

Buatlah analisis hasil testing dengan 200 request dan 10 request/second masing-masing algoritma Load Balancer

  1. Ubah block upstream backendphp pada /etc/nginx/sites-available/lb-php Eisen untuk menggunakan algoritma tertentu. Pastikan untuk restart nginx sebelum melakukan benchmark
# Weighted Round Robin
upstream backendphp  {
server 192.227.3.1 weight=1; #IP Lugner
server 192.227.3.2 weight=2; #IP Linie
server 192.227.3.3 weight=4; #IP Lawine
}
# Round Robin
upstream backendphp  {
server 192.227.3.1; #IP Lugner
server 192.227.3.2; #IP Linie
server 192.227.3.3; #IP Lawine
}
# Least Connection
upstream backendphp  {
least_conn;
server 192.227.3.1; #IP Lugner
server 192.227.3.2; #IP Linie
server 192.227.3.3; #IP Lawine
}
# IP Hash
upstream backendphp  {
ip_hash;
server 192.227.3.1; #IP Lugner
server 192.227.3.2; #IP Linie
server 192.227.3.3; #IP Lawine
}
# Generic Hash
upstream backendphp  {
hash $request_uri consistent;
server 192.227.3.1; #IP Lugner
server 192.227.3.2; #IP Linie
server 192.227.3.3; #IP Lawine
}
  1. Lakukan benchmark dari Client
ab -n 200 -c 10 http://granz.channel.f12.com/
  • Weighted Round Robin

    Weighted Round Robin

  • Round Robin

    Round Robin

  • Least Connection

    Least Connection

  • IP Hash

    IP Hash

  • Generic Hash

    Generic Hash

  • Graph

    Graph 1

Soal 9

Dengan menggunakan algoritma Round Robin, lakukan testing dengan menggunakan 3 worker, 2 worker, dan 1 worker sebanyak 100 request dengan 10 request/second, kemudian tambahkan grafiknya pada grimoire

  1. Comment beberapa server pada blok upstream backendphp untuk mengatur banyaknya worker yang bekerja kemudian restart nginx
# Round Robin
upstream backendphp  {
server 192.227.3.1; #IP Lugner
# server 192.227.3.2; #IP Linie
# server 192.227.3.3; #IP Lawine
}
  1. Lakukan benchmark dari Client
ab -n 100 -c 10 http://granz.channel.f12.com/
  • 1 Worker

    Round Robin 1 Worker

  • 2 Worker

    Round Robin 3 Worker

  • Graph

Graph 2

Soal 10

Selanjutnya coba tambahkan konfigurasi autentikasi di LB dengan dengan kombinasi username: โ€œneticsโ€ dan password: โ€œajkyyyโ€, dengan yyy merupakan kode kelompok. Terakhir simpan file โ€œhtpasswdโ€ nya di /etc/nginx/rahasisakita/

  1. Tambahkan konfigurasi berikut pada blok location / pada /etc/nginx/sites-available/lb-php kemudian restart nginx
auth_basic "Administrator's Area";
auth_basic_user_file /etc/nginx/rahasiakita/.htpasswd;
  1. Buat direktori rahasiakita dan file .htpasswd di dalamnya

  2. Daftarkan sebuah username dan password pada file tersebut

htpasswd -b /etc/nginx/rahasiakita/.htpasswd netics ajkf12
  1. Akses website dari Client menggunakan Lynx. Client akan diminta untuk memasukkan username dan password untuk mengaksesnya.

Auth

Auth

Auth

Auth

Soal 11

Lalu buat untuk setiap request yang mengandung /its akan di proxy passing menuju halaman https://www.its.ac.id

  1. Buat sebuah block location ~ /its pada /etc/nginx/sites-available/lb-php Eisen kemudian restart nginx
location ~ /its {
        proxy_pass https://www.its.ac.id;
}
  1. Akses website dari Client
lynx granz.channel.f12.com/its
lynx granz.channel.f12.com/loremipsum/its

Proxy Pass

Soal 12

Selanjutnya LB ini hanya boleh diakses oleh client dengan IP [Prefix IP].3.69, [Prefix IP].3.70, [Prefix IP].4.167, dan [Prefix IP].4.168.

  1. Buat sebuah file untuk menyimpan restriksi IP. Dalam hal ini /etc/nginx/conf.d/ip-restrictions.conf yang berisi sebagai berikut
allow 192.227.3.69;
allow 192.227.3.70;
allow 192.227.4.167;
allow 192.227.4.168;
deny all;
  1. Include file tersebut pada block location / pada /etc/nginx/sites-available/lb-php Eisen kemudian restart nginx
location / {
        include /etc/nginx/conf.d/ip-restrictions.conf;

        proxy_pass http://backendphp;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    Host $http_host;

        auth_basic "Administrator's Area";
        auth_basic_user_file /etc/nginx/rahasiakita/.htpasswd;
}
  1. Akses website dari Client. Client dengan IP yang tidak memenuhi persyaratan tidak dapat mengakses website granz.channel.f12.com

IP Restriction

Soal 13

Semua data yang diperlukan, diatur pada Denken dan harus dapat diakses oleh Frieren, Flamme, dan Fern.

  1. Install mariadb-server pada Denken
apt-get update
apt-get install -y mariadb-server
  1. Masukkan konfigurasi berikut pada /etc/mysql/my.cnf
[client-server]

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

[mysqld]
skip-networking=0
skip-bind-address
  1. Restart mysql

  2. Jalankan command mysql lalu buat beberapa user dan database

mysql -u root -p
CREATE USER 'kelompokf12'@'%' IDENTIFIED BY 'qwe123';
CREATE USER 'kelompokf12'@'localhost' IDENTIFIED BY 'qwe123';
CREATE DATABASE kelompokf12;
GRANT ALL PRIVILEGES ON *.* TO 'kelompokf12'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'kelompokf12'@'localhost';
FLUSH PRIVILEGES;
  1. Pada worker Laravel, install mariadb-client

  2. Akses server database Denken dari worker Laravel

mysql -u kelompokf12 -h 192.227.2.1 -p -D kelompokf12

Database Server

Database Client

Soal 14

Frieren, Flamme, dan Fern memiliki Riegel Channel sesuai dengan quest guide berikut. Jangan lupa melakukan instalasi PHP8.0 dan Composer Quest guide merupakan sebuah git repo yang berisi project laravel yang perlu dicopy ke tiap worker.

  1. Sebelum itu kita perly install semua yang diperlukan, yaitu php8, compose dan beberapa app lain speerti wget.
apt-get install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update
apt-get install php8.0-mbstring php8.0-xml php8.0-cli php8.0-common php8.0-intl php8.0-opcache php8.0-readline php8.0-mysql php8.0-fpm php8.0-curl unzip wget -y
apt-get install -y git mariadb-client nginx
wget https://getcomposer.org/download/2.0.13/composer.phar
chmod +x composer.phar
mv composer.phar /usr/bin/composer

  1. Setelah itu kita perlu setup project berdeasarkan repo.
   cd /var/www
git clone https://github.com/martuafernando/laravel-praktikum-jarkom
cd laravel-praktikum-jarkom
composer update
composer install
  1. Agar dapat konek dengan database, kita perlu modifikasi file env.
file_to_modify="/var/www/laravel-praktikum-jarkom/.env"
echo -e "${BG_BLUE}Configuring $file_to_modify${RESET}"
echo 'APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=192.227.2.1
DB_PORT=3306
DB_DATABASE=kelompokf12
DB_USERNAME=kelompokf12
DB_PASSWORD=qwe123

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"' > "$file_to_modify"
  1. Setup sehingga file bisa dirun
chown -R www-data.www-data /var/www/laravel-praktikum-jarkom/storage
php artisan migrate
php artisan db:seed --class=AiringsTableSeeder
php artisan key:generate
php artisan jwt:secret
php artisan cache:clear

Soal 15

Riegel Channel memiliki beberapa endpoint yang harus ditesting sebanyak 100 request dengan 10 request/second. Tambahkan response dan hasil testing pada grimoire. POST /auth/register

  1. buat register.json di client sehingga bisa lakukan post.
echo '
{
  "username": "kelompokf12",
  "password": "passwordf12"
}' > /root/register.json
  1. Run apache benchmark dengan register.json
ab -n 100 -c 10 -p register.json -T application/json http://192.221.4.1:8001/api/auth/register

register.json

## Soal 16 > Riegel Channel memiliki beberapa endpoint yang harus ditesting sebanyak 100 request dengan 10 request/second. Tambahkan response dan hasil testing pada grimoire. POST /auth/login 1. buat login.json di client sehingga bisa lakukan post.
echo '
{
  "username": "kelompokf12",
  "password": "passwordf12"
}' > /root/login.json

  1. Run apache benchmark dengan login.json
ab -n 100 -c 10 -p login.json -T application/json http://192.221.4.1:8001/api/auth/register

login.json

## Soal 17 > Riegel Channel memiliki beberapa endpoint yang harus ditesting sebanyak 100 request dengan 10 request/second. Tambahkan response dan hasil testing pada grimoire. GET /me 1. Buat token untuk endpoint
curl -X POST -H "Content-Type: application/json" -d @login.json http://192.173.4.1:8001/api/auth/login > login_output.txt
  1. Set token sebagau variabel di client
token=$(cat login_output.txt | jq -r '.token')
  1. Run benchmark
ab -n 100 -c 10 -H "Authorization: Bearer $token" http://192.221.4.1:8001/api/me

get me

## Soal 18 > Untuk memastikan ketiganya bekerja sama secara adil untuk mengatur Riegel Channel maka implementasikan Proxy Bind pada Eisen untuk mengaitkan IP dari Frieren, Flamme, dan Fern 1. Buat setting load balancer untuk laravel di eisen
echo 'upstream backendlaravel  {
server 192.227.4.1:8001; #IP Fern
server 192.227.4.2:8002; #IP Flamme
server 192.227.4.3:8003; #IP Frieren
}

server {
        listen 80;
        server_name riegel.canyon.f12.com;

        location / {
                proxy_pass http://backendlaravel;
        }

        location ~ /\.ht {
                deny all;
        }

        error_log /var/log/nginx/lb_laravel_error.log;
        access_log /var/log/nginx/lb_laravel_access.log;

}'
  1. Link dengan sites-enabled
unlink /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/lb-php /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/lb-laravel /etc/nginx/sites-enabled/

Soal 19

Untuk meningkatkan performa dari Worker, coba implementasikan PHP-FPM pada Frieren, Flamme, dan Fern. Untuk testing kinerja naikkan

  • pm.max_children
  • pm.start_servers
  • pm.min_spare_servers
  • pm.max_spare_servers sebanyak tiga percobaan dan lakukan testing sebanyak 100 request dengan 10 request/second kemudian berikan hasil analisisnya pada Grimoire Kita buat 3 file untuk masing masing specifkasi dengan nilai nilai yang naik secara lurus
echo '[www]
user = www-data
group = www-data
listen = /run/php/php8.0-fpm.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off


; Choose how the process manager will control the number of child processes.


pm = dynamic
pm.max_children = 4
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 4' > /etc/php/8.0/fpm/pool.d/www.conf


service php8.0-fpm restart




# Script 2
echo '[www]
user = www-data
group = www-data
listen = /run/php/php8.0-fpm.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off


; Choose how the process manager will control the number of child processes.


pm = dynamic
pm.max_children = 15
pm.start_servers = 5
pm.min_spare_servers = 4
pm.max_spare_servers = 8' > /etc/php/8.0/fpm/pool.d/www.conf


service php8.0-fpm restart




# Script 2
echo '[www]
user = www-data
group = www-data
listen = /run/php/php8.0-fpm.sock
listen.owner = www-data
listen.group = www-data
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off


; Choose how the process manager will control the number of child processes.


pm = dynamic
pm.max_children = 50
pm.start_servers = 15
pm.min_spare_servers = 10
pm.max_spare_servers = 20' > /etc/php/8.0/fpm/pool.d/www.conf


service php8.0-fpm restart

Berikut adalah hasil

Test 1

test1

### Test 2

test2

### Test 3

test3

Bisa dilihat semakin banyak semaik bagus, namun jika terlalu banyak justru melambat

Soal 20

Nampaknya hanya menggunakan PHP-FPM tidak cukup untuk meningkatkan performa dari worker maka implementasikan Least-Conn pada Eisen. Untuk testing kinerja dari worker tersebut dilakukan sebanyak 100 request dengan 10 request/second.

  1. Edit load balancer sehingga mempunyai least connect
echo 'upstream backendlaravel  {
least_conn;
server 192.227.4.1:8001; #IP Fern
server 192.227.4.2:8002; #IP Flamme
server 192.227.4.3:8003; #IP Frieren
}

server {
        listen 80;
        server_name riegel.canyon.f12.com;

        location / {
                proxy_pass http://backendlaravel;
        }

        location ~ /\.ht {
                deny all;
        }

        error_log /var/log/nginx/lb_laravel_error.log;
        access_log /var/log/nginx/lb_laravel_access.log;

}'
  1. Run benchmark

least_conn laravel

jarkom-modul-3-f12-2023's People

Contributors

aurelioklv avatar ranocg123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.