Serverless functions are great for many tasks with their dynamic scaling and flexible pricing models. But when you have a task which is composed of long running complex steps, it is not feasible to run it in a single serverless function. A simple solution is simply to offload complicated tasks from the serverless function. You can process those asynchronously in your preferred environment, this can be other serverless functions, serverless containers or traditional server based processes too. To offload your tasks, you need a reliable event queue. In this article we will use Upstash Redis for this purpose.
Google Cloud Functions is the second most popular serverless execution platform. Similar to AWS Lambda it is stateless, namely you need to access external resources to read or write your applications state. In this post, we will introduce Redis as a database for your Google Cloud functions.
This tutorial shows how to build a serverless API with Redis on Google Cloud Functions. The API will simply count the page views and show it in JSON format.
In this tutorial, we will implement a Serverless API using AWS Lambda and we will deploy it using AWS CDK. We will use TypeScript as the CDK language. It will be a page view counter where we will keep the state in Redis.
Check the Github repo for the source code.
AWS CDK is an interesting project which allows you to provision and deploy AWS infrastructure with code.
The above projects allows you to set up the infrastructure…
Next.js is a very successful web framework that brings together server side rendering and static site generation. SSG speeds up your website thanks to CDN caching meanwhile SSR helps you with SEO and dynamic data.
Server side rendering is a great feature that helps you to write fullstack applications. But if you are not careful, the performance of your Next.js website can be affected easily. In this blog post, I will explain how to leverage Redis to speed up your Next.js API calls. Before that, I will briefly mention a simpler way to improve your performance.
SWR is a very…
One of the best things about serverless is its ability to scale even in huge traffic spikes. But unfortunately, scaling is not free both financially and technically. That’s why developers need to control their applications’ scalability. Here are the main reasons you will need a rate limiting mechanism in your serverless application:
1- Protect your resources: If you’re providing a public API, traffic spikes can degrade the quality of the service, and may lead to a service outage for all your users. You need to protect your system against such cascading failures as well as self-inflicted DDoS incidents. A bug…
While developing the latency benchmark for the serverless databases (DynamoDB, FaunaDB, Upstash), I wished there was an API where I will record the latency numbers and get the histogram back. In this tutorial, I will build such an API where you can record your latency values from any application. It will be a serverless REST API with following methods:
I will show how easy to develop a generic API using AWS Lambda and Serverless Redis.
Step-1:Create a Redis (Upstash) Database
Create a database as defined at getting started
Step-2:Serverless Project Setup
If you do not have…
In this tutorial, we will develop a simple coin price list using GraphQL API of Upstash. You can call the application
We want to give a use case where you can use the GraphQL API without any backend code. The use case is publicly available read only data for web applications where you need low latency. The data is updated frequently by another backend application, you want your users to see the last updated data. …
In this article, I will compare the latencies of three serverless databases DynamoDB, FaunaDB, Upstash (Redis) for a common web use case.
I have inserted 7001 NY Times articles into each database. The articles are collected from New York Times Archive API(all articles of January 2021). I randomly scored each article. At each page request, I query top 10 articles under the
World section from each database.
I use serverless functions (AWS Lambda) to…
We will keep country names in a Redis Sorted set. In Redis sorted sets, elements with the same score are sorted lexicographically. So in our case, all country names will have the same score, 0. We keep all prefixes of country and use ZRANK to find the terms to suggest. See this blog post for the details of the algorithm.
If you do not have it already install the serverless framework via:
npm install -g serverless
In any folder run…
Designing a database for serverless, the biggest challenge in our mind was to build an infrastructure which supports per request pricing in a profitable way. We believe Upstash has achieved this. After we launched the product, we saw that there was another major challenge: Database connections!
As you know, Serverless Functions scale from 0 to infinity. This means when your functions get a lot of traffic, the cloud provider creates new containers (lambda functions) in parallel and scales out your backend. …