What is a Cloud Native Application?
Applications that are written to take full advantage of cloud computing frameworks are called cloud-native applications.
According to the Cloud Native Computer Foundation, a cloud-native application should have the below properties:

Container packaged
This means the application should be able to run in a container. This isolates the application so it is a stand-alone unit of deployment, this also makes it possible to achieve high levels of resource segregation. In a development context, this encourages the code and components to be reused and simplifies operations for cloud-native applications.

Dynamically managed
This means the application should be able to be actively scheduled and managed by a central orchestrating process. This improves machine efficiency and resource utilisation whilst reducing the cost.

Micro-services oriented
This means the development of the application is more agile and that the solutions are loosely coupled with dependencies.

Ballerina is a programming language that has all of the above properties, making it a cloud-native programming language. Ballerina reduces the effort of configuring container details in config files. Instead, all that is needed is an annotation with relevant information in the code itself. In addition, when the code i.

This is an example from a sample project for annotation level configuration for docker. Here it is configured, with the values able to be read from environment variables. You can find more details on Ballerina config parameters here.

Ballerina also provides annotation-based configuration for Kubernetes. Like Docker, when you are using Ballerina code it will generate the required YAML files relevant to the annotated configs. More detail on this can be found in the Ballerina services with Kubernetes blog.

Ballerina is specifically designed for integrations and Microservices best practice is built into the Ballerina language. As an example, this Circuit Breaker pattern in Microservice architecture can easily be configured in Ballerina as it is built into the language. What’s more, in Microservice architecture, multiple services can be participating in a global transaction. In that scenario, transaction context should be passed from one service to the other before it is then coordinated and managed. To achieve this in Ballerina transactions

can be implemented that will improve the reliability of microservice-based applications. An example can be found here.

Ballerina is network aware, so it is able to define client and server endpoints and supports HTTP/S, HTTP2, gRPC, WebSocket and JMS. The language endpoints can also be extended to support any other protocols, which is a useful feature of Ballerina.

endpoint http:Listener httpServiceEndpoint{...}
endpoint http:Client fixerClientEp {...}
endpoint grpc:Listener grpcListenerEndpoint {...}
In client endpoints apart from protocol-level endpoints, we can see there are higher level endpoints for APIs.

endpoint twitter:Client twitterClient {...}

You can find and write connectors to communicate with any API and publish it to Ballerina Central.

In line with the agile nature of the development, Ballerina is designed to take lifecycle concepts for microservices and the associated best practices into account. These elements are embedded into the language as part of Ballerina’s build system, Ballerina Central, Teseterina and Docker / K8S artefacts which are generated during the build.

Another element to mention is that with Ballerina, what is being written in the code can be visualised as a sequence diagram. This is very useful for getting an understanding of what the code is supposed to do. In an enterprise-level development project, this will be used by integration analyst or even business people to get an idea about the use case.

This sequence diagram is for a simple use case that gets exchange rates from a public API and the diagram is auto-generated based on the code written in Ballerina. Sequence diagrams are very helpful as they give a visual overview of the use case by providing a clear understanding of the flow.

Isuru Gunawardana

Associate Architect
Mitra Innovation

Leave a Reply