faastCrystal

 faastCrystal

Crystal on faastRuby♥ #crystaljp

4b071f90c5d9c0a58e2d9076460b7be4?s=128

さっちゃん

May 13, 2019
Tweet

Transcript

  1. 8.
  2. 9.

    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
  3. 15.

    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
  4. 16.

    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
  5. 20.

    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%
  6. 21.

    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%
  7. 22.

    Benchmark Crystal is a little bit faster than Ruby, but

    it's not matter. They use Nginx. Perhaps the Nginx dose rate limiting.