{"id":20136143,"url":"https://github.com/zkfmapf123/event_driven_architecture","last_synced_at":"2026-05-13T19:32:20.270Z","repository":{"id":235720579,"uuid":"615350638","full_name":"zkfmapf123/event_driven_architecture","owner":"zkfmapf123","description":"event_driven_architecture use nodejs","archived":false,"fork":false,"pushed_at":"2023-03-20T15:51:27.000Z","size":372,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T22:42:16.101Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkfmapf123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-17T13:53:19.000Z","updated_at":"2023-03-20T15:51:31.000Z","dependencies_parsed_at":"2024-04-24T12:10:37.906Z","dependency_job_id":"48a8f691-4ac9-48d4-8ef1-2355e7b5a9ad","html_url":"https://github.com/zkfmapf123/event_driven_architecture","commit_stats":null,"previous_names":["zkfmapf123/event_driven_architecture"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zkfmapf123/event_driven_architecture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfmapf123%2Fevent_driven_architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfmapf123%2Fevent_driven_architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfmapf123%2Fevent_driven_architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfmapf123%2Fevent_driven_architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkfmapf123","download_url":"https://codeload.github.com/zkfmapf123/event_driven_architecture/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkfmapf123%2Fevent_driven_architecture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32997556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T21:17:57.164Z","updated_at":"2026-05-13T19:32:20.255Z","avatar_url":"https://github.com/zkfmapf123.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event Driven Architecture\n\n## Index\n\n1. Command And Query\n2. Event\n3. Event Driven Architecture\n4. Event Sourcing And CQRS\n\n## As a Point\n\n### 1.Command And Query\n\n\u003e Command\n\n![Command](./public/command.png)\n\n    - Do Something\n    - Usaully Synchronous\n    - Sometimes returns a response\n    - CAlling service needs to know who handles the command\n\n\u003e Query\n\n![Query](./public/query.png)\n\n    - Retrieve data\n    - Almost always synchronous\n    - Always returns a response\n    - Calling service needs to know who handles the query\n\n### Command And Query Problem\n\n\u003e Performance\n\n    - 두개의 방식모두 동기방식으로 운영 -\u003e 느려짐\n\n\u003e Coupling\n\n    - 두개의 방식모두 다른 서비스를 호출 -\u003e 만약 서비스가 바뀐다면 -\u003e 결합성 이슈 생길수 있음\n\n\u003e Scalability\n\n    - 두개의 방식모두 다른 서비스를 호출 -\u003e 한개의 인스턴스라면, 내부에서 많은 통신일 일어나게 됨(busy) -\u003e 다른 인스턴스로 확장할순 있지만 어려움(관리)\n\n### 2. Event\n\n![Event](./public/event.png)\n\n\u003e Complete Event\n\n    - Contains all the relevant data\n    - Usually entity data\n    - 보통의 데이터를 뜻함\n\n```json\n    \"event_type\"    : \"CustomerCreated\"\n    \"customer_id\"   : 1\n    \"first_name\"    : \"lee\"\n    ...\n```\n\n\u003e Pointer Event\n\n- Retrieve Complete Data in Stored Database\n\n```json\n    \"event_type\"    : \"CustomerCreated\"\n    \"customer_id\"   : 1\n```\n\n## 3. Event Driven Architecture\n\n![EDA](./public/eda.png)\n\n\u003e Producer\n\n    - 이벤트 생성 시 다른 채널로 해당 이벤트를 전송/발송 한다\n\n\u003e Channel\n\n    - RabbitMQ\n    - Kafka\n    - Usually Use Queue\n\n\u003e Consumer\n\n    - Execute Event\n    - Sometimes Return value (ACK)\n    - Push / Pull 메커니즘 사용\n\n### Advantages of EDA\n\n\u003e Performance\n\n    - EDA is an Asynchronous Architecture (the opposite Command and Query)\n    - The Channel Does not wait for response from consumer\n    - Solution of Performance (Command and Query)\n\n\u003e Coupling\n\n    - producer -\u003e Channel\n    - Channel은 topic기준 queue로 관리가 됨\n\n\u003e Scalability\n\n    - Many Consumer can listen events from channel\n\n\u003e EDA와 Pubsub의 차이점\n\n    - EDA는 전체적인 개념임 -\u003e 이벤트 기반의 구조를 뜻함\n    - Pubsub은 Publisher / Subscribe 기반의 메시징 시스템을 뜻함 -\u003e 더 소규모 개념임\n    - EDA와 pubsub은 유사한 개념이나, EDA 구조안에 pubsub 개념이 있다고 생각하면 됨\n\n```txt\n    우리 시스템은 Event Driven Architecture를 사용하고 있으며,\n    그 안에서 배달 시스템은 Pubsub 구조를 채택하고 있다.\n```\n\n### Event Sourcing And CQRS\n\n\u003e Example Employee Table in RDB\n\n| emp_id | first_name | last_name | address | role     | date_join  |\n| ------ | ---------- | --------- | ------- | -------- | ---------- |\n| 1      | john       | smith     | seoul   | backend  | 2009-04-23 |\n| 2      | sahra      | adsf      | busan   | frontend | 2001-05-23 |\n| 3      | culre      | basf      | incheon | data     | 2003-09-23 |\n\n\u003e 해당 테이블로 알수 없는 질문\n\n    - john의 이전 role은 무엇인가요? -\u003e 알수없음\n    - sahra의 이전 주소는 어디인가? -\u003e 알수없음\n    - culre의 이전이름이 있다면 무엇인가? -\u003e 알수없음\n    - 이러한 Log성 데이터가 필요하다 -\u003e CQRS로 이방식을 해결할 수 있다.\n\n\u003e Event Sourcing\n\n    - 계속 바뀌는 데이터의 패턴을 Capture하는 방식\n    - 해당 데이터를 삭제하거나 업데이트 하지 않고, 계속 insert 하는 방식\n    - Event Store\n\n    ```\n       event_id          timestamp          type           event\n       1                 20230101           create          employee join who john is cloud enginner\n       2                 20230102           update          update role whe john is backend\n       3                 20230103           sahra           move to address incheon\n       ...\n\n       - john의 이전 역할은? 클라우드 엔지니어\n       - sahra의 이전주소는? 인천\n    ```\n\n    - Props\n        - 해당 방식을 사용하게 된다면 -\u003e 이전의 데이터(history)를 검색하기에 유리하다\n        - 간단한 데이터 구조를 사용할 수 있다.\n        - 간단한 형태의 데이터를 핸들링 가능하다 (no update, no concurrency -\u003e very fast insert)\n    - Cons\n        - 현재의 데이터를 찾기 어려울 수 있다.\n        - 계속 데이터가 쌓이기때문에, 많은 양의 공간이 필요하다 (Many Records Per Entity)\n\n\u003e CQRS (Command and Query Responsibility Segregation)\n\n![CQRS](./public/cqrs.png)\n\n    - Command 용 데이터 베이스를 구축 -\u003e Only Insert -\u003e NoSQL (MongoDB, RTDB, DynamoDB, CouchBase*)\n    - Query 용 데이터 베이스를 구축 -\u003e Retrieve -\u003e RDB (MySQL)\n\n    - Props\n        - 대용량의 읽기 요청이 있을경우, Read 하는 부분 (Query), Update하는 부분 (Command)이 나뉘어져 있어서 -\u003e 큰 부하에 견딜 수 있다.\n\n    - Cons\n        - 보통 Command용 데이터에서 Query용 데이터로 Sync를 맞추기 때문에 정합성이 실시간으로 업데이트 되지 않을 수 있다.\n        - 2개의 데이터베이스를 운용해야 히기때문에 Handling하기 어려울 수 있다.\n\n    - UseCase\n        - Historical data가 정말 중요할 때 ex) 입,출금이력, 구매이력, HealthCare\n        - Read하는 부분, Update하는 부분을 나눠야 할때 Performance, 부하분산.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkfmapf123%2Fevent_driven_architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkfmapf123%2Fevent_driven_architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkfmapf123%2Fevent_driven_architecture/lists"}