Senior Engineer Wajib Tahu CQRS
Senior Engineer Wajib Tahu CQRS — Bikin Search 100× Lebih Cepat 🚀Pencarian katalog produk yang awalnya cepat tiba-tiba jadi ~3 DETIK saat data
menyentuh 1 juta baris. Di video ini kita bedah masalahnya dari akar, lalu
pelan-pelan sampai ke pola CQRS (Command Query Responsibility Segregation) dan
mendemokannya LANGSUNG dengan benchmark nyata.
Yang penting: kita TIDAK buru-buru ganti arsitektur. Kita optimalkan dulu
PostgreSQL-nya (pg_trgm), ukur ulang, dan baru pindah ke CQRS SAAT optimasi
benar-benar mentok. Ini disiplin engineering yang sering dilewati.
================================
YANG AKAN KAMU PELAJARI
• Kenapa LIKE '%kata%' + facet GROUP BY tidak skala di data besar
• Optimasi PostgreSQL dengan index trigram (pg_trgm) — TANPA ubah kode aplikasi
• Batas optimasi database: kapan satu index sudah cukup, kapan tidak
• Pola CQRS: memisahkan model tulis (Command) dari model baca (Query)
• Sinkronisasi write → read pakai CDC (Debezium → Kafka) — tanpa dual-write
• Read model OpenSearch: n-gram (mirip LIKE tapi terindeks) & facet drill-down
• Trade-off eventual consistency — kapan worth it, kapan tidak
• Benchmark 3 engine berdampingan: PostgreSQL naif vs PG+trigram vs OpenSearch
================================
BENCHMARK (1 juta produk, search + facet)
• PostgreSQL naif : ~3.230 ms 🐌
• PostgreSQL+trigram: ~1.102 ms
• OpenSearch : ~21 ms ⚡ (facet nyaris gratis — satu pass agregasi)
Hasil pencarian IDENTIK (parity terverifikasi) — bukan "hasil beda makanya cepat".
================================
CHAPTERS
00:00 Pendahuluan
00:29 Studi Kasus: Pencarian Katalog Produk
02:50 Pendekatan Awal (Satu Database Saja)
03:44 Masalah Pendekatan Awal (Lambat di Skala Besar)
08:26 Kenapa Bisa Selambat Itu?
10:07 Sebelum Pindah ke CQRS
10:43 Optimalisasi Database (pg_trgm)
18:11 Batas Optimalisasi Database
23:00 Command Query Responsibility Segregation
25:17 Konsekuensi CQRS
27:22 Arsitektur CQRS
35:38 Kenapa OpenSearch?
40:08 Cara Membuat Facet
44:04 Eventual Consistency
47:20 Benchmark Demo
50:46 Kesimpulan
================================
TECH STACK
• product-backend — Java 25, Spring Boot 4, PostgreSQL (write model + CRUD)
• Debezium + Kafka — Kafka Connect (CDC), Kafka KRaft (sinkronisasi write → read)
• product-search — Spring Boot 4, Spring Kafka (projector + Search API)
• OpenSearch 3 — read model (search + facet)
• product-frontend — SvelteKit + nginx (UI + toggle 3 engine)
• product-faker — Bun (generator data demo)
Semua dijalankan via Docker / Podman Compose.
================================
COBA SENDIRI
Repo: https://github.com/ProgrammerZamanNow/cqrs-demo
podman compose up -d --build # naikkan seluruh stack
make register # daftarkan Debezium connector
# buka http://localhost:3000 # toggle PostgreSQL / PG+trigram / OpenSearch
================================
TAKEAWAY
Optimalkan dulu yang ada; pakai CQRS saat memang mentok. Database yang tepat
untuk pekerjaan yang tepat — tanpa mengorbankan sumber kebenaran.
Kalau video ini membantu, jangan lupa LIKE, SUBSCRIBE, dan share ke tim kamu 🙏
Punya pertanyaan atau request topik? Tulis di kolom komentar!
#CQRS #SystemDesign #SoftwareEngineering #OpenSearch #PostgreSQL #Kafka
#Debezium #SpringBoot #Java #BackendDevelopment #Microservices #DatabaseOptimization
#ProgrammerZamanNow Receive SMS online on sms24.me
TubeReader video aggregator is a website that collects and organizes online videos from the YouTube source. Video aggregation is done for different purposes, and TubeReader take different approaches to achieve their purpose.
Our try to collect videos of high quality or interest for visitors to view; the collection may be made by editors or may be based on community votes.
Another method is to base the collection on those videos most viewed, either at the aggregator site or at various popular video hosting sites.
TubeReader site exists to allow users to collect their own sets of videos, for personal use as well as for browsing and viewing by others; TubeReader can develop online communities around video sharing.
Our site allow users to create a personalized video playlist, for personal use as well as for browsing and viewing by others.
@YouTubeReaderBot allows you to subscribe to Youtube channels.
By using @YouTubeReaderBot Bot you agree with YouTube Terms of Service.
Use the @YouTubeReaderBot telegram bot to be the first to be notified when new videos are released on your favorite channels.
Look for new videos or channels and share them with your friends.
You can start using our bot from this video, subscribe now to Senior Engineer Wajib Tahu CQRS
What is YouTube?
YouTube is a free video sharing website that makes it easy to watch online videos. You can even create and upload your own videos to share with others. Originally created in 2005, YouTube is now one of the most popular sites on the Web, with visitors watching around 6 billion hours of video every month.