Cloud native programming inherently involves working with remote endpoints: microservices, serverless, APIs, WebSockets, SaaS apps, and more. Ballerina is a new programming language that is designed to bring code-first agility to the challenge of integrating across endpoints. As we know, one of the fallacies of distributed computing is "the network is reliable". Resilience is the ability to recover to a working condition after being affected by a serious incident. Integration programmers have to be aware of such failures and also make their programs robust to deal with and recover from such failures.
In this session, Afkham will look at how Ballerina helps integration developers write resilient programs and how it helps eliminate or reduce failures due to oversight. He will also demonstrate core resiliency techniques, such as timeout, retry, circuit breaker, distributed transactions, and others.
2. “
Random House Kernerman Webster’s College dictionary
Ability to return to the original form or position after being
affected by a particular alteration.
Ability to recover from illness, depression, adversity or the like.
Resilience
8. Failures are a fact of life.
Don’t avoid failures. Embrace them.
9. Resilience
○ The ability of an app to recover from certain types of failure yet remain
functional from the users’ perspective
○ Users don’t notice it
○ Graceful degradation
○ Resilience is how you achieve the outcome
○ Also called recoverability
10. Features of resilience systems
○ Failures are compartmentalized
○ A resilient system would automatically cut off failing components and
reintegrate them once they are no longer failing
13. Don’t hide the network
○ Calls over the network should always return errors in addition to the
response
○ Network calls should be easily distinguishable
14. var backendRes = backendClientEP->forward("/hello", request);
match backendRes {
http:Response res => {
...
}
error responseError => {
log:printError("Error sending response", err = responseError);
}
}
18. Retry
○ Transient failures are not uncommon
○ In such cases, a simple retry is sufficient
○ Can be handled by
○ Retry immediately
○ Retry with a delay
○ IMPORTANT: Idempotency should be handled at the application layer
27. Circuit breaker
○ Some transient failures take much longer to recover
○ Repeatedly retrying may hinder recoverability
○ Retry up to a certain degree and cut off
35. Transactions Sample - initiator
transaction with retries = 2 {
// Calling a local participant
localParticipantDoSomething();
// Calling a remote participant
http:Response res = check participant->get(“/ParticipantService/hi”)
} onretry {
// Code here will execute before retrying
} committed {
// Code here will execute after the initiated transaction
// has committed
} aborted {
// Code here will execute after the initiated transaction
// has been aborted
}