How to manage your data with Upstash

Serkan SAKINMAZ
5 min readJan 8, 2023

Redis is a distributed in-memory database that provides peak performance for applications. When you need a good caching solution, Redis comes to play. In terms of infrastructure management, you can manage Redis on-prem or on the cloud. In this blog, I am going to explain how to manage Redis data in a serverless manner with Upstash.

Serverless is getting more popular in the cloud world. You don’t need to manage any server, and cloud providers introduce new serverless services that focus on specific domains and libraries. For example, Lambda is one of the popular serverless services that provides a computing solution.

There is also a need to manage Redis and Kafka data in a serverless manner. At that point, Upstash provides a data platform that manages data for Kafka and Redis. It is serverless, hence you don’t need to provision any server. In addition to that, Upstash provides low latency to access data on these platforms.

As of now, Upstash supports Kafka, Redis and QStash, most probably they will support more solutions in the future.

Advantages and features of Upstash

  • Supports pay-as-you-go pricing: When you use Upstash, you don’t need to pay any money upfront or don’t need to sign a contract. The fee is calculated by how much you used the service. In addition to that, Upstash supports big enterprise companies with other offers
  • Easy to use: You can easily enrol on the service and start using it within minutes. We will implement a sample application to show the easiness.
  • Monitoring support: You can monitor different metrics like request count, cost, average storage etc .. Under the usage panel, you can see lots of details with your table
  • Availability and scalability: Upstash supports multi-zone replication to improve availability and scalability. It also meets with a disaster recovery strategy for critical applications.
  • Backup: With the backup feature, you can easily create an on-demand and scheduled backup. The backup can be restored to the latest backup time.
  • Security: It supports the different levels of data encryption to improve data security. Apart from that, Upstash supports some additional security features like IP Whitelisting, TLS etc
  • Reduce time to production: Since Upstash manages the infrastructure, you are going to focus on your product instead of focusing on server provisioning and management.
  • Web-based CLI: You can easily use Redis commands via CLI. The details are in this link: https://docs.upstash.com/redis/overall/rediscompatibility
  • Web-based data browser: Upstash provides a web-based data browser, so you don’t need to install any client-based data viewer.
  • Documentation: It is very important for new beginners as well as developers who will use more complicated features. Upstash documentation includes mandatory details for users

Sample Application with Upstash

Let’s implement a quick POC with Upstash. For beginners, Upstash provides a free tier plan, and you don’t need to pay any money.

Official link: https://upstash.com/

Step 1- Creating an account on Upstash

Upstash allows you to create an account with your email, password or other accounts like Amazon, GitHub and Google

Sign-in to Upstash

Step 2-Create a Redis database from the console. You can also import and migrate the database from the console

Step 3-You are going to fill out the database name and regional information

Step 4-After creating the database, you will see the details to connect to the database

Step 5-You can see the different types of code snippets. In the below panel, Upstash also provides a REST API call

Let’s implement a simple Java code to use the Redis database which is on Upstash. As I mentioned, Upstash provides code snippets that support popular programming languages.

I will use Jedis as a Redis client library to connect Redis from Java, you can use the following maven snippet to import the Jedis library

Create a simple Java code and paste the following which also exists in your Upstash panel

Note: You need to replace your Redis URL and password.

The code connects to Redis which is in the Upstash and adds a simple key/value pair like “UserPoint”

After running the code snippet, we will see the value that we put to Redis

Congrats! You easily used Redis via Upstash within minutes. We have implemented a simple application with Redis.

For developers who want to use Kafka, it is still simple how we implemented it in Redis.

Conclusion

There are different architectural approaches to setting up your project infrastructure either in the on-premise or in the cloud. Cloud comes to play with different advantages like easiness, logging, monitoring, scalability and availability. If you don’t have any impediment to using the cloud, I think the cloud is a very good option. For using Redis and Kafka, Upstash is one of the best solutions within the cloud providers with serverless support for that requirement.

--

--