By Afzaal Ahmad Zeeshan, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.
For decades, we have been in a cycle where we synthesize information in a new dimension with the wisdom of the past, and by reusing the same contexts and concepts, we keep reinventing. This is a continually evolving process that keeps the software industry revolving. In the same way, we have the dynamics of databases. Databases are not just used to store the data after a transaction has been processed, with the advent of real-time systems, and single-page ecommerce applications, our customers require our applications to remember what they were doing. Either being on the client-side or on the server-side. Formally, we used to work with in-memory databases, which stores the entire dataset in RAM (Random-Access-Memory), unlike the traditional and on-disk database system. Working with the in-memory database was not less than a charm because or several benefits that we get,
However, this ease diminishes when the system gets rebooted or your program crashes because you will not be able to recover this data ever again. Later, it became possible to empower the in-memory database with caching (in-memory-database to in-memory-cashing), to resolve the data persistence and durability issues.
With time, it has been realized that due to high request rate (input-output- requests-per-seconds), the additional resources such as more RAM and CPU, which ultimately mean your cost, as well as the management, is increasing. This management and the cost-shift will look satisfied in the peak business hours and craziest occasional traffic loads. And combining all this with the session state management, customer information on a transaction, sometimes it is obvious that we require a solution that does not cost us much, each year. In several of my own projects, I have utilized caching solutions that help me maintain a good performance for my app. Although caching and storage is available on client as well as server-side, we will mostly talk about the server-side caching technologies, especially Redis and how we can deploy a Redis caching server on Alibaba Cloud.
Redis works in-memory and provides a high throughput for your applications. Working in-memory requires a good suitable and large container for your memory requirements. In a general environment, your RAM is the component that wears out quickly. Over the course of decades, price of RAM has dropped fairly for your own on-premises datacenter development, but even with this scenario you cannot expect everything to work out as planned. Cloud providers and solutions work quite well in many scenarios, and the thing is, you do not have to worry about the infrastructure and setup costs—most cloud providers always provide the latest hardware technology for your solutions, so you also do not need to worry about upgrading your hardware.
Among variety of obvious reasons to think about a cloud provider for your data caching, the most prominent ones would be; accessibility, instant backup, and recovery. Because the data caching isn't a new concept, it has been around since ages now, and everyone – from a small business holder to a giant vendor (such as email services, image, and video sharing sites and other large enterprises) need a durable and expeditious cloud storage that can store and manage their data.
In the coming sections, we will explore the benefit that Alibaba Cloud users have when it comes to Redis deployment and management on the cloud scale. I would want to explore and show you how easy it is, to manage the cluster size, and provision the usage of the servers.
Before speaking about Alibaba Cloud ApsaraDB for Redis and having an insightful concept about its implementation and controls, let's talk about Redis itself. Because Alibaba has developed ApsaraDB for Redis entirely based on the actual Redis Protocol, it supports version 2.8 and 4 of Redis protocol, and we will see how they both differ in providing the services, to customers, but in a later section.
Redis (remote data structure server) is an in-memory database, with a range of data types, it stores and sorts data automatically. Your application's processes can access Redis from multiple different nodes; moreover, to make high availability of data possible, it replicates its activities with leader-follower (master-slave) mechanism. In short, if your application requires scalability and sharing of the same data on different nodes, then Redis is for you, it have built-in support for replication and distribution of data among cluster.
Due to high performance and ease of use, it is no surprise that all the mega cloud storage providers have implemented Redis to drive up its features. Similarly, ApsaraDB for Redis provides high persistency with a wide range of flexible architecture models – standard architecture and Cluster architecture, this is because Alibaba Cloud serves a wide range of business level requirements such as excessive read/write requests, capacity adjustments, and security strings. To be precise, ApsaraDB spins in-memory caching performance in the following ways:
Now, let us dive in a head and discuss how to create instances of ApsaraDB for Redis on the online portal for Alibaba Cloud.
ApsaraDB offers pay-as-you-go and subscription-based model, in both models the product behavior is same; you get the Redis server that can be used for
However, the most important difference is that once you create a type you cannot change it on the runtime—that is a limitation of Redis protocol itself. ApsaraDB for Redis can be purchased as an upfront payment, where you get various benefits and more support, or you can also try it out as a Pay-as-you-Go model.
Figure 1: Purchase panel for ApsaraDB for Redis
There are several data centers where you can deploy your solutions. This is the most primary thing to realize and understand in this overall process of deployment. A solution in the cloud can only help you, if you have deployed it closer to your audience. A solution deployed in a different region will not be able to help you out—latency would be higher. Next you get to select the version of the Redis protocol, the type of the nodes and the architecture of your application depends on the type of payment model you have, as well as the version you select. In Pay-as-you-Go mode, version 4 does not support clustered mode. You can use clustered mode with version 2.8, but you miss out the features and improvements provided in version 4. See the image below,
Figure 2: Pay-as-you-Go purchase model for ApsaraDB for Redis
Rest of the configurations are simply the ways to setup your system. You specify the size of the cluster you want, you can setup where you want to deploy, which network you want to deploy in, and so on. Once you are happy with the configurations that you have selected here, you can go ahead and create the instance. Alibaba Cloud will send you a notification, once your instance has been created and you can then use that instance to perform other actions, like accessing the resources, or making more changes to it. As you can see, my instance has been created and is ready to be used,
Figure 3: ApsaraDB for Redis instance list and status of our instance
Most of the information is already shown on this page, and you can use it—the instance information, payment options, network used etc. You can then go ahead in each of your instances and configure them from there, let's see how to do that in the next section.
Most basic of the configurations can be performed on the overview—default—page of the ApsaraDB for Redis Instance.
Figure 4: Basic configuration for our ApsaraDB for Redis instance
Everything from the basic network information, all the way to core Redis information like max number of clients is shown over here. Portal also shares the other tabs where you can configure more details about your subscription and service. Let's take a quick look at all of those.
As I have already mentioned, ApsaraDB itself maintains the architecture in a way that lets you not worry about the underlying high-availability for your resources. The architecture for the subscription that I have bought is something like this,
Figure 5: Architecture of our purchased service.
As you can see, the front-end of the service is then managed at the backend by internal services, proxies—you can think of them as load balancers. Your requests go through them and then they reach the layers where your data is maintained. Your data is also persisted so that your applications can rely on the data being there. A master-slave relationship is created for our solution, to maintain the backups as well.
ApsaraDB for Redis is deployed on the internal networks—VPCs where your services are configured for the internal DNS to be resolved for. This service is not available on the public internet, so you must access the resources from within the network and expose them via a web app, or a VM that might listen to these changes and perform actions.
However, you can access the Redis connection strings from the same page,
Figure 6: Connection settings and information for Redis running on Alibaba Cloud VPC
You can use any library that works with Redis and access the services. I tried with StackExchange.Redis library for .NET Core, you can try the same, just make sure you are within the network on VPC before accessing the service.
Apart from this, you can also control how your service is being used and how it spans across all the nodes that you are using, these configurations are also available inside the portal and you can edit them from within the browser too.
Figure 7: Server configurations for Redis cache in ApsaraDB
Most policies, like that cache removal upon maximum utilization policy can be configured right from here. Of course, most of the settings have been removed from this list, because of the size of the screenshot that I could take.
Finally, you can also configure the name of your service in the Alibaba Cloud. This can help you recover name collision, or it can help you name the services that can be remembered easily.
Figure 8: Editing of the service name for easier discovery on VPC
This way, you can easily control how your services are discovered on the VPC that you have on the Alibaba Cloud.
Now, I believe this is enough for an introduction, as we explored the overall structure of the Redis service provided by Alibaba Cloud's ApsaraDB, and its benefits. We also saw how we can create the accounts and which account would be better for our use case. We will look at how this can be integrated with other services available on Alibaba Cloud, like web apps, or VMs in later post.
Alibaba Clouder - July 26, 2019
Alibaba Clouder - June 2, 2020
Alibaba Cloud Blockchain Service Team - May 5, 2019
Alibaba Cloud New Products - August 20, 2020
Alibaba Cloud MaxCompute - March 2, 2020
Alibaba Clouder - June 2, 2020
A key value database service that offers in-memory caching and high-speed access to applications hosted on the cloudLearn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
Supports data migration and data synchronization between data engines, such as relational database, NoSQL and OLAPLearn More
More Posts by Alibaba Clouder