Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
sissa
Participant
Some common goals of web development projects are to build fast, secure, scalable and high-performance websites and apps. At the same time, there's also a need for delivering value faster.

Thankfully, these days, there are many tools and technologies readily available to help us.

This post demonstrates an example that uses the following state-of-the-art technologies to help achieve these goals and is inspired by the Jamstack architecture“the modern way to build Websites and Apps that delivers better performance”[1].

  • Next.js"gives you the best developer experience with all the features you need for production"[2]

  • Chakra UI"gives you the building blocks you need to build your React applications"[3]with "less code"[3]and "more speed"[3]

  • Go Programming Language — language of choice for backend microservices

  • Gin - an HTTP web framework written in Go that "features a Martini-like API with much better performance -- up to 40 times faster"[4]

  • SAP HANA Cloud — a "high-performance in-memory database"[5]

  • SAP Event Mesh"a fully managed cloud service that allows applications to communicate through asynchronous events"[6]

  • Kyma — "a cloud-native application runtime that combines the power of Kubernetes with a set of best-in-class tools and open-source components"[7]

  • Kubernetes"an open source container orchestration engine for automating deployment, scaling, and management of containerized applications"[8]

  • Cloudflare CDN"stops malicious traffic"[9], "optimizes the delivery of website resources"[9], "routes visitor requests to the nearest Cloudflare data center"[9] and "provides security"[9]


Next.js app with Kyma Eventing & Go backend connected to SAP HANA Cloud database


This example illustrates the following major components of SAP BTP, Kyma Runtime and its goal is to help you to get familiarized with some of the key features of SAP BTP, Kyma Runtime and to help you use your learnings in your own experiments using a free SAP BTP Trial account.

  • Containerized Microservice exposed via an API Rule — a Next.js app used as a client-side web app

  • Go Containerized Microservice — a Go app used as a backing service

  • Node.js Serverless Function

  • Kyma Eventing using either NATS (available with a free SAP BTP Trial account) or SAP Event Mesh (requires a paid account)


It is modelled as a simple conference registration system that stores user information in an SAP HANA Cloud database and sends a confirmation email to the user.

Its front-end is powered by a Next.js app that is deployed as a microservice on Kyma Runtime with a client-side user interface and an API endpoint.

Form submissions are sent via the API endpoint to Kyma Eventing, which can be either NATS by default, or optionally SAP Event Mesh.

A Serverless Function consumes events from the queue and sends a confirmation email to the user after saving the user's details to an SAP HANA Cloud database via a Go Microservice — a REST API Server microservice that is implemented in Go using Gin Web Framework.

The Go Microservice is exposed as a Kubernetes service with ClusterIP ServiceType (by default) and can be accessed via a hostname that is only accessible within the Kubernetes cluster, with the following format: <service-name>.<namespace>.svc.cluster.local
Note: Mutual TLS (mTLS) is enabled mesh-wide by default in Kyma Runtime. To be more specific, the mTLS mode is set to STRICT in a PeerAuthentication policy within the root istio-system namespace. As a result, all internal service to service communication within the Kubernetes cluster is encrypted by default using Transport Layer Security (TLS).

Solution Architecture




Sequence Diagram




Build and deployment steps


This web app can be deployed using a free SAP BTP Trial account via the following steps that will also help you learn how the major components of Kyma Runtime work together.
Note: Click the links below for more details.


Verification steps





Troubleshooting steps


Using Cloudflare CDN


The DNS provider of the namespace needs be set as Cloudflare to use Cloudflare CDN.

For more Information, refer to: Step 7 - Connect your web app running on Kyma Runtime to a domain via Cloudflare.

Superb performance of the user facing app


Without Cloudflare CDN


Even without Cloudflare CDN, Google's PageSpeed Insights tool gave a Performance score of 100 to the Next.js web app for Desktop.



With Cloudflare CDN


With Cloudflare CDN, the time to interactive and total blocking time were reduced even further.



Blazing fast performance of the backing service


Although this web app only uses the HTTP POST API call of the Go Microservice to save customer records to the SAP HANA Cloud database, the Go Microservice has all the CRUD operations (Create, read, update and delete) implemented in it for the sake of demonstration.

The HTTP POST and PUT API calls of the Go Microservice had an almost similar response time. In order to not create too many records in the database during load testing, the HTTP PUT API calls were load tested, which make update requests and they had an average response time of 27.33 ms with 143.4 Hits per second when tested with BlazeMeter.

That is, on average each request was executed within about 1/36th of a second, which is blazing fast for a backing service — and that too with using a free SAP BTP Trial account!



Conclusion


Implementing the Jamstack architecture using the Kyma Runtime and an SAP HANA Cloud database results in extremely fast performance, which can be fine-tuned even further by either using caching services such as Redis or by horizontal as well as vertical scaling — key features of Kubernetes that can be easily configured. The added benefit of using the Kyma Runtime is the seamless connectivity provided by it to various SAP solutions as well as to services of other hyperscalers such as Google Cloud Platform, AWS & Azure using service operators — a great topic that is covered in the following blog post: Using Kubernetes operators with SAP BTP Kyma runtime.

As a next step, you could try to customize this example or put together the different components of Kyma Runtime that were covered in this example and build a web app for another use case using the Jamstack architecture.

If you'd like to dive deeper into some of the key topics that were covered in this blog post, you may find the resources listed in the Further Readings section below interesting.

Also, if you'd like to access the Go Microservice via a public URL from outside the Kubernetes cluster for testing it using an API client such as Postman, then you'll need to create an API Rule and expose the registrations-rest-api service. To do that, select the conference-registration namespace in the Kyma console. Next, under Discovery and Network, select API Rules. Then, click on Create API Rule. When creating the API Rule, you could also select to set its access strategy to OAuth2 to secure it. If you do that, you'll also need to create an OAuth client to be used to access it. You can do that by selecting Configuration and then OAuth Clients from the left menu in the Kyma console.

Kindly provide your feedback or feel free to ask clarifying questions related to this post in the comment section below. Additionally, I’d like to invite you to submit any broader Kyma related questions in the Q&A area of the SAP BTP, Kyma runtime topic.

If the SAP BTP, Kyma runtime topic interests you, here are some other links that you may like:

Lastly, if you liked this post, kindly hit the like icon, leave a comment below or share this post. Thank you!

References



  1. Jamstack: For fast and secure sites

  2. Next.js by Vercel

  3. Chakra UI

  4. Gin Web Framework - GitHub

  5. SAP HANA

  6. What Is SAP Event Mesh?

  7. Kyma - An easy way to extend enterprise applications on Kubernetes

  8. Kubernetes Documentation

  9. How Cloudflare works


Further Readings


4 Comments