Kumologica: Improving data layer responsiveness with Redis node
This tutorial explains how to install and use the Redis node in a Kumologica flow in order to improve data layer responsiveness.
Join the DZone community and get the full member experience.Join For Free
Online shopping is becoming the prominent sales channel in the retail industry, even for the ones who are traditional with a brick-and-mortar history. This necessitates that the website provides the best in class user experience to the customers. User experience is not only about the layout and eye-catchiness of the website, but the responsiveness, optimally with sub-millisecond responses. Recent surveys indicate that 9 out of 10 users have responded that they will abandon a website if it is not responsive.
One of the major challenges for achieving great responsiveness is the bottleneck introduced by the data layer. It becomes very challenging to design the persistence storage layer to provide the required response performance. A proven way to enhance the data layer responsiveness is to introduce a caching layer on top of the persistence storage. Redis is the industry-leading enterprise-grade caching provider with great performance and scalability.
Kumologica supports Redis integration with the Redis Node. Flows can use the Redis node to interface directly with the Redis caching layer.
In this article, we will look into a use case-based flow that uses the Redis node to fetch cached data from the Redis cache.
One of the important pages in an eCommerce website is the product details page (PDP) that provides a view of the product inventory to the users. The core API to support this is to retrieve the complete details related to an item, based on the SKU_ID from the backend.
Let's build an API (Kumologica flow) that looks like so:
- Given a SKU_ID will retrieve the details related to the SKU.
- The flow will use Kumologica Redis node to retrieve the details from Redis Cache based on the SKU_ID.
- Kumologica Designer — Download the designer for building the flow.
- AWS account — For running the Kumologica flow as lambda. (Optional)
If you don't have an AWS account you can run this solution locally. All you need is Kumologica designer.
We will be creating a flow in our Kumologica project. Let’s start building the flow that will take SKU_ID as a path parameter. This flow will be hosted on the endpoint GET: /items/SKU_ID.
- Open Kumologica Designer, click the Home button and choose to Create a New Kumologica Project.
- Enter name (for example ItemService), select directory for the project.
- Press the Create Button.
- Drag and drop the EventListener node to the canvas the provide the following configuration.
Display Name : Get Item Provider : AWS Event Source : Amazon API gateway Verb : GET URL : /items/:SKU_ID
- Use the "Add more nodes" button on the nodes palette (left side of the designer) to add "Redis Node" to the canvas.
- Complete the flow as depicted above.
- In the Redis node, enter the configuration details to connect to your Redis installation.
- Provide the output transformation to conform to the required output format.
- Add the EventListener End node. Provide the following configuration.
Display Name : Success Status Code : 200 Content-Type : text/html Payload : msg.payload
- Open the browser and type the following URL: http://localhost:1880/items/1234
- Replace the SKU_ID (represented as 1234 here) with one that has data cached in Redis.
- The browser should display the results fetched from Redis.
- More details on locally testing a Kumologica flow can be found in this article: Testing Kumologica Flow Locally
Deploying to AWS
- Select the AWS icon on the right-hand side vertical tab of Kumologica designer, select your AWS Profile.
Note: If you haven’t mapped your local AWS profile with the designer, then you may follow the below video to configure it.
Mapping the AWS Profile to Kumologica Designer
- Click Connect. If you're successfully connected, it will show the rest of the configuration options.
- Set the Memory to 512MB and Timeout as 20 seconds.
- Go to the “Trigger” section under the Cloud tab and select the Amazon API Gateway trigger.
Opinions expressed by DZone contributors are their own.