HTTP Services in Rust*
1Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation
@dhigit9
Anton Whalley – Cloud Technical Professional
*Focusing on Containers
2
Running Order
• Benefits of Rust for HTTP Services
• Select a Rust HTTP Framework
• Align software development process
@dhigit9
A standard way to package an application and
all its dependencies so that it can be moved
between environments and run without
changes.
Containers work by isolating the differences
between applications inside the container so
that everything outside the container can be
standardized.
The “Goldilocks of Virtualization”
Containers
IBM Cloud Kubernetes Service | ©2018 IBM Corporation
What are containers? VMs vs Containers
Containers are isolated, but share OS and, where
appropriate, bins/libraries …faster, less overhead
Host OS
Server
Guest
OS
Bins/
Libs
VM
Hypervisor (Type 2)
App
A
AppA’
Host OS
Server
Bins/Libs
AppA
Bins/Libs
AppA’
AppB’
AppB’
Container
App
A`
Guest
OS
Bins/
Libs
App
A`
Guest
OS
Bins/
Libs
App
B
Guest
OS
Bins/
Libs
App
B`
Guest
OS
Bins/
Libs
What industries do you work in using Rust Full time?
https://blog.rust-lang.org/2020/04/17/Rust-survey-2019.html
Rust Largest Use Case - Backend Web Applications
@dhigit9
6© 2020 IBM Corporation
Container Adoption Continues to Grow
@dhigit9
The Hidden Truth - Runtimes in Containers
@dhigit9
8
Runtime Mem CPU Processes/CPU
Java Spring Boot ~87Mb ~20m 50
Node.JS Express ~47Mb ~10m 100
Rust Tide ~1Mb ~1m 1000
Cold Service Resource Utilisation
https://venshare.com/blog/runtime-overhead-on-openshift/ @dhigit9
9
Deployment Density Solutions For Runtimes
isolated-vm Piscina
Java Node.js
@dhigit9
10
The Trade Off for New Runtimes
New Software Development LifeCycle
• Code Refactoring
• New Tools
New Operational Constraints
• Runtime Characteristics
• Debugging
Security Implications
Still uses GCed Runtime (Java/Node.js/Go)
@dhigit9
The Truth about GC
https://blog.discord.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f
@dhigit9
Rust Compared to GCed Runtime (Go)
https://blog.discord.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f
@dhigit9
13
• Benefits of Rust for HTTP Services ✅
• Select a HTTP Framework
• Align software development process
@dhigit9
14Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation
Select a HTTP
Framework?
Rocket
WARP
Tide
15Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation
https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/
Framework Total Downloads Daily Download
Acitx-web ~1250k ~3000
Rocket ~525k ~1000
Warp ~435k ~3000
Tide ~47k ~300
Adoption
16Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation
https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/
Runtime Total Downloads Daily Download
tokio ~9600k ~30k
async-std ~600k ~4k
Async Support
Framework Runtime
actix-web tokio
rocket (0.5.x) tokio
tide async-std
warp tokio
17Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation
https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/
Community Crates
Framework # results
rocket 178
actix-web 113
warp 57
tide 20
Actix-web Rocket
Tide Warp
Contributor Ratio
Contributor Ratio – Github commit log
19
Picking a Framework Conclusion
Align your values with the framework!
Tide
Fast and friendly HTTP server framework
Collaboration focus
Active Discord
Architecture similar to Node.js middleware
@dhigit9
20
• Benefits of Rust for HTTP Services ✅
• Select a HTTP Framework ✅
• Align software development process
@dhigit9
Problems with Kubernetes
21© 2020 IBM Corporation
I want to deploy my container-based
workloads easily, quickly and securely
to a platform that:
… dynamically scales my containers
according to load.
... has monitoring, logging and a service
mesh “built in”.
… gives me the a seemless developer
experience.
… does not “lock me in” and is built on
open-source projects.
@dhigit9https://www.youtube.com/watch?v=oNa3xK2GFKY
22Source: https://thenewstack.io/ux-is-kubernetes-biggest-short-term-challenge/
Knative addresses 4 of the top 5 pain points of Kubernetes
*Top areas the Core Kubernetes Project Needs to Address in 2020, Thenewstack
@dhigit9
Introducing Knative
Knative is a serverless 2.0 environment that extends Kubernetes
Middleware components
Modern, source-centric, and container-based applications
Can run anywhere:
on premises, in the cloud, or even in a third-party data center.
@dhigit9
• Knative vs Serverless Platforms
User defined resource management with sensible defaults
Container approach gives wider language support
No Execution Timeout
More portability options
@dhigit9
Knative overview
25
Knative overview (cont.)
26
© 2019 IBM Corporation
Appsody – Knative Software Development
Jane: Lead
Enterprise
Developer
Champ: Solution
Architect
Champ provides pre-configured application stacks
Jane selects a stack she and her team want to work with and get to work right away
Kubernetes native
CI/CD pipeline
Knative in any hybrid multicloud environment
twitter: @dhigit9
Appsody – Serverless Workflow twitter: @dhigit9
Demo
29
● Rust with Appsody Tutorial
https://appsody.dev/tutorials/ServerlessRust/
https://www.youtube.com/watch?v=asywye-eDfg
● Appsody
https://appsody.dev/
● Create your own Appsody stack tutorial
https://developer.ibm.com/technologies/containers/tutorials/create-appsody-stack/
● CNCF Serverless
https://github.com/cncf/wg-serverless/blob/master/whitepapers/serverless-
overview/cncf_serverless_whitepaper_v1.0.pdf
● IBM Cloud OpenShift
https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_tutorial
● Install Knative on OpenShift
https://docs.openshift.com/container-platform/4.3/serverless/installing_serverless/installing-
knative-serving.html
Follow Up Links
30
twitter: @dhigit9

Http Services in Rust on Containers

  • 1.
    HTTP Services inRust* 1Think 2018 / DOC ID / Month XX, 2018 / © 2018 IBM Corporation @dhigit9 Anton Whalley – Cloud Technical Professional *Focusing on Containers
  • 2.
    2 Running Order • Benefitsof Rust for HTTP Services • Select a Rust HTTP Framework • Align software development process @dhigit9
  • 3.
    A standard wayto package an application and all its dependencies so that it can be moved between environments and run without changes. Containers work by isolating the differences between applications inside the container so that everything outside the container can be standardized. The “Goldilocks of Virtualization” Containers IBM Cloud Kubernetes Service | ©2018 IBM Corporation
  • 4.
    What are containers?VMs vs Containers Containers are isolated, but share OS and, where appropriate, bins/libraries …faster, less overhead Host OS Server Guest OS Bins/ Libs VM Hypervisor (Type 2) App A AppA’ Host OS Server Bins/Libs AppA Bins/Libs AppA’ AppB’ AppB’ Container App A` Guest OS Bins/ Libs App A` Guest OS Bins/ Libs App B Guest OS Bins/ Libs App B` Guest OS Bins/ Libs
  • 5.
    What industries doyou work in using Rust Full time? https://blog.rust-lang.org/2020/04/17/Rust-survey-2019.html Rust Largest Use Case - Backend Web Applications @dhigit9
  • 6.
    6© 2020 IBMCorporation Container Adoption Continues to Grow @dhigit9
  • 7.
    The Hidden Truth- Runtimes in Containers @dhigit9
  • 8.
    8 Runtime Mem CPUProcesses/CPU Java Spring Boot ~87Mb ~20m 50 Node.JS Express ~47Mb ~10m 100 Rust Tide ~1Mb ~1m 1000 Cold Service Resource Utilisation https://venshare.com/blog/runtime-overhead-on-openshift/ @dhigit9
  • 9.
    9 Deployment Density SolutionsFor Runtimes isolated-vm Piscina Java Node.js @dhigit9
  • 10.
    10 The Trade Offfor New Runtimes New Software Development LifeCycle • Code Refactoring • New Tools New Operational Constraints • Runtime Characteristics • Debugging Security Implications Still uses GCed Runtime (Java/Node.js/Go) @dhigit9
  • 11.
    The Truth aboutGC https://blog.discord.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f @dhigit9
  • 12.
    Rust Compared toGCed Runtime (Go) https://blog.discord.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f @dhigit9
  • 13.
    13 • Benefits ofRust for HTTP Services ✅ • Select a HTTP Framework • Align software development process @dhigit9
  • 14.
    14Think 2018 /DOC ID / Month XX, 2018 / © 2018 IBM Corporation Select a HTTP Framework? Rocket WARP Tide
  • 15.
    15Think 2018 /DOC ID / Month XX, 2018 / © 2018 IBM Corporation https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/ Framework Total Downloads Daily Download Acitx-web ~1250k ~3000 Rocket ~525k ~1000 Warp ~435k ~3000 Tide ~47k ~300 Adoption
  • 16.
    16Think 2018 /DOC ID / Month XX, 2018 / © 2018 IBM Corporation https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/ Runtime Total Downloads Daily Download tokio ~9600k ~30k async-std ~600k ~4k Async Support Framework Runtime actix-web tokio rocket (0.5.x) tokio tide async-std warp tokio
  • 17.
    17Think 2018 /DOC ID / Month XX, 2018 / © 2018 IBM Corporation https://www.lpalmieri.com/posts/2020-07-04-choosing-a-rust-web-framework-2020-edition/ Community Crates Framework # results rocket 178 actix-web 113 warp 57 tide 20
  • 18.
    Actix-web Rocket Tide Warp ContributorRatio Contributor Ratio – Github commit log
  • 19.
    19 Picking a FrameworkConclusion Align your values with the framework! Tide Fast and friendly HTTP server framework Collaboration focus Active Discord Architecture similar to Node.js middleware @dhigit9
  • 20.
    20 • Benefits ofRust for HTTP Services ✅ • Select a HTTP Framework ✅ • Align software development process @dhigit9
  • 21.
    Problems with Kubernetes 21©2020 IBM Corporation I want to deploy my container-based workloads easily, quickly and securely to a platform that: … dynamically scales my containers according to load. ... has monitoring, logging and a service mesh “built in”. … gives me the a seemless developer experience. … does not “lock me in” and is built on open-source projects. @dhigit9https://www.youtube.com/watch?v=oNa3xK2GFKY
  • 22.
    22Source: https://thenewstack.io/ux-is-kubernetes-biggest-short-term-challenge/ Knative addresses4 of the top 5 pain points of Kubernetes *Top areas the Core Kubernetes Project Needs to Address in 2020, Thenewstack @dhigit9
  • 23.
    Introducing Knative Knative isa serverless 2.0 environment that extends Kubernetes Middleware components Modern, source-centric, and container-based applications Can run anywhere: on premises, in the cloud, or even in a third-party data center. @dhigit9
  • 24.
    • Knative vsServerless Platforms User defined resource management with sensible defaults Container approach gives wider language support No Execution Timeout More portability options @dhigit9
  • 25.
  • 26.
  • 27.
    © 2019 IBMCorporation Appsody – Knative Software Development Jane: Lead Enterprise Developer Champ: Solution Architect Champ provides pre-configured application stacks Jane selects a stack she and her team want to work with and get to work right away Kubernetes native CI/CD pipeline Knative in any hybrid multicloud environment twitter: @dhigit9
  • 28.
    Appsody – ServerlessWorkflow twitter: @dhigit9
  • 29.
  • 30.
    ● Rust withAppsody Tutorial https://appsody.dev/tutorials/ServerlessRust/ https://www.youtube.com/watch?v=asywye-eDfg ● Appsody https://appsody.dev/ ● Create your own Appsody stack tutorial https://developer.ibm.com/technologies/containers/tutorials/create-appsody-stack/ ● CNCF Serverless https://github.com/cncf/wg-serverless/blob/master/whitepapers/serverless- overview/cncf_serverless_whitepaper_v1.0.pdf ● IBM Cloud OpenShift https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_tutorial ● Install Knative on OpenShift https://docs.openshift.com/container-platform/4.3/serverless/installing_serverless/installing- knative-serving.html Follow Up Links 30 twitter: @dhigit9