TECH |
Techable(テッカブル) |
建設業の転職希望者を支援する、日本最大級の建設業専門求人検索エンジン『ビズケン』がリリース |
https://techable.jp/archives/204628
|
株式会社 |
2023-04-30 10:30:51 |
TECH |
Techable(テッカブル) |
資金調達にも活用できる!NFT活用のデジタル会員権発行サービス「Memva!」 |
https://techable.jp/archives/205002
|
cosmgate |
2023-04-30 10:00:35 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Reactドキュメントを和訳するシリーズ(まとめ) |
https://qiita.com/i-ryo/items/e9f2c6161db51f06adf1
|
quickstart |
2023-04-30 19:19:32 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Rubyを実行する時に裏側で起こっていることを大体で理解する |
https://qiita.com/annaPanda8170/items/7fa7d5853d63cba2d105
|
rubykaigi |
2023-04-30 19:33:17 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Amazon CodeCatalystを触ってみた |
https://qiita.com/bytheway811/items/396353e9c9e9f94b8e7e
|
amazoncodecatalyst |
2023-04-30 19:30:41 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
dockerコンテナの起動時間を3分から20秒まで縮めることに成功した経験談 |
https://qiita.com/kenji-kawata/items/fceba7b8cc7c3dabac21
|
docker |
2023-04-30 19:06:50 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
toioを動かす with ChatGPT |
https://qiita.com/Teach/items/c61660f305a804613c89
|
chatgpt |
2023-04-30 19:06:38 |
海外TECH |
MakeUseOf |
Why Are Mac Webcams Still So Bad? |
https://www.makeuseof.com/why-are-mac-webcams-bad/
|
reasons |
2023-04-30 10:15:16 |
海外TECH |
DEV Community |
Querying microservices in real-time with materialized views |
https://dev.to/bobur/querying-microservices-in-real-time-with-materialized-views-211c
|
Querying microservices in real time with materialized viewsThe distributed systems architecture has become increasingly popular due to its flexibility scalability and fault tolerance However querying data from multiple microservices in real time can be challenging as it may require complex and time consuming data retrieval operations Materialized views in combination with the Command Query Responsibility Segregation CQRS pattern can provide a solution to this challenge by enabling efficient and real time querying of microservices data In this article we will explore how materialized views in a streaming database can be used to query microservices in real time with an example of an online store application Understanding the scenario and problemsLet s consider an example of an online store app that uses microservices architecture for handling various functions such as product catalog customer inventory and order management Each microservice is responsible for handling a specific domain or business function and storing data in its own data store For example Product service stores information about products in the Products database Without materialized views querying data from multiple microservices in real time can be challenging For example when a customer searches for a product on the website the website may need to retrieve product information catalog pricing and inventory status from different microservices This can result in multiple round trip queries to different microservices leading to slow response times and increased database load Assume that you apply the API composition pattern for the above case to query data from multiple microservices in a single API call In addition to scalability and maintenance issues it leads to tight coupling between microservices querying microservice needs to know the structure returned by the microservices it queries and increased complexity in implementation as it requires additional logic to aggregate and combine data from multiple microservices API composition can result in additional performance overhead as the orchestrator microservice may need to wait for responses from multiple microservices before returning a result to the client Most importantly it may not provide real time or near real time updates of data from multiple microservices If the data in the queried microservices changes frequently the API composition may not reflect the most up to date data leading to potential inconsistencies or stale information in the queried results Querying with materialized viewsNow let s see how materialized views can be utilized to optimize the querying of microservices in real time and boost the performance of the online store The below architectural diagram describes the idea Separate queries from commandsFirstly we define the commands that will modify the data in the system and queries that will read data from the system We can use CQRS to separate the responsibility for handling commands write operations from that queries read operations This allows for the optimization of each operating independently For example the products can be stored and updated in a traditional database such as SQL NOSQL while product listings search results order history or user recommendations may be some common views that need to be optimized for performance can be stored in the streaming database in the form of materialized views that is updated in real time based on the events in the stream Identify the queries creating materialized viewsLet s focus on the query part of CQRS One approach to implementing it is through the use of read optimized materialized views Materialized views are precomputed views of data that are stored and updated independently from the main transactional database Materialized views can be used to optimize read operations by reducing the complexity and latency associated with querying the main database We identify the queries that require real time or near real time access to data in the online store application such as recently viewed products The main goal here is to keep the data required by the query service in a denormalized format to enable fast retrieval Materialized views are denormalized and optimized for the specific query or view on the UI allowing for faster and more efficient data retrieval Materialized views can be created using different technologies such as relational databases NoSQL databases or specialized caching systems But if you would like to get real time updates and keep that data consistent by subscribing to the state changes of other microservices databases you opt for using the streaming database A streaming database is a type of database that is designed to consume data from various sources and handle continuous data streams in real time and making it possible to query this data from materialized views using SQL You can read more about how a Streaming database differs from a Traditional database and how to choose the right streaming database in my other blog posts Keep materialized views in syncNext we should keep the materialized view up to date The streaming database can ingest data in real time from all databases as event streams using the Change Data Capture process and built in connector If you are using PostgreSQL for a specific microservice as a data source you can utilize RisingWave s PostgreSQL CDC connector to obtain direct real time data from the change logs without using message brokers like Kafka RisingWave builds a materialized view by joining those streams together and keeps the view up to date as new events come event driven updates For example when a new product is added to the product catalog microservice a corresponding event can be captured and used to update the materialized view for product listings ensuring that the view is always up to date RisingWave is an open source streaming database that has built in fully managed CDC source connectors for various databases also it can collect data from other sources such Kafka Pulsar Kinesis or Redpanda and it allows you to query real time streams using SQL You can get a materialized view that is always up to date Query materialized viewsFinally you add a new query service that serves queries only read requests coming from the UI The query handler converts API requests to queries and fetches data from the streaming database materialized views For example when a user searches for a product the search results can be retrieved from the materialized view for search listings instead of making multiple API calls to different microservices Creating and querying materialized views with RisingWaveOn this GitHub repository you can find several use cases of materialized views with the RisingWave streaming database See how it is straightforward to connect to MySQL as a source and define database tables to retrieve data in which we are interested and to get real time updates in streaming databases create table order events order id int order date bigint customer name varchar price decimal product id int order status smallint PRIMARY KEY order id with connector mysql cdc hostname mysql port username root password database name mydb table name orders server id Then we create a materialized view to count the total and average order prices CREATE MATERIALIZED VIEW order details ASSELECT order id SUM item price AS total price AVG item price AS avg priceFROM order eventsGROUP BY order id Benefits of materialized views with streaming database for queryingAs we saw in the new architecture of the online store application it introduces new components such as a streaming database and query handler and provides several benefits Simple queries Materialized views can simplify the querying logic by aggregating data in advance you don t need to write complex queries with a bunch of joins Improved performance Materialized views can be optimized for specific queries reducing the latency associated with querying the main database Real time Data Access Materialized views in the streaming database can provide real time data from multiple microservices Increased scalability The streaming database can be deployed independently from the main database allowing for horizontal scaling of the query side Better fault tolerance The streaming database can be used as a fallback in case the main database goes down ConclusionCQRS with incrementally updated materialized views in the streaming database is an effective solution to the challenge of querying data across multiple microservices By separating the read and write operations and precomputing views of the data this integration provides better performance scalability and fault tolerance Related resourcesHow to choose the right streaming databaseHow Streaming database differs from a Traditional database Query Real Time Data in Kafka Using SQL Recommended contentIs RisingWave the Right Streaming Database Rethinking Stream Processing and Streaming Databases CommunityJoin the Risingwave Community About the authorVisit my blog www iambobur com |
2023-04-30 10:19:35 |
ニュース |
BBC News - Home |
Rail strikes cynically targeting Eurovision, minister says |
https://www.bbc.co.uk/news/uk-politics-65441184?at_medium=RSS&at_campaign=KARANGA
|
workers |
2023-04-30 10:15:57 |
ニュース |
BBC News - Home |
Caerphilly: Baby in hospital after dog attack |
https://www.bbc.co.uk/news/uk-wales-65441162?at_medium=RSS&at_campaign=KARANGA
|
attackthe |
2023-04-30 10:40:47 |
ニュース |
BBC News - Home |
Nurses' strike: Concern for patients ahead of England walkout |
https://www.bbc.co.uk/news/health-65412881?at_medium=RSS&at_campaign=KARANGA
|
england |
2023-04-30 10:05:12 |
ニュース |
BBC News - Home |
Call for thorough investigation after ferry grounding |
https://www.bbc.co.uk/news/uk-scotland-north-east-orkney-shetland-65441218?at_medium=RSS&at_campaign=KARANGA
|
ferry |
2023-04-30 10:54:01 |
ニュース |
BBC News - Home |
Ty Hafan: Unique bond of mums who met at children's hospice |
https://www.bbc.co.uk/news/uk-wales-65398632?at_medium=RSS&at_campaign=KARANGA
|
peaks |
2023-04-30 10:08:50 |
ビジネス |
不景気.com |
週刊不景気ニュース4/30、元上場企業の倒産が話題に - 不景気com |
https://www.fukeiki.com/2023/04/week-report-230430.html
|
上場企業 |
2023-04-30 10:31:31 |
コメント
コメントを投稿