fbpx

FaaStRuby 0.4 adds support for Ruby 2.6.0 and... Crystal 0.27.0!

I am really excited to announce that the newest version of the faastruby gem comes with support for Ruby 2.6.0 and a little surprise: a Crystal runtime!

Update the gem:

$ gem update faastruby

To use different runtimes, use the '--runtime' command line argument when creating a new function. For example, for Ruby 2.6.0:

$ faastruby new hello-world --runtime ruby:2.6.0
$ cd hello-world
hello-world$ faastruby deploy-to my-unique-workspace

Now for those who want to play around with the Crystal runtime, here's how:

$ faastruby new crystal-hello-world --runtime crystal:0.27.0
$ cd crystal-hello-world
crystal-hello-world$ faastruby deploy-to my-unique-workspace
...
crystal-hello-world$ curl https://api.tor1.faastruby.io/my-unique-workspace/crystal-hello-world
Hello World!
crystal-hello-world$ 

Performance

You can pass the header "Benchmark: true" to check how much time your function took to execute. The time returned is in milliseconds (ms).

Here's the output of the Ruby hello-world function when you pass the benchmark header:

{"execution_time":"0.87","function_response":"Hello, World!\n"}

Now here is the output of crystal-hello-world:

{"execution_time":"0.003472","function_response":"Hello, World!\n"}

While the hello-world in Ruby took 0.87ms to run, the same function in Crystal took ~0.0035ms! That's ~250x faster!

Upgrading your current Ruby functions to 2.6.0

To change your existing functions to Ruby 2.6.0, all you have to do is edit the file faastruby.yml and add the key:

runtime: ruby:2.6.0

Please try it out. I am curious to hear your feedback! You can reach out to me on the chat, or via twitter @parrudanet.

Happy new year!