AWS Introduces AZ Affinity Strategy in Open Source Valkey GLIDE Client Library

by drbyos

AWS Enhances Valkey GLIDE with Availability Zone Awareness

AWS has recently released an update to its open-source Valkey General Language Independent Driver for Enterprise (GLIDE) client library, introducing a critical feature known as Availability Zone (AZ) affinity routing. This enhancement, available in version 1.2 of GLIDE, allows developers to optimize their cloud operations by directing requests to replicas within the same AZ as the client. This approach promises significant reductions in both latency and operational costs.

Understanding AZ Affinity Routing

Valkey GLIDE, originally developed by the AWS team and written in Rust, is a versatile multi-language client library compatible with both Valkey and Redis OSS. Last summer, AWS introduced Valkey 8, which included the ability for clients to specify the AZ for each Valkey server. With the latest update, GLIDE now leverages this capability to implement AZ affinity routing.

New AZ Affinity Strategy

In addition to the existing PREFER_REPLICA and PRIMARY strategies, GLIDE now supports the AZ_AFFINITY strategy. This new approach ensures that read commands are directed to a replica located within the same AZ as the client. This minimizes data transfer across different zones, which is often associated with higher costs and slower processing times.

“By leveraging AZ affinity routing, developers can reduce both the cost associated with cross-Zone data transfers and the latency experienced by applications,” commented Asaf Porat Stoler, Software Development Manager at AWS.

AZ Affinity Routing Strategy

Benefits of AZ Affinity Routing

The introduction of AZ affinity routing offers several benefits for cloud users. Firstly, it drastically reduces data transfer costs. In cloud environments, transferring data across different AZs can incur additional charges. By keeping all data traffic within the same AZ, these extra costs can be eliminated.

Secondly, AZ affinity routing enhances application responsiveness by minimizing latency. Operations that involve reading data from a replica located in the same AZ as the client will experience significantly lower latency as compared to cross-AZ operations.

Example of Cost Savings

To illustrate the potential savings, consider an AWS environment where a Valkey cluster consists of 2 shards, each with 1 primary and 2 replicas. The cluster processes 250MB of data per second, and all operations constitute read commands. If 50% of this traffic crosses AZs, the cross-AZ data transfer cost would amount to approximately $3,285 per month. The total operational cost would be $4,373 per month, including the cost of cluster nodes.

“Implementing AZ affinity routing can reduce the total cost from $4,373 to $1,088, as traffic remains within the same AZ,” said Stoler.

Implementing AZ Affinity Routing in GLIDE

To benefit from AZ affinity routing in GLIDE, developers need to configure the availability zone for each Valkey node. This configuration is language-specific, and the process differs depending on the chosen language for development. Here’s how to set it up in Java:

client.configSet(Map.of("availability-zone", az), new ByAddressRoute("address.example.com", 6379))
    

After configuring the availability zone, developers should instantiate GLIDE with AZ-specific targeting enabled:

GlideClusterClientConfiguration config = GlideClusterClientConfiguration.builder()
    .address(NodeAddress.builder()
        .host("address.example.com")
        .port(6379)
        .build())
    .readFrom(ReadFrom.AZ_AFFINITY)
    .clientAZ("us-east-1a")
    .build()
GlideClusterClient client = GlideClusterClient.createClient(config).get();
    

Compatibility and Support

Valkey GLIDE supports Valkey versions 7.2 and later, as well as Redis open-source versions 6.2, 7.0, and 7.2. However, AZ affinity routing is exclusively available with Valkey 8.0. Developers using earlier versions of Valkey will need to upgrade to take advantage of this feature.

Conclusion

The enhancement of Valkey GLIDE with AZ affinity routing represents a significant step forward in cloud computing efficiency. By routing data requests to replicas within the same AZ, AWS is helping developers reduce operational costs and improve application performance. This update is particularly beneficial for businesses relying heavily on cloud services and looking to optimize their infrastructure.

If you’re a developer working with AWS and cloud-based key/value datastores, consider upgrading to Valkey GLIDE version 1.2 to enjoy these benefits. Implementing AZ affinity routing could lead to substantial savings and improved application responsiveness.

We encourage you to share your thoughts on this enhancement. Does your business stand to benefit from AZ affinity routing? Share your experiences and insights in the comments below.

Related Posts

Leave a Comment