“Microservices” is certainly a buzzword. Everybody wants to work on microservices applications. However when working on such a project you’ll soon realize that a buzzword doesn’t magically make your application work. And there will be a lot of challenges that you’ll face on this journey. During this session I will share my experience from the trenches of a microservices project aiming to make developers aware of the different challenges you’ll mostly won’t see at conferences. I will also try to illustrate my experiences with relevant code samples.
6. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Services are…
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• small in size
• messaging enabled
• bounded by contexts
• autonomously developed
• independently deployable
• decentralized
• built and released with automated processes
8. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Drawbacks?
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Let's discuss them at the end :)
9. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
The project
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• The customer is a provider of integrated systems
for Contact Centers
• Rich application ecosystem
• Goal: Rebuild the Time and Attendance solution to
meet modern software architecture standards and
business needs
• How? Use Microservices architecture
11. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Decomposing models
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• By business capability and define services corresponding to business
capabilities
• By DDD bounded contexts
• By verb or use case and define services that are responsible for
particular actions. e.g. a Shipping Service that’s responsible for
shipping complete orders
• By nouns or resources by defining a service that is responsible for all
operations on entities/resources of a given type. e.g. an Account
Service that is responsible for managing user accounts
12. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Issues
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• How to identify the bounded contexts?
• How to identify business capabilities?
• Which decomposition model is suitable for a given scenario?
• Is it really possible to decompose everything in a meaningful way
following only one model?
15. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Issues
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• A microservices architecture is all about communication
• How should services communicate in any given business scenario?
• Should they call each other synchronously?
• Should they communicate via asynchronous messaging?
• What are the pros and cons of the chosen message brokering
technology?
16. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Communication patterns
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Synchronous Calls if:
• we want to query some data, because a query is not changing any state so we don’t have to
worry about distributed transactions and data consistency across service boundaries
• the call is allowed to fail and we don’t need a sophisticated retry mechanism
Simple Messaging if:
we want to send state-changing commands
• the operation must be performed eventually, even if it fails the first couple times
• we don’t care about potentially complex message structure
Transactional Messaging if:
• we want to send state-changing commands only when the local database transaction has
been successful
17. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Message broker concepts
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Producer - User application that sends messages to an exchange.
• Exchange - Pushes messages into queues. Exchange types define what to do
with the message when it’s received, whether. appended to a one queue, to
many queues, or discarded. Example exchange types are direct, topic and
fanout.
• Queue - Each exchange contains a buffer, or queue, that stores messages. A
queue is only bound by the host’s memory & disk limits, it’s essentially a large
message buffer. Many producers can send messages that go to one queue, and
many consumers can try to receive data from one queue.
• Consumer - User application that receives messages.
18. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
DEMO:
Messaging infrastructure
19. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
Lessons learned:
3. The API gateway
20. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
What should an API gateway do?
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Proxying
• Service discovery
• Response aggregation
• Header translation
• Protocol translation
• Load balancing
• Authorization
• Rate limiting
21. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Available options
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• All the major cloud providers offer such services
• Kubernetes has such a functionality
Drawbacks
• Technology debt
• Additional complexity when setting up environments
• Not very flexible
22. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
A possible solution in the .NET world…
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• Meets all discussed requirements
• Easy to configure
• Can be extended with own
functionality
24. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Conclusions
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
• A microservices architecture adds a lot of complexity that we might tend to
oversea in the planning phase
• Are the benefits really outnumbering the complexities?
• A microservices architecture is not only about software architecture, but also
about the organization and how teams are set up
25. Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
Before deciding on going for a
microservices architecture try to
ask yourself if it’s worth