Foundationপ্রথম নীতি থেকে
LEVEL 9 · Distributed Systems

CQRS

সিকিউআরএস

Command (write) আর Query (read)-এর model আলাদা করা — এক data-র দুই representation, event দিয়ে sync।

also: command-query-responsibility-segregation, cqs

commands ──► write model (normalized, invariants enforce)
                │ events / CDC
                ▼
queries  ◄── read model (denormalized, query-shaped)
             (search index, cache, materialized view...)
  • Read side free-ভাবে scale হয় — শুধু পড়ার traffic আর লেখার traffic এক structure-এ ফেঁসে না
  • Inherent price: read model stale — UI-তে ‘আপনার লেখা এখনো দেখা যাচ্ছে না’ মোকাবিলার plan ডিজাইনের অংশ
  • Event sourcing-এর প্রাকৃতিক companion, কিন্তু বাধ্যতামূলক নয়; plain CRUD app-এ CQRS অকারণ যন্ত্রপাতি