Updated: Sep 12, 2021
Cloud Foundry is a cloud native application development and hosting platform. In Cloud Foundry Developers can easily deploy and manage their application(s). Cloud foundry is a Platform as a Service (PaaS). This platform is used for application development and hosting, Specially microservices. Here is a list of few compelling advantages applications developers have when they use cloud foundry to host their applications.
Advantages of using Cloud Foundry platform for hosting an application:
Next, I will explain each of them.
Declarative definition of application deployment information
In Cloud Foundry we can use cloud foundry CLI commands to deploy/restart/delete applications. The CLI can be installed in all major OS. Here you can find how to install the CLI. We can also adjust some deployment parameters related to the application. The typical information needed by Cloud Foundry’s Cloud Controller to deploy an application is its name, size of required memory, required disk size, the route and many more. We can save these configuration parameters in a declarative file and use it for deployments and redeployments. This finale is called manifest file. We just need to provide this file to the Cloud Foundry in the deployment command and the platform will take care of the rest. In a separate blog I have described how to write a manifest.
Application is guaranteed to be always up - No Downtime
Once an application is deployed in Cloud Foundry, it saves all the declarative parameters provided during deployment with the deployable file (for example jar). For any reason if an application crashes, Cloud Foundry is clever enough to detect that and restart the application using saved information, you will only lose the content of memory meaning the status of the objects and variables and ongoing tasks being executed by the application will be incomplete. But the platform takes care to reboot your application from scratch. That's what it's preferable to host stateless applications in Cloud Foundry, otherwise you need to take care of saving and retrieving the states and sessions. It's still great because you have achieved zero down time which is crucial for cloud ready applications. It saves you from getting phone calls in the middle of the night to wake up and restart a crashed application.
To update an application with its new version you do not have to bring down the application. Cloud foundry provides you ways using which you can deploy a new version of the application, the platform takes care to update the application without downtime. It gives your users 24/7 availability. It's also known as blue-green update.
Automatic Load Balancing
You can deploy more than one instance of the application. Each application will do the same work. It helps the application to handle load. When more than one instance of the same application is running, Cloud Foundry automatically loads the incoming HTTP traffic to each instance evenly. You just need to make sure that your application is stateless.
Easy Vertical and Horizontal scaling of application
A running application can be scaled up or down using commands. The scaling can be vertical meaning increasing or decreasing disk and/or memory. The scaling can also be horizontal. In this case we can increase or decrease the number of instances. When we scale horizontally we don't need a down time, it is dynamic. The platform already has all the information to spin up a new instance if we scale up. The platform also automatically load balanced across all instances.
Automatic Detection of Build packs
Build packs are the framework and runtime needed to deploy and run applications. For java it will be java runtime for nodeJS it will be nodeJS packages and runtime. For each type of programming language and corresponding executable there is a build pack. The good thing is when you deploy your application, cloud foundry can examine your application automatically identify which build pack is needed to deploy and run the application. Cloud Foundry will then use the appropriate build pack to prepare the application to deploy and run your application. Optionally you also can mention the build pack and its version in your manifest.
Automated Health Check
In the microservices world you need to proactively determine application down events and bring your application up and running as soon as possible. The first step is to detect that an application is down. Cloud foundry allows you to provide means using which it can periodically detect the liveliness of an application. For example you can provide a /health HTTP endpoint of type GET that returns with a 200 HTTp response code. Then mention in the manifest that the health check has been done using this endpoint. The platform takes the pain to periodically ping the endpoint to know if the required number of instances of your are running. As I wrote before the platform will start a new instance immediately, if any of the instances fail to respond within a certain amount of predefined time.
Array of off-the-shelf Reusable Services
There are off-the-shelf reusable services in cloud foundry which the application developer takes the advantage of. For example, databases like MongoDB, PostgreSQL, Messaging service like RabitMQ and many more.
Application developers can create an instance of the required resualbe service and bind the reusable service finance with the application. Binding is explained in detail in another blog, but the essence is binding allows the application to get the configuration needed to interact with the service instance. For example the Host, Port, user name, password and database name for a database instance. Application developers are not required to manage the database, they don't have to think about data replication ,database down time, crash and recovery. It's the job of the reusable service provider. These reusable services could be paid services but follow the “pay per use” model. With this handled application developers can focus on developing business logic.
Create Your Own Reusable Service
Application developers can develop their own reusable service instance and make it available for the rest of the platform users to use it. The reusable application needs to follow the reusable service framework for the platform users to use. Then the service needs to be registered in Cloud Foundry Cloud Controller. In this way
We can have our own reusable service.
Each landscape can have its own default domain as well as extra and custom named domain also can be configured, though that is the admin’s task not the application developers.
The above advantages are huge when we look from the perspective of application management in production in the cloud where a software is expected to be available 99% of its lifetime. It helps application developers concentrate on the business logic that application is really built for.