+ All Categories
Home > Documents > Microservices external API and data management...

Microservices external API and data management...

Date post: 20-May-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
29
Microservices external API and data management patterns Nikola Zivkov @nikolazivkov Seavus
Transcript
Page 1: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Microservices external APIand data management patterns

Nikola Zivkov@nikolazivkovSeavus

Page 2: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Setting up the context

● Microservices– Small (solves one problem)– Running in own process– Individually deployable– Individually scalable– Database per service– Etc.

Page 3: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Bookstore application

Page 4: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Bookstore context map

Page 5: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Direct connection

Page 6: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Direct connection communication fow

Page 7: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Challenges (part 1)

● The number of service instances and their locations (host+port) changes dynamically.

● Partitioning into services can change over time and should be hidden from clients.

Page 8: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Solution

Reverse proxy API gateway

Page 9: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Nginx reverse proxy API gateway

Page 10: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Zuul reverse proxy API gateway

Page 11: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Reverse proxy API gateway communication fow

Page 12: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Reverse proxy API gateway summary

● Single point of entry for clients.● Multiple service instances are handled by load balancing through service discovery (Spring Cloud Ribbon).

● Other implementations: AWS API Gateway, etc.

Page 13: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Challenges (part 2)

● Microservices typically ofer ne-grained APIs resulting in multiple calls between the client and the server (chatty APIs). This is especially bad when network calls are expensive such as the case with mobile clients.

● Services might be using diverse set of protocols, some of which might not be web friendly (e.g. SOAP).

Page 14: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Solution

Composer API gateway

Page 15: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Composer API gateway

Page 16: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Composer API gateway communication fow

Page 17: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Composer API gateway summary

● Single client request is fanned out to multiple microservices.● Responses are joined in memory before returned to the client.

Page 18: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Challenges (part 3)

● Not straightforward to implement queries that join data from multiple services.

Page 19: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Solution

Command Query Responsibility Segregation(CQRS)

Page 20: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

CQRS API gateway

Page 21: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

CQRS API gateway Bookstore context map

Page 22: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

CQRS API gateway communication fow

Page 23: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

CQRS API gateway summary

● Queries are executed against one or more materialized views that are kept up to date by subscribing to streams of events emitted from microservices when data changes occur.

● Data is materialized views is eventually consistent.

Page 24: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Challenges (part 4)

● Diferent clients need diferent data. For example, the desktop browser version of a product details page is typically more elaborate than the mobile version.

Page 25: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Solution

Backend for Frontend(BFF)

Page 26: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Backend for Frontend (BFF)

Page 27: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Backend for Frontend summary

● Multiple API gateways to satisfy the needs of diferent clients.

Page 28: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

The patterns

● API gateway and BFFhttp://microservices.io/patterns/apigateway.html

● API compositionhttp://microservices.io/patterns/data/api-composition.html

● CQRShttp://microservices.io/patterns/data/cqrs.html

● And many others at...http://microservices.io/

Page 29: Microservices external API and data management patternsjug.mk/presentations/javaskop18/microservices.pdf · Challenges (part 2) Microservices typically ofer ne-grained APIs resulting

Thank You


Recommended