Edition 0 Updated to asp. Net core 0



Yüklə 11,82 Mb.
Pdf görüntüsü
səhifə37/288
tarix12.07.2023
ölçüsü11,82 Mb.
#136458
1   ...   33   34   35   36   37   38   39   40   ...   288
GraphQL Federation
One option to consider if your microservices are already using GraphQL is 
GraphQL Federation
. Federation allows you to defi
ne “subgraphs” from other services and compose 
them into an aggregate “supergraph” that acts as a standalone schema.
CQRS with query/reads tables.
Another solution for aggregating data from multiple microservices is 
the 
Materialized View pattern
. In this approach, you generate, in advance (prepare denormalized data 
before the actual queries happen), a read-only table with the data th
at’s owned by multiple 
microservices. The table has a format suited to the client app’s needs.
Consider something like the screen for a mobile app. If you have a single database, you might pull 
together the data for that screen using a SQL query that performs a complex join involving multiple 
tables. However, when you have multiple databases, and each database is owned by a different 
microservice, you cannot query those databases and create a SQL join. Your complex query becomes 
a challenge. You can address the requirement using a CQRS approach

you create a denormalized 
table in a different database that’s used just for queries. The table can be designed specifically for the 
data you need for the complex query, with a one-to-one relationship between fields needed by your 
application’s screen and the columns in the query table. It could also serve for reporting purposes.
This approach not only solves the original problem (how to query and join across microservices), but it 
also improves performance considerably when compared with a complex join, because you already 


33 
CHAPTER 3 | Architecting container and microservice-based applications 
have the data that the application needs in the query table. Of course, using Command and Query 
Responsibility Segregation (CQRS) with query/reads tables means additional development work, and 
you’ll
need to embrace eventual consistency. Nonetheless, requirements on performance and high 
scalability in 
collaborative scenarios
 (or competitive scenarios, depending on the point of view) are 
where you should apply CQRS with multiple databases. 

Yüklə 11,82 Mb.

Dostları ilə paylaş:
1   ...   33   34   35   36   37   38   39   40   ...   288




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin