Slide 1

Slide 1 text

λ faastCrystal

Slide 2

Slide 2 text

.。oO(さっちゃんですよヾ(〃l _ l)ノ゙ ☆)

Slide 3

Slide 3 text

https://speakerdeck.com/ne_sachirou/faastruby

Slide 4

Slide 4 text

faastRuby

Slide 5

Slide 5 text

Visit to the faastRuby Web site. https://faastruby.io/

Slide 6

Slide 6 text

Serverless Platform for Ruby and Crystal https://faastruby.io/

Slide 7

Slide 7 text

Serverless Platform for Ruby and Crystal

Slide 8

Slide 8 text

Let's.

Slide 9

Slide 9 text

faastruby new-project hello --api + d ./hello + f ./hello/project.yml + f ./hello/secrets.yml + d ./hello/functions/root + f ./hello/functions/root/handler.rb + f ./hello/functions/root/faastruby.yml + d ./hello/functions/catch-all + f ./hello/functions/catch-all/handler.rb + f ./hello/functions/catch-all/faastruby.yml + d ./hello/public + f ./hello/public/faastruby.yml + f ./hello/.gitignore Initialized empty Git repository in ~/hello/.git/ Project 'hello' initialized. Now run: $ cd hello $ faastruby local Then visit http://localhost:3000

Slide 10

Slide 10 text

mkdir functions/rb

Slide 11

Slide 11 text

faastruby.yml --- cli_version: 0.5.25 name: rb runtime: ruby:2.6

Slide 12

Slide 12 text

handler.rb def handler event response = { 'hello' => 'world' } render json: response end

Slide 13

Slide 13 text

mkdir functions/cr

Slide 14

Slide 14 text

faastruby.yml --- cli_version: 0.5.25 name: cr runtime: crystal:0.27.2

Slide 15

Slide 15 text

handler.cr require "json" def handler(event) response = JSON.build do |json| json.object do json.field "hello", "world" end end render json: response end

Slide 16

Slide 16 text

faastruby deploy ┌ Deploying project 'hello' to workspace 'hello-stage- ~' ├── [✔] Connecting to workspace 'hello-stage- ~' ├── [✔] Uploading static assets in 'public' ├── [✔] Deploying function from 'functions/rb' ├── [✔] Deploying function from 'functions/cr' ├── [✔] Deploying function from 'functions/catch-all' └── [✔] Deploying function from 'functions/root' * Project URL: https://hello-stage- ~. ~.faast.cloud

Slide 17

Slide 17 text

$ curl 'https://hello-stage- ~. ~.faast.cloud/rb' {"hello":"world"} $ curl 'https://hello-stage- ~. ~.faast.cloud/cr' {"hello":"world"}

Slide 18

Slide 18 text

Works! faast faast

Slide 19

Slide 19 text

Benchmark?

Slide 20

Slide 20 text

h2load -n 100 -c 1 -t 1 URL Ruby finished in 20.73s, 4.82 req/s, 1.93KB/s requests: 100 total, 100 started, 100 done, 100 succeeded, 0 failed, 0 errored, 0 timeout status codes: 100 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 39.93KB (40887) total, 32.91KB (33695) headers (space savings 0.00%), 1.66KB (1700) data min max mean sd +/- sd time for request: 189.23ms 320.82ms 202.13ms 25.53ms 91.00% time for connect: 518.60ms 518.60ms 518.60ms 0us 100.00% time to 1st byte: 712.13ms 712.13ms 712.13ms 0us 100.00% req/s : 4.82 4.82 4.82 0.00 100.00% Crystal finished in 20.27s, 4.93 req/s, 1.97KB/s requests: 100 total, 100 started, 100 done, 100 succeeded, 0 failed, 0 errored, 0 timeout status codes: 100 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 39.93KB (40887) total, 32.91KB (33695) headers (space savings 0.00%), 1.66KB (1700) data min max mean sd +/- sd time for request: 182.51ms 404.88ms 197.55ms 39.14ms 94.00% time for connect: 513.51ms 513.51ms 513.51ms 0us 100.00% time to 1st byte: 699.38ms 699.38ms 699.38ms 0us 100.00% req/s : 4.93 4.93 4.93 0.00 100.00%

Slide 21

Slide 21 text

h2load -n 100 -c 10 -t 10 URL Ruby finished in 2.78s, 35.98 req/s, 14.51KB/s requests: 100 total, 100 started, 100 done, 100 succeeded, 0 failed, 0 errored, 0 timeout status codes: 100 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 40.33KB (41300) total, 32.91KB (33700) headers (space savings 0.00%), 1.66KB (1700) data min max mean sd +/- sd time for request: 189.91ms 261.53ms 212.59ms 17.58ms 63.00% time for connect: 517.43ms 540.26ms 527.85ms 7.19ms 70.00% time to 1st byte: 714.19ms 772.20ms 753.39ms 19.72ms 90.00% req/s : 3.60 3.99 3.77 0.12 70.00% Crystal finished in 2.50s, 39.96 req/s, 16.12KB/s requests: 100 total, 100 started, 100 done, 100 succeeded, 0 failed, 0 errored, 0 timeout status codes: 100 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 40.33KB (41300) total, 32.91KB (33700) headers (space savings 0.00%), 1.66KB (1700) data min max mean sd +/- sd time for request: 182.24ms 232.80ms 194.89ms 11.66ms 83.00% time for connect: 514.20ms 530.94ms 519.75ms 4.58ms 80.00% time to 1st byte: 711.84ms 752.36ms 736.42ms 15.44ms 60.00% req/s : 4.00 4.18 4.05 0.06 80.00%

Slide 22

Slide 22 text

Benchmark Crystal is a little bit faster than Ruby, but it's not matter. They use Nginx. Perhaps the Nginx dose rate limiting.