March 11, 2021 By Henrik Loeser 3 min read

How to use IBM Cloud Code Engine for GitHub traffic analytics.

Some years back, we introduced an IBM Cloud solution tutorial for GitHub traffic analytics based on Cloud Foundry and IBM Cloud Functions. A Cloud Functions action is triggered daily to collect traffic data. The action stores the data in a Db2 database. Users can then analyse the data in a Python Flask app served by Cloud Foundry.

Today, that same solution scenario and app are still available, but they are served by IBM Cloud Code Engine. Code Engine is a fully managed, serverless platform that runs your containerized workloads, including web apps, microservices, event-driven functions or batch jobs. The slightly renamed tutorial — “Serverless web app and eventing for data retrieval and analytics” — demonstrates how the existing app can be containerized and both served as web app and and used to process the daily data collection event:

Solution architecture for serverless web app and eventing.

Serverless application

Serverless computing is an approach to computing that offloads responsibility for common infrastructure management tasks (e.g., scaling, scheduling, patching, provisioning, etc.) to cloud providers and tools, allowing engineers to focus their time and effort on the business logic specific to their applications or process. It is also the computing model utilized by Code Engine. With that, it is a great fit for the solution scenario discussed in the tutorial. 

Users can access the web application to look at and analyse GitHub traffic data (see [1] in the architecture diagram above). The app itself relies on the IBM Cloud App ID security service to authenticate users. It also stores the traffic data and other app data in an IBM Db2 on Cloud database (see [2]). Moreover, the app is triggered daily (see [3]) to collect new traffic data from GitHub (see [4]). Since the web application is only needed infrequently and the data collection happens once a day, the solution benefits from the serverless compute model and its automatic up- and downscaling of resources (autoscaling). When not in use, there are no costs.

Containerized solution

The code for this tutorial is available in a GitHub repository. In the tutorial, we set up a Code Engine project with an app. We configure the app to be built as container image from the code on GitHub. The container image is stored in the IBM Cloud Container Registry. From there, it is fetched by Code Engine and used to deploy a revision of our app.

Only few steps are needed to set up everything and deploy the app and it required services. Once done, the traffic data is collected daily and you can start analyzing it in the app — either as data tables or with a chart like the one below:

Line chart with daily views for GitHub repositories.

Summary

The solution for analysing GitHub traffic statistics is a good fit for IBM Cloud Code Engine. It has scheduled daily collection of traffic data (eventing) and the actual web app is infrequently used (serving). Thus, it benefits from the serverless compute model and its automatic up- and downscaling of resources (autoscaling). When not in use, there are no costs. The container deployment directly off the git repository makes it easy to use.

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn

Was this article helpful?
YesNo

More from Cloud

Bigger isn’t always better: How hybrid AI pattern enables smaller language models

5 min read - As large language models (LLMs) have entered the common vernacular, people have discovered how to use apps that access them. Modern AI tools can generate, create, summarize, translate, classify and even converse. Tools in the generative AI domain allow us to generate responses to prompts after learning from existing artifacts. One area that has not seen much innovation is at the far edge and on constrained devices. We see some versions of AI apps running locally on mobile devices with…

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

The advantages and disadvantages of private cloud 

6 min read - The popularity of private cloud is growing, primarily driven by the need for greater data security. Across industries like education, retail and government, organizations are choosing private cloud settings to conduct business use cases involving workloads with sensitive information and to comply with data privacy and compliance needs. In a report from Technavio (link resides outside ibm.com), the private cloud services market size is estimated to grow at a CAGR of 26.71% between 2023 and 2028, and it is forecast to increase by…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters