Skip to Content

Last week I had the privilege to be back at SAP Tech Ed in Las Vegas. I met a lot of wonderful people, one of them Craig Cmehil who suggested to me to continue writing some blogs in spanish. Also, I attended some wicked sessions 😊 During the opening keynote by Bernd Leukert, he had a couple of nice announcements. The first one was about the SCP FaaS service. The other one was about ABAP on the cloud. The main purpose of this blog is to focus on the FaaS as it pertains on the SCP.

the same blog can be found in spanish here

SAP Cloud Platform (SCP) Cloud Fundry (CF) – Function as a Service (FaaS)

 

What is it?

Function as a Service is a part of a Cloud Platform that allows companies to develop, run, and manage application functionality (tasks with smaller chunks of code) rather than the traditional big application, and infrastructure needed to run an app.

Why it makes sense?

it absolutely makes sense because as companies continue to explore and venture into Cloud Platforms and services, software continues to mature and take advantage of such services and resources, allowing them to grow/shrink as needed by the cloud infrastructure without the overhead cost of owning hardware. This becomes the pay what you use model. More SAP documentation can be found here as well as a nice architecture diagram shown on that site.

 

https://help.sap.com/viewer/94fafb5bcf8f4c5cbdd0cdd8e358183c/Cloud/en-US/76c96fb29dbf4ee6acfba8ce6394fad6.html

 

Next, I would like to showcase my experience of developing one of the functions as a service from my SCP trial account.

 

While using the SAP Cloud trial account, make sure you go to the CF region and create a new subaccount. Enable the Beta Features. Keep in mind this feature, Functions, is still not fully supported so we are going to look at it from a beta point of view.

Once the sub account is created (faasDev) then we can navigate into it

And Enable CF, in my case it uses the trial account settings.

P1854054600trial_p1854054600trial

Once it has been created, then you will notice on the right-hand section

Another pre-req we need to make sure we have is the SPACE. There is no space set by default so we need to create one.

I called it testFaas with its default settings.

 

At the subaccount level, we need to click on edit, in order to set the Entitlements. This section will allow us to create functions in the CF environment and eventually let us run our FaaS. I struggled in this section because I wasn’t able to find it easily, however, after reading a couple blogs and response from Maximilian Streifeneder I found it  – thanks Maxi

after clicking on Edit, you can scroll down to functions and update the value from 0 to 1.

 

 

After saving those changes, we can go back to the SPACE and it should now show the Functions Service in the Service Marketplace

 

So let’s navigate into it and go into the instances section in order to create an instance of this service.

 

Create a New instance

Click next twice.. and leave the default wizard settings until you get to the step to assign a name and select Finish.

Read the official documentation for limits on how many functions per instance, how much resources and how many instances per account are allowed… again, this is in beta mode so documentation may be subject to change

When the Function service instance is created, it should look like so on your Dashboard.

 

You may need to grant access the CF instance to access your account

 

 

Once inside the Functions service, we can see the blank dashboard… so let’s take a look

Since we are in the Functions service, let’s create a Function. I will call it sayhelloworld and leave the default runtime (Node v8.1.0). more information about Nodejs can be found on the nodejs.org site.

 

Once the function is created, we can see the default handler (nodejs) code which is what will execute once this function gets called. This window looks like ….

And the bottom half of that screen looks like

Notice the different parameters, triggers, settings, secrets, etc… so I may be wondering what all this is.

If I go back to the functions page, I should expect to see my functions (1 in this case) similarly the triggers and secrets – I have not created any triggers / secrets at this time so let’s continue to explore

 

A trigger by definition is an object that will execute some operation (or function) so I clicked on the triggers page, and create new, provided a name and its type will be HTTP * other types can be timer (using chron job syntax – scheduled function) or event (binding a trigger to a function in order to react to a particular event from the enterprise event messaging service). I must select what function will get executed when this trigger is invoked

After creating the trigger, then the page shows the existing triggers

Since I selected an HTTP type trigger, I correctly assumed, I would get a URL to invoke it. I believe this may be the easiest way to consume a function via a URL, just like any other web service. So the different ways I normally test these services would be:

 

  • Browser call – and let’s see what is in the network tab from the developer tools.. I am interested in seeing the execution time so I can see how well or bad this operation performs plus the response time… as this will eventually get called and I will get billed for the consumption of resources… yes that is the purpose of FaaS services.

 

Opening the network tab, we can see the size of the response (287 B) and the status 200 (HTTP OK)

 

 

Further, Analyzing the network tab header response we can see other properties of the response header.

And from postman  (different free browser test tool – same response, 224ms and HTTP OK) I wonder why the difference in execution from the browser call and the browser extension.

 

note: there are 2 other ways (Event and Timer) to invoke the Function as a Service service, however, I am not showcasing them here for simplicity of my exercise.

 

Timer uses a chron job syntax for [Seconds, Minutes, Hours, Month, Year]

Events require a few extra steps to enable the Event driven message, Queue. These steps can be found here:

https://help.sap.com/viewer/788fa4c7585e415187e347e904010cee/1808.500/en-US/56cf82e75f2a42de827b5dc30e48db64.html

 

 

Finally, in the main page for the Functions Service, we can see the Dashboard.. within this page, we can see the logs for the specific functions we have defined. Notice that this log captures anything we specify in our handler function as console.log

 

Advantages of the function model architecture:

  • Pay per resource/consumption – instead of paying for an entire hosting package
  • Easy to start, scale, and deploy (this simple demo took me approx. 10 mins)
  • Less time on building a lot of skeleton code – with a few clicks I was able to generate all the parts and it was time for me to fill in the function code.

Different from traditional software development:

  • Different way of architecting software – think modular, scalable, microservices
  • Resource utilization needs to be considered
  • Independent deployments – so individual functions should be able to perform and complete a task

 

For additional Official documentation:

https://help.sap.com/viewer/94fafb5bcf8f4c5cbdd0cdd8e358183c/Cloud/en-US/3418355e1497473baf071e28294dde41.html?q=SAP%20Cloud%20Platform%20Functions

 

 

my personal note:

I am really liking the direction that SCP is going… offering FaaS similar to AWS and also using open source technology to accomplish this is really pushing the boundaries of latest technology, SAP embracing open source software and also making use of Cloud Foundry principles while continuing to improve and innovate in this area. well done SAP

 

 

I hope you can share you experiences with whatever function you decide to use as a service.

 

don’t forget to share your experiences

Sergio

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Dominique Pierre

    Thanks for sharing this Sergio, playing with Functions is on my todo list and your post will probably help a lot!

    I already discovered how to allocate services to subaccounts thanks to this post. 😉 I have to get used to all these new SCP concepts…

    (1) 
    1. Sergio Guerrero Post author

      glad to hear Dominique… and i completely agree w you.. there is just so much to learn.. I was just talking to Raphael Pacheco and he told me he is even learning some Spanish from SCN 😉 he is killing 2 birds w 1 stone 🙂 #letsKeepLearning

      (1) 
      1. Raphael Pacheco

        hahaha, SCN is not only for learn and share SAP technologies, also helps you to know other cultures 😉

        Commenting now about the blog, thanks for share this Sergio Guerrero. I have one doubt, I see in your steps you using the Node as language in your cloud function, my question is: Can we able to use another languages on that? (eg. Python, Java, etc).

        BR,

        Raphael Pacheco.

        (1) 
        1. Sergio Guerrero Post author

          very good question Raphael and thanks! as of right now, the only option on this feature is the NodeJS runtime, however, I would think that this may expand to other languages since the whole platform is following CF rules. I do not see why it would be a difficult thing to implement – even in the logs i see the kubernetes container implementation.. I thinkonce it goes out of Beta, maybe it will be offered

          would any of the SAP employees reading the blog know?

          (1) 
          1. Joerg Singler

            Hi,

            you are right it won’t be that hard for us to support also other programming languages. However we decided to go first deep on one language (the most used one for functions) before we go broad. There is still some way to go when thinking of e.g. Enterprise Readiness features such as e2e-tracing or requirements/feedback from early adopters such as you. So these are domains which we want to cover first before we go broad. Makes sense?

            Kindly,

            Joerg

             

            (2) 
            1. Raphael Pacheco

              For me it makes sense, in parts. When I say this, I want to mention the fact that when I think of cloud functions, I think of scalability and maintainability, which I do not think the node would be a purely good language for it. When we think of development, we must not only think of a more accepted technology / language, but also other technologies that fit our purpose. I hope that in the future they will include Python, Elixir among others to this.

              Br,

              Raphael Pacheco.

              (1) 
              1. Joerg Singler

                You are right. It is a mix/balance of popularity, eco-system/available libraries and characteristics of a language.
                I am just convinced that we have to support some language-independent functional or non-functional requirements first. It will be a set of features which every or most additional programming language will be able to leverage from the beginning. Then we can go big on languages. Python or go to name only a few are definitely ranked on top of the list.

                Kindly,

                Joerg

                 

                (2) 
                1. Sergio Guerrero Post author

                  thank you Joerg for the responses… personally, I would also like to see the Go lang as a top contender. I think Go has a lot to offer, similar syntax and being a language developed by Google, I assume, could be a good match for some of those apps running on google cloud. I also agree w Raphael Pacheco at some point.. maybe it gets opened for Python

                  (2) 

Leave a Reply