5. Cloud native is building software applications as a collection of
independent, loosely coupled, business-capability-oriented
services that can run on dynamic environments in an
automated, scalable, resilient, manageable, and
observable way.
<<Design Patterns for Cloud Native Applications>> Kasun Indrasiri and Sriskandarajah Suhothayan
6. Distributed Systems Communication
Service A
• Core functionality
• Retry / Timeout
• Logging
• Configuration
request
Service B
• Core functionality
• Retry / Timeout
• Logging
• Configuration
7. Distributed Systems Communication – Sidecar
Service A
• Core functionality
Service B
• Core functionality
• Retry / Timeout
• Logging
• Service Discovery
Sidecar
• Retry / Timeout
• Logging
• Service Discovery
Sidecar
8. Problems with Cloud Native Application
Any cloud or edge infrastructure
Application Code
Client SDK
GCP SDK AWS SDK AZURE SDK Spring
9. Application Code
Problems with Cloud Native Application
Any cloud or edge infrastructure
Client SDK
GCP SDK AWS SDK AZURE SDK Spring
Application
high coupled
10. Developing Applications with Google Cloud
# Imports the Google Cloud client library
from google.cloud import datastore
# Instantiates a client
datastore_client = datastore.Client()
# The kind for the new entity
kind = "Order"
name = "order1"
# The Cloud Datastore key for the new entity
order_key = datastore_client.key(kind, name)
order = datastore.Entity(key=order_key)
order["description"] = "Milk"
order["created"] = datetime.datetime.now()
# Saves the entity
datastore_client.put(order)
Application
google-cloud-storage==1.4.0
GCP SDK
{
"Name/ID":"order1",
"description":"Milk",
"created":"2023/07/29 14:00:00"
}
Cloud Firestore
21. Application Resiliency – Retry Pattern
Service A
• Core functionality
• Retry / Timeout
(Retries = 4, duration=2 sec)
request
Service B
• Core functionality
• Retry / Timeout
200
500
500
The Retry pattern enables a service to retry a failed request operation a
(configurable) number of times with an exponentially increasing wait time.
22. Application Resiliency – Circuit Breaker Pattern
Service A
• Core functionality
• Retry / Timeout
(Retries=4, duration=2 sec)
• Circuit Breaker
(failed count = 5, check = 30sec)
request
Service B
• Core functionality
• Retry / Timeout
The Circuit Breaker pattern can prevent an application from repeatedly trying
to execute an operation that's likely to fail. After a pre-defined number of failed
calls, it blocks all traffic to the service.
5
23. resiliency.yaml
apiVersion: dapr.io/v1alpha1
kind: Resiliency
metadata:
name: myresiliency
spec:
policies:
retries:
retryForever:
policy: constant
duration: 5s
maxRetries: -1
circuitBreakers:
simpleCB:
maxRequests: 1
timeout: 5s
trip: consecutiveFailures >= 5
• Resiliency patterns can be applied across
Dapr APIs
• Retries
• Timeouts
• Circuit breakers
• Declarative and decoupled from
application code
• Available across all component types,
service invocation and actors.
Dapr - Resiliency
25. Order
Processor
Checkout
Pub/sub queue
Inbound
Outbound
1
Outbound component resiliency
policies for `retries`, `timeouts and
`circuit breakers` can be applied to
message publishing
1
Additionally, many pub/sub
components have `retry` capabilities
built-in. The policies are configured
on a per component basis.
Resiliency in PubSub
1
Inbound component resiliency polices for
`retries`, `timeouts and `circuit breakers`
policies can be applied to subscriptions
when delivering messages
26. Key Takeaways
💪 Cloud Native Application on Google Cloud
💪 Decoupling from Cloud Provider/Infra with Dapr
💪 Resilience patterns and implement with Dapr