Serverless Ballerina
Rodric Rabbah
Apache OpenWhisk
@rabbah
Adnan Abdulhussein
Kubeless
@prydonius
Agenda
○ Serverless Computing
○ Serverless Ballerina with Apache OpenWhisk
○ Serverless Ballerina with Kubeless
To understand Server-less,
let us review Server-full.
What is Serverless Computing?
Server-full Computing
○ API or REST endpoint, e.g., “/hello”
○ Request/Response handler or function...
… to accept input, return output
The Function
public function msg(json data) returns json {
  json? name = data.name;
  if (name == null) {
    return { msg: "hello world!" };
  } else {
    return { msg: "hello " + name.toString() + "!" };
  }
}
input output
{ } → { msg: “hello world!” }
{ name: “san francisco” } → { msg: “hello san francisco!” }
hello-function.bal
The Server hello-server.bal
import ballerina/http;
endpoint http:Listener listener { port: 8080 };
service default bind listener {
  hello(endpoint caller, http:Request req) {
var params = req.getQueryParams();
json body = params.hasKey("name") ? { name: params.name } : {};
http:Response res = new;
    res.setPayload(msg(body));
    _ = caller->respond(res);
  }
}
Run the Server
> ballerina run hello-server.bal
ballerina: initiating service(s) in 'hello.bal'
ballerina: started HTTP/WS endpoint 0.0.0.0:8080
localhost:8080/default/hello
localhost:8080/default/hello?name=san francisco
Deploy the Server
VM
rent bare metal
rent virtual machine
rent a container
Deploy the Server
VM
rent bare metal
rent virtual machine
rent a container
Manage servers.
Operate servers.
Secure servers.
Scale servers.
Pay for servers...
… Even when idle.
So what is Serverless Computing?
VM
Function
with serverless, there is the function,
and only the function, for you to
create, deploy and operate.
Serverless Ballerina in
Apache OpenWhisk
3337 stars, 631 forks
120 contributors
Serverless Functions with
Partners: Adobe, IBM, Red Hat
Many on-prem deployments
Use as hosted service from IBM, Adobe
And now available from WSO2
Deploys to Kube, Mesos, OpenShift, VMs
Run full stack on your laptop
Topped Hacker News in February
912 on Slack
https://openwhisk.apache.org
Reminder: The Function
public function msg(json data) returns json {
  json? name = data.name;
  if (name == null) {
    return { msg: "hello world!" };
  } else {
    return { msg: "hello " + name.toString() + "!" };
  }
}
hello-function.bal
Deploy the Function
> wsk action create hello hello-function.bal --web true
ok: created action hello
guest.localhost/default/hello.json
guest.localhost/default/hello.json?name=san francisco
Under the hood
“Deploy my code hello-function.bal as a function named hello”
hello = hello-function.bal
Function is deployed.
Nothing is running.
Your cost is $0.
Controller
Code Store
Executor
Under the hood
“Run my function hello and return the result”
Controller
Code Store
Executor
Function starts to execute within milliseconds.
You pay for the duration of the function.
Functions auto-scale with load.
GET /hello
Functions run
in containers.
Apache OpenWhisk running locally on Mac OS
Some executions are
“cold starts”.
OpenWhisk hides
container startup latency.
Apache OpenWhisk running locally on Mac OS
58 ms:
container assigned
Once a function is
loaded, it is ready to
execute.
Apache OpenWhisk running locally on Mac OS
499 ms:
function loaded
Apache OpenWhisk running locally on Mac OS
warm starts
OpenWhisk schedules
functions to containers,
and maximize “warm
starts”.
Another example: using Ballerina central packages
import wso2/twitter;
public function run(json args) returns json {
endpoint twitter:Client tw {
clientId: args.clientId,
clientSecret: args.clientSecret,
accessToken: args.accessToken,
accessTokenSecret: args.accessTokenSecret,
clientConfig: {}
};
twitter:Status st = check tw->tweet(args.data);
return { status: st.text };
}
OpenWhisk Functions are Reactive
Serverless use cases
Periodic and scheduled events
run function when ...
Integrated with event sources
crop images, analyze content, transform data, conversation bots
Batch processing
integrate with data and object stores
What about this Server part?
import ballerina/http;
endpoint http:Listener listener { port: 8080 };
@http:ServiceConfig { basePath: "/" }
service default bind listener {
  @http:ResourceConfig { methods:["GET"], path: "/hello" }
  hello(endpoint caller, http:Request req) {
var params = req.getQueryParams();
json body = params.hasKey("name") ? { name: params.name } : {};
http:Response res = new;
    res.setPayload(msg(body));
    _ = caller->respond(res);
  }
}
Ballerina’s cloud-native edge
● Integrated application architecture
○ The “server” maps routes to functions
○ Generate Swagger → Configure API Gateway
Ballerina’s cloud-native edge
● Integrated application architecture
○ The “server” maps routes to functions
○ Generate Swagger → Configure API Gateway
● Functions as APIs and APIs as Functions
○ Single semantic-domain
● Integrate Functions in any language
Ballerina’s cloud-native edge
● Integrated application architecture
○ The “server” maps routes to functions
○ Generate Swagger → Configure API Gateway
● Functions as APIs and APIs as Functions
○ Single semantic-domain
● Integrate Functions in any language
● Leverage Ballerina’s built-in network type-system, error handling
Serverless Ballerina in
Kubeless
Kubernetes-native Serverless Platform
https://github.com/kubeless/kubeless
Why Kubernetes?
○ Production-grade orchestration system
○ Infrastructure as code
○ Suited for microservice architectures
○ Easily extendable to build abstractions/APIs on to
Deploy a function
$ kubeless function deploy hello 
--runtime ballerina0.980.0 
--handler hello.foo 
--from-file helloget.bal
import kubeless/kubeless;
public function foo(
kubeless:Event event,
kubeless:Context context)
returns (string|error)
{
return "Hello World Ballerina";
}
Under the hood
Function
Custom
Resource
Service
(for HTTP triggers)
ConfigMap
Deployment
kubeless client or kubectl Code
Code
Q & A
THANK YOU

More Related Content

PDF
Autoscaling with hashi_corp_nomad
PDF
Lies, Damn Lies, and Benchmarks
PDF
Rack Middleware
PDF
8 Minutes On Rack
PDF
Selenium sandwich-3: Being where you aren't.
PDF
A reviravolta do desenvolvimento web
PDF
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
KEY
Intro to PSGI and Plack
Autoscaling with hashi_corp_nomad
Lies, Damn Lies, and Benchmarks
Rack Middleware
8 Minutes On Rack
Selenium sandwich-3: Being where you aren't.
A reviravolta do desenvolvimento web
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
Intro to PSGI and Plack

What's hot (20)

PDF
Testing your infrastructure with litmus
PDF
Ruby HTTP clients comparison
PDF
Inside Bokete: Web Application with Mojolicious and others
PPTX
Capistrano - automate all the things
PDF
Beyond Breakpoints: A Tour of Dynamic Analysis
PPS
Web Development in Perl
KEY
Plack at YAPC::NA 2010
PPTX
Getting Started with Capistrano
PDF
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
PDF
Altitude NY 2018: Programming the edge workshop
PDF
Testing http calls with Webmock and VCR
PDF
Ruby HTTP clients
PDF
Perl in the Internet of Things
PDF
Static Typing in Vault
PPTX
PowerShell: Automation for everyone
KEY
Php resque
PDF
Asynchronous programming patterns in Perl
PPT
Capistrano
PPTX
SPSTC - PowerShell - Through the SharePoint Looking Glass
ODP
Modern Web Development with Perl
Testing your infrastructure with litmus
Ruby HTTP clients comparison
Inside Bokete: Web Application with Mojolicious and others
Capistrano - automate all the things
Beyond Breakpoints: A Tour of Dynamic Analysis
Web Development in Perl
Plack at YAPC::NA 2010
Getting Started with Capistrano
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Programming the edge workshop
Testing http calls with Webmock and VCR
Ruby HTTP clients
Perl in the Internet of Things
Static Typing in Vault
PowerShell: Automation for everyone
Php resque
Asynchronous programming patterns in Perl
Capistrano
SPSTC - PowerShell - Through the SharePoint Looking Glass
Modern Web Development with Perl
Ad

Similar to Serverless Ballerina (20)

PPT
Spring data iii
PDF
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
PDF
About Node.js
PDF
Websockets talk at Rubyconf Uruguay 2010
KEY
Writing robust Node.js applications
PDF
Into The Box | Alexa and ColdBox Api's
PDF
Socket.IO
PDF
Play Framework: async I/O with Java and Scala
PDF
Intro to Asynchronous Javascript
PPT
Play!ng with scala
KEY
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
PDF
Flask and Angular: An approach to build robust platforms
PDF
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
PDF
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
PDF
Nodejs Explained with Examples
PDF
Nodejsexplained 101116115055-phpapp02
PDF
Server Side Swift: Vapor
PDF
HTML5: huh, what is it good for?
KEY
Using and scaling Rack and Rack-based middleware
PDF
HTML5 tutorial: canvas, offfline & sockets
Spring data iii
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
About Node.js
Websockets talk at Rubyconf Uruguay 2010
Writing robust Node.js applications
Into The Box | Alexa and ColdBox Api's
Socket.IO
Play Framework: async I/O with Java and Scala
Intro to Asynchronous Javascript
Play!ng with scala
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Flask and Angular: An approach to build robust platforms
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Nodejs Explained with Examples
Nodejsexplained 101116115055-phpapp02
Server Side Swift: Vapor
HTML5: huh, what is it good for?
Using and scaling Rack and Rack-based middleware
HTML5 tutorial: canvas, offfline & sockets
Ad

More from Ballerina (20)

PDF
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
PDF
Ballerina in the Real World: Motorola_KubeCon 2018
PDF
Ballerina integration with Azure cloud services_KubeCon 2018
PDF
Ballerina is not Java_KubeCon 2108
PDF
Microservice Integration from Dev to Production_KubeCon2018
PDF
Building a Microgateway in Ballerina_KubeCon 2108
PDF
Ballerina ecosystem
PDF
Orchestrating microservices with docker and kubernetes
PDF
Data integration
PDF
Service resiliency in microservices
PDF
Microservices integration
PDF
Writing microservices
PDF
Ballerina philosophy
PDF
Ballerina: Cloud Native Programming Language
PPTX
Writing services in Ballerina_Ballerina Day CMB 2018
PPTX
Resiliency & Security_Ballerina Day CMB 2018
PDF
Stream Processing with Ballerina
PDF
Secure by Design Microservices & Integrations
PDF
Observability with Ballerina
PDF
Test Driven Development for Microservices
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina is not Java_KubeCon 2108
Microservice Integration from Dev to Production_KubeCon2018
Building a Microgateway in Ballerina_KubeCon 2108
Ballerina ecosystem
Orchestrating microservices with docker and kubernetes
Data integration
Service resiliency in microservices
Microservices integration
Writing microservices
Ballerina philosophy
Ballerina: Cloud Native Programming Language
Writing services in Ballerina_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
Stream Processing with Ballerina
Secure by Design Microservices & Integrations
Observability with Ballerina
Test Driven Development for Microservices

Recently uploaded (20)

PDF
Practical Indispensable Project Management Tips for Delivering Successful Exp...
PDF
Microsoft Office 365 Crack Download Free
PDF
infoteam HELLAS company profile 2025 presentation
PDF
Website Design & Development_ Professional Web Design Services.pdf
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PDF
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
PPTX
hospital managemt ,san.dckldnklcdnkdnkdnjadnjdjn
PPTX
Presentation by Samna Perveen And Subhan Afzal.pptx
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
PDF
AI-Powered Fuzz Testing: The Future of QA
PPTX
Download Adobe Photoshop Crack 2025 Free
PPTX
Computer Software - Technology and Livelihood Education
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PDF
E-Commerce Website Development Companyin india
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
Practical Indispensable Project Management Tips for Delivering Successful Exp...
Microsoft Office 365 Crack Download Free
infoteam HELLAS company profile 2025 presentation
Website Design & Development_ Professional Web Design Services.pdf
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
MiniTool Power Data Recovery 12.6 Crack + Portable (Latest Version 2025)
hospital managemt ,san.dckldnklcdnkdnkdnjadnjdjn
Presentation by Samna Perveen And Subhan Afzal.pptx
Full-Stack Developer Courses That Actually Land You Jobs
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
CCleaner 6.39.11548 Crack 2025 License Key
What Makes a Great Data Visualization Consulting Service.pdf
Cloud Native Aachen Meetup - Aug 21, 2025
HackYourBrain__UtrechtJUG__11092025.pptx
AI-Powered Fuzz Testing: The Future of QA
Download Adobe Photoshop Crack 2025 Free
Computer Software - Technology and Livelihood Education
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
E-Commerce Website Development Companyin india
CapCut PRO for PC Crack New Download (Fully Activated 2025)

Serverless Ballerina

  • 1. Serverless Ballerina Rodric Rabbah Apache OpenWhisk @rabbah Adnan Abdulhussein Kubeless @prydonius
  • 2. Agenda ○ Serverless Computing ○ Serverless Ballerina with Apache OpenWhisk ○ Serverless Ballerina with Kubeless
  • 3. To understand Server-less, let us review Server-full. What is Serverless Computing?
  • 4. Server-full Computing ○ API or REST endpoint, e.g., “/hello” ○ Request/Response handler or function... … to accept input, return output
  • 5. The Function public function msg(json data) returns json {   json? name = data.name;   if (name == null) {     return { msg: "hello world!" };   } else {     return { msg: "hello " + name.toString() + "!" };   } } input output { } → { msg: “hello world!” } { name: “san francisco” } → { msg: “hello san francisco!” } hello-function.bal
  • 6. The Server hello-server.bal import ballerina/http; endpoint http:Listener listener { port: 8080 }; service default bind listener {   hello(endpoint caller, http:Request req) { var params = req.getQueryParams(); json body = params.hasKey("name") ? { name: params.name } : {}; http:Response res = new;     res.setPayload(msg(body));     _ = caller->respond(res);   } }
  • 7. Run the Server > ballerina run hello-server.bal ballerina: initiating service(s) in 'hello.bal' ballerina: started HTTP/WS endpoint 0.0.0.0:8080 localhost:8080/default/hello localhost:8080/default/hello?name=san francisco
  • 8. Deploy the Server VM rent bare metal rent virtual machine rent a container
  • 9. Deploy the Server VM rent bare metal rent virtual machine rent a container Manage servers. Operate servers. Secure servers. Scale servers. Pay for servers... … Even when idle.
  • 10. So what is Serverless Computing? VM Function with serverless, there is the function, and only the function, for you to create, deploy and operate.
  • 12. 3337 stars, 631 forks 120 contributors Serverless Functions with Partners: Adobe, IBM, Red Hat Many on-prem deployments Use as hosted service from IBM, Adobe And now available from WSO2 Deploys to Kube, Mesos, OpenShift, VMs Run full stack on your laptop Topped Hacker News in February 912 on Slack https://openwhisk.apache.org
  • 13. Reminder: The Function public function msg(json data) returns json {   json? name = data.name;   if (name == null) {     return { msg: "hello world!" };   } else {     return { msg: "hello " + name.toString() + "!" };   } } hello-function.bal
  • 14. Deploy the Function > wsk action create hello hello-function.bal --web true ok: created action hello guest.localhost/default/hello.json guest.localhost/default/hello.json?name=san francisco
  • 15. Under the hood “Deploy my code hello-function.bal as a function named hello” hello = hello-function.bal Function is deployed. Nothing is running. Your cost is $0. Controller Code Store Executor
  • 16. Under the hood “Run my function hello and return the result” Controller Code Store Executor Function starts to execute within milliseconds. You pay for the duration of the function. Functions auto-scale with load. GET /hello
  • 17. Functions run in containers. Apache OpenWhisk running locally on Mac OS
  • 18. Some executions are “cold starts”. OpenWhisk hides container startup latency. Apache OpenWhisk running locally on Mac OS 58 ms: container assigned
  • 19. Once a function is loaded, it is ready to execute. Apache OpenWhisk running locally on Mac OS 499 ms: function loaded
  • 20. Apache OpenWhisk running locally on Mac OS warm starts OpenWhisk schedules functions to containers, and maximize “warm starts”.
  • 21. Another example: using Ballerina central packages import wso2/twitter; public function run(json args) returns json { endpoint twitter:Client tw { clientId: args.clientId, clientSecret: args.clientSecret, accessToken: args.accessToken, accessTokenSecret: args.accessTokenSecret, clientConfig: {} }; twitter:Status st = check tw->tweet(args.data); return { status: st.text }; }
  • 23. Serverless use cases Periodic and scheduled events run function when ... Integrated with event sources crop images, analyze content, transform data, conversation bots Batch processing integrate with data and object stores
  • 24. What about this Server part? import ballerina/http; endpoint http:Listener listener { port: 8080 }; @http:ServiceConfig { basePath: "/" } service default bind listener {   @http:ResourceConfig { methods:["GET"], path: "/hello" }   hello(endpoint caller, http:Request req) { var params = req.getQueryParams(); json body = params.hasKey("name") ? { name: params.name } : {}; http:Response res = new;     res.setPayload(msg(body));     _ = caller->respond(res);   } }
  • 25. Ballerina’s cloud-native edge ● Integrated application architecture ○ The “server” maps routes to functions ○ Generate Swagger → Configure API Gateway
  • 26. Ballerina’s cloud-native edge ● Integrated application architecture ○ The “server” maps routes to functions ○ Generate Swagger → Configure API Gateway ● Functions as APIs and APIs as Functions ○ Single semantic-domain ● Integrate Functions in any language
  • 27. Ballerina’s cloud-native edge ● Integrated application architecture ○ The “server” maps routes to functions ○ Generate Swagger → Configure API Gateway ● Functions as APIs and APIs as Functions ○ Single semantic-domain ● Integrate Functions in any language ● Leverage Ballerina’s built-in network type-system, error handling
  • 30. Why Kubernetes? ○ Production-grade orchestration system ○ Infrastructure as code ○ Suited for microservice architectures ○ Easily extendable to build abstractions/APIs on to
  • 31. Deploy a function $ kubeless function deploy hello --runtime ballerina0.980.0 --handler hello.foo --from-file helloget.bal import kubeless/kubeless; public function foo( kubeless:Event event, kubeless:Context context) returns (string|error) { return "Hello World Ballerina"; }
  • 32. Under the hood Function Custom Resource Service (for HTTP triggers) ConfigMap Deployment kubeless client or kubectl Code Code
  • 33. Q & A