thinking in rules

Serverless Execution with InRule for JavaScript and AWS Lambda

Dan Reynolds | 5/23/2017

Serverless execution is gaining momentum. If you aren't familiar with the concept, the idea is that you just provide the code you want to run and the platform magically makes it available as a service. It's serverless, because you, the user, don't have to provision a server in any way, shape or form. The best part, and the reason for its recent popularity, is that you only pay for the execution time, whereas traditionally you would have to pay for the server to be up and running. It is an elastic model that will immediately scale on-demand and you do not have to pay for the setup, teardown, or idle server time.

Amazon, Google, and Microsoft all have serverless cloud offerings. In this post I'll demonstrate Amazon's answer to serverless execution, AWS Lambda. A Lambda function is simply code, written in a handful of possible languages, that will execute when called as a service. It's simple text in/text out. One of the supported languages is Node/JavaScript, which works extremely well with InRule® for JavaScript, our JavaScript rules engine. Throw in an extendible authoring tool and we've got ourselves an end-to-end solution!


The rules are authored in irAuthor, InRule's rule authoring tool. I've also written my own custom extension that adds a button to the ribbon. When clicked, it will take the rules from irAuthor, send them to the InRule Distribution service (irDistribution) where the rules are converted into JavaScript. The custom extension then takes the JavaScript and updates the Lambda Function in AWS with the new rules. The final piece is an independent web page that I wrote to test the service in Amazon.

I'm using rules to calculate a mortgage for the demo, which are called from the test page. The page does a simple JavaScript POST to call the Lambda function. The results returned from the function are then written back to the page.

Demo Video


This type of solution is very flexible and affordable. The cost is based on what your business uses as opposed to paying for provisioned idle servers that sit unused.  Serverless brings an unprecedented alignment between resource allocation and resource consumption; pair that with high speed caching technologies and the next generation of elastic compute is here.

A couple final notes:

comments powered by Disqus