Scaling on Kubernetes With Open Source Korifi
Korifi is an open source platform that makes deploying and managing applications on Kubernetes easy. It provides developers with a Cloud Foundry-like experience while offering the flexibility and power of Kubernetes.
One of the key benefits of Korifi is its ability to scale applications quickly. There are two main ways to scale an application in Korifi: horizontal scaling and vertical scaling.
Horizontal Scaling
Horizontal scaling is the process of adding more instances of an application to handle increased traffic. To horizontally scale an application in Korifi, you can use the cf scale command along with the -i flag.
For example, to scale your application to 10 instances, you would run the following command:
cf scale my-app -i 10
Korifi will automatically create the necessary Kubernetes resources and deploy the new instances of your application.
Vertical Scaling
Vertical scaling is the process of increasing the resources (such as memory and CPU) allocated to an existing instance of an application. To vertically scale an application in Korifi, you can use the cf scale command with the -m flag.
For example, to scale your application to 1GB of memory, you would run the following command:
cf scale my-app -m 1G
You can make a similar change with the -k flag to increase disk space. Note that when vertically scaling an application's disk space or memory limit, the change is applied to all instances of the app.
Example: Scale a Ruby Application With Korifi
Let's put this into practice. For this example, artificially creating a memory-bound Ruby app demonstrates scaling benefits. This example uses Ubuntu 22.04.2 LTS.
Clone the sample repository:
git clone https://github.com/sylvainkalache/sample-web-apps
Modify the Ruby app to simulate a memory-heavy operation by editing app.rb:
require 'sinatra'
get '/' do
Array.new(100000)
end
Korifi's default memory allocation per application instance is 1GB, but for this test, lower it to 50MB by creating a manifest:
cd ruby/
cat << EOF > manifest.yaml
---
applications:
- memory: 50M
EOF
Push the Ruby application:
cf push my-ruby-app
Once deployed, check the application status:
$ cf app my-ruby-app
The application will show one instance with 50MB allocated memory.
Send a massive number of requests using Apache Bench to stress-test the app:
apt-get install apache2-utils
ab -n 150 -c 50 https://my-ruby-app.apps-127-0-0-1.nip.io/
The mean response time will be around 4.8 seconds -- relatively slow due to memory constraints.
Now scale horizontally to five instances:
$ cf scale my-ruby-app -i 5
Benchmark again:
$ ab -n 150 -c 50 https://my-ruby-app.apps-127-0-0-1.nip.io/
The mean response time drops to approximately 0.6 seconds, demonstrating how horizontal scaling improves performance and throughput.
Conclusion
This example illustrates how Korifi makes scaling applications on Kubernetes straightforward without dealing with underlying complexity. The platform enables developers to focus on application concerns rather than infrastructure management.
Topics