SlideShare a Scribd company logo
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

What's hot

Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
Bram Vogelaar
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
Yusuke Wada
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
John Cleary
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
Fastly
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
Naveen Gupta
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
LaunchAny
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Fastly
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshop
Fastly
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCR
Kerry Buckley
 
Ruby HTTP clients
Ruby HTTP clientsRuby HTTP clients
Ruby HTTP clients
Zoran Majstorovic
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
Dave Cross
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
GlynnForrest
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
Gavin Barron
 
Php resque
Php resquePhp resque
Php resque
Chaitanya Kuber
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
deepfountainconsulting
 
Capistrano
CapistranoCapistrano
Capistrano
Jason Noble
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking Glass
Brian Caauwe
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
Dave Cross
 

What's hot (20)

Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
 
Plack at YAPC::NA 2010
Plack at YAPC::NA 2010Plack at YAPC::NA 2010
Plack at YAPC::NA 2010
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
 
Altitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshopAltitude NY 2018: Programming the edge workshop
Altitude NY 2018: Programming the edge workshop
 
Testing http calls with Webmock and VCR
Testing http calls with Webmock and VCRTesting http calls with Webmock and VCR
Testing http calls with Webmock and VCR
 
Ruby HTTP clients
Ruby HTTP clientsRuby HTTP clients
Ruby HTTP clients
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
 
Php resque
Php resquePhp resque
Php resque
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
Capistrano
CapistranoCapistrano
Capistrano
 
SPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking GlassSPSTC - PowerShell - Through the SharePoint Looking Glass
SPSTC - PowerShell - Through the SharePoint Looking Glass
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 

Similar to Serverless Ballerina

Spring data iii
Spring data iiiSpring data iii
Spring data iii
명철 강
 
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
ContainerDays NYC 2016: "OpenWhisk: A Serverless Computing Platform" (Rodric ...
DynamicInfraDays
 
Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Ismael Celis
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api's
Ortus Solutions, Corp
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
Arnout Kazemier
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
Siarzh Miadzvedzeu
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
Ayush Sharma
 
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
Hue: Big Data Web applications for Interactive Hadoop at Big Data Spain 2014
gethue
 
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Server-Side Push: Comet, Web Sockets come of age (OSCON 2013)
Brian Sam-Bodden
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
Gabriele Lana
 
Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02Nodejsexplained 101116115055-phpapp02
Nodejsexplained 101116115055-phpapp02
Sunny Gupta
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
Paweł Kowalczuk
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?Remy Sharp
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
Alona Mekhovova
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 

Similar to Serverless Ballerina (20)

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

More from Ballerina

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

More from Ballerina (20)

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

Recently uploaded

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 

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