AWS ISV Event - Unlocking Business Agility with the AWS Serverless Application Model
Matt Fellows, Principal Consultant from DiUS will talk about the evolution to serverless architectures, and discuss key development and testing practices for these modern distributed systems
3. WHAT WE ARE KNOWN FOR
3
Microservices
Evolution Drivers for levelling up
● Increase time-to-value
● Increase utilisation / cost
reduction
● Raise abstraction; focus on
composition
● Scale product teams
● Massively distributed,
real-time apps
● API contracts (e.g. OAS)
● Ubiquity of cloud computing
● Rise of containers
● Unreliable networking /
components
● Rise of the Service Mesh
● Improved observability
Why Serverless? > Drivers
9. 9
Trends > Data pipelines > Before
Systems of Record
Integration / Middleware
APIs
Presentation
Synchronous,
coupled invocation
Data locked here
10. 10
Trends > Data pipelines > After
System of Record
Event
API
Local cache /
materialised view
API
3. Event processed into local
view of data
1. Change of system state
2. Event is shared
11. Observations
Architecture > Microservices
● Democratisation of data
○ “Everyone gets a data”
● Hollywood Principle
● Pipelines are the new batch
● Prerequisite for AI/ML
● Composition and enrichment
● Lambda to “glue” steps together
15. New approach
● Scheduled Lambda to replace “cron” jobs
● Real-time cron - event-driven
● Function written and deployed as code -
first class citizens
Rise of the OODA loop
Trends > IT Ops Automation
18. 18
API Gateway
Trends > Microservices > Before
Services
Services
Team 1: Orders Team 2: Identity
Services
Team ...
Team 3:
Experience
19. 19
Trends > Microservices > After > New Patterns
API
External
Events
API
Outside World
Microservice
Interface
API
Master Data
API
Inside bounded context
Event Emitters
API
Materialised view /
cache
Events and
Processing
Data
Event Handlers
Processing
Offline Processing
20. 20
Provisioning
Amazon ML
Trends > Microservices > After > Example Team 1 Bounded Context
Place Order API
External
Events
Order Status API
Outside World
Internal Events
Microservice
Interface
Data, Events and
Processing
Suggestions API
Publish Event
to external
subscribers
Insights /
Predictions
Customer /
Other Event
Orders
Push API
Inside bounded context
CRM
Materialised view of
customer
Provisioning Event
External
Events
… API
21. 21
Trends > Microservices > Evolution
Sizeofthing
Number of communicating things
Monolith
SOA
Serverless
Microservices
Fn
Luckily, built on the
same primitive!
22. Observations
Architecture > Microservices
● Microservices still a thing
○ ..but are now just the interface of the
iceberg
● Further decomposition of services into
smaller functions
● Event-driven + asynchronous >
synchronous invocation
● Lambda and managed services as “glue”
● Architectural composition
BUT - More things to manage
23. Summary
Architecture > Microservices
● Serverless as a higher-order system
○ Composition
● IT Operations Automation
○ Better discipline (OODA)
○ Everything as code
● Microservices still a thing, new designs
emerging
○ Event-driven and loosely coupled
○ “Iceberg” patterns
24. 24
Much Compose! So speed!
Architecture > Functions + Serverless (Cloud Native)Architecture > Functions + Serverless (Cloud Native)
26. 26
If you can’t build a good monolith you
shouldn’t be doing microservices
Architecture > Microservices
27. ...the µServices
ride
● Ability to write a modular monolith
● Strong grasp on your domain model
● Ability to design loosely coupled services
○ = state + transactions
● Ability to scale and decouple teams
● Ability to deploy continuously
● A strong “DevOps” culture
● Be comfortable with decentralised,
complex systems + uncertainty
Architecture > Microservices
28. 28
If you can’t build good microservices
you shouldn’t be doing serverless
Architecture > Functions + Serverless (Cloud Native)
29. 29
What practices do we need in this
new world?
Architecture > Functions + Serverless (Cloud Native)
35. WHAT WE ARE KNOWN FOR
35
Options
● ...
Challenges
● Observability + Tracing
● Structured logging
● Shift responsibility into
platform
● Good acceptance tests
Challenges > Vendor lock-in
38. WHAT WE ARE KNOWN FOR
38
Options
● Multi-cloud = lowest
common denominator
● There is always a vendor
(even if it’s you!)
● You’ll never be completely
vendor agnostic
● Multi-cloud abstraction
● Avoid altogether
● Structure your code better
Challenges
Challenges > Vendor lock-in
39. WHAT WE ARE KNOWN FOR
39
Options
● Multi-cloud = lowest
common denominator
● There is always a vendor
(even if it’s you!)
● You’ll never be completely
vendor agnostic
● Multi-cloud abstraction
● Avoid altogether
● Structure your code better
Challenges
Challenges > Vendor lock-in
46. Summary
Architecture > Microservices
● Separate protocol handling from
business logic
● Business logic shouldn’t change with
introduction of a new protocol
● Port, Adapter and Business Logic are
independently testable
47. 47
How do you test locally?
Challenges > Testing Locally
48. WHAT WE ARE KNOWN FOR
48
Options
Challenges > Testing Locally
● Stub services (e.g. Localstack)
● Multiple handlers
● Stub API (e.g. Moto)
● Unit tests
50. WHAT WE ARE KNOWN FOR
50
Options
● Feature arms race
● Trustworthy?
● Integration style = slower
● All cloud providers?
● Stub services (e.g. Localstack)
● Stub API (e.g. Moto)
● Multiple handlers
● Unit tests
Challenges > Testing Locally
Challenges
51. WHAT WE ARE KNOWN FOR
51
Writing good unit tests
● Follow test pyramid
● Stub out AWS APIs
● Test your business logic
separately from any
serverless features (e.g.
lambda handler)
● Callback pyramid of death
● Tests are hard to write
● Your business logic knows
about AWS
● You have to stub multiple
services per test
● Large methods
● Confusing control flow
Challenges > Testing Locally > Unit Test
Code Smells
57. Summary
Architecture > Microservices
● Business logic should be tested
separately from port + adapter
● Majority of tests, should be fast unit
tests
● Stub AWS Services where required
● (Lambda) Handlers can be locally
integration tested with pre-canned JSON
events
60. WHAT WE ARE KNOWN FOR
60
Options
● Local integration testing
● Cloud env. integration testing
● Contract testing
Challenges > Async
61. WHAT WE ARE KNOWN FOR
61
Options
● Can’t run complete local
environment
● Many moving parts
● Problems with integration
testing...
● Local integration testing
● Cloud env. integration testing
● Contract testing
Challenges
Challenges > Async
62. WHAT WE ARE KNOWN FOR
62
Options
● Can’t run complete local
environment
● Many moving parts
● Problems with integration
testing...
● Local integration testing
● Cloud env. integration testing
● Contract testing
Challenges
Challenges > Async
67. WHAT WE ARE KNOWN FOR
67
Problems with automated e2e tests
● Slow
● Easy to break
● Hard to fix
● Scales badly across teams
● Lots of set up maintenance
● $$ potentially costly
Challenges > Async > Contract Tests
69. WHAT WE ARE KNOWN FOR
69
Test symmetry
Solved problems New problems
● Hard to keep both sides in
sync
● Fast feedback
● Few dependencies
● No dedicated environment
● Reliable
● Easy to debug
Challenges > Async > Contract Tests