<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vishnu VG</title>
    <description>The latest articles on DEV Community by Vishnu VG (@vishnuvg).</description>
    <link>https://dev.to/vishnuvg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F720367%2Fab6dd1e0-0df2-4923-b294-f8bf58a81a4a.png</url>
      <title>DEV Community: Vishnu VG</title>
      <link>https://dev.to/vishnuvg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vishnuvg"/>
    <language>en</language>
    <item>
      <title>Leveraging Redis Services on AWS</title>
      <dc:creator>Vishnu VG</dc:creator>
      <pubDate>Wed, 09 Jul 2025 18:15:22 +0000</pubDate>
      <link>https://dev.to/vishnuvg/redis-on-aws-32kg</link>
      <guid>https://dev.to/vishnuvg/redis-on-aws-32kg</guid>
      <description>&lt;p&gt;I recently attended the KSUG.ai MCP Meetup held at the Microsoft Office in Bangalore. One of the sessions that struck me was Himanshumalis session about the AI and MCP Capabilities in Redis.&lt;/p&gt;

&lt;p&gt;I’ve been working with the installed version of Redis on either on-premises or EC2 instances. While attending the sessions, I learned about the different Redis AI offerings, especially the Redis MCP Server, Semantic Search, Redis Vector Set, and RAG capabilities. Though the session was primarily focused on Redis, in this article, I am attempting to consolidate how to leverage Redis AI-related offerings on AWS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Redis Offerings in AWS
&lt;/h2&gt;

&lt;p&gt;AWS primarily offers Redis-based managed services named AWS ElastiCache and AWS MemoryDB for Redis (formerly AWS Memcached service). These are managed services from AWS, where AWS handles the heavy lifting. Your applications can simply connect to these cache services and take advantage of managed cache functionality. Choosing between ElastiCache and MemoryDB depends on your application’s requirements. The key considerations are persistence and latency; everything else — API, features, management — remains similar.&lt;/p&gt;

&lt;p&gt;If your applications need a fast cache with sub-millisecond latency and no persistence (data will be available on restart), you should go with ElastiCache for Redis. However, if you can compensate for sub-millisecond latency with 1–3 ms latency and durable persistent storage (managed by AWS), you should go with MemoryDB for Redis. Please be aware that there is also a separate ElastiCache non-Redis offering from AWS available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting Your Application to ElastiCache / MemoryDB (Based on .NET Core)
&lt;/h2&gt;

&lt;p&gt;The Redis client code is identical for both services; only the connection string and infrastructure differ.&lt;/p&gt;

&lt;p&gt;We start by installing the required Redis NuGet package. For JavaScript frameworks or Java, equivalent npm packages or Java code will be available.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Install-Package StackExchange.Redis&lt;/code&gt;&lt;br&gt;
The next step is to create the required Redis managed service in AWS — either ElastiCache for Redis or MemoryDB for Redis. Grab the connection string and set it in your application’s configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "ConnectionStrings": {
    "ElastiCache": "your-elasticache-cluster.cache.amazonaws.com:6379",
    "MemoryDB": "clustercfg.your-memorydb.memorydb.us-east-1.amazonaws.com:6379"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to inject Dependency Injection to use Redis services. DI in .NET Core is specifically designed to inject custom behaviors and implementations throughout your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// ElastiCache
builder.Services.AddSingleton&amp;lt;IConnectionMultiplexer&amp;gt;("ElastiCache", provider =&amp;gt;
{
    var connectionString = builder.Configuration.GetConnectionString("ElastiCache");
    return ConnectionMultiplexer.Connect(connectionString);
});
// MemoryDB
builder.Services.AddSingleton&amp;lt;IConnectionMultiplexer&amp;gt;("MemoryDB", provider =&amp;gt;
{
    var connectionString = builder.Configuration.GetConnectionString("MemoryDB");
    return ConnectionMultiplexer.Connect(connectionString);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, the actual Program.cs code that has the Redis implementations. The code shows implementations for both ElastiCache and MemoryDB; however, your application may use either one of those or both.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
using StackExchange.Redis;
using System.Text.Json;
public class RedisService
{
    private readonly IDatabase _database;
    private readonly string _serviceName;
    public RedisService(string connectionString, string serviceName = "Redis")
    {
        var redis = ConnectionMultiplexer.Connect(connectionString);
        _database = redis.GetDatabase();
        _serviceName = serviceName;
    }
    public async Task SetAsync(string key, string value, TimeSpan? expiry = null)
    {
        await _database.StringSetAsync(key, value, expiry);
        Console.WriteLine($"[{_serviceName}] Set key: {key}");
    }
    public async Task&amp;lt;string&amp;gt; GetAsync(string key)
    {
        var value = await _database.StringGetAsync(key);
        Console.WriteLine($"[{_serviceName}] Get key: {key}, Found: {value.HasValue}");
        return value;
    }
    public async Task&amp;lt;T&amp;gt; GetObjectAsync&amp;lt;T&amp;gt;(string key)
    {
        var json = await _database.StringGetAsync(key);
        if (!json.HasValue) return default(T);
        return JsonSerializer.Deserialize&amp;lt;T&amp;gt;(json);
    }
    public async Task SetObjectAsync&amp;lt;T&amp;gt;(string key, T obj, TimeSpan? expiry = null)
    {
        var json = JsonSerializer.Serialize(obj);
        await _database.StringSetAsync(key, json, expiry);
    }
    public async Task&amp;lt;bool&amp;gt; DeleteAsync(string key)
    {
        return await _database.KeyDeleteAsync(key);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By following the above approach, you can connect your existing applications, whether on-premises or in the cloud, to take advantage of managed Redis services offered by AWS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting Your EC2, Container / Kubernetes Services to Redis
&lt;/h2&gt;

&lt;p&gt;Based on your requirements, sometimes your application may be running on an EC2 instance or container instances like AWS Fargate or Kubernetes, and you want to connect to Redis. For EC2, Container, and Kubernetes, you can follow the same approach. You can use IAM roles to retrieve Redis connection strings from AWS services (Parameter Store/Secrets Manager), but you still need to explicitly connect to Redis with that endpoint. Redis itself doesn’t use IAM authentication like other AWS services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Serverless Instances with Lambda (with C#)
&lt;/h2&gt;

&lt;p&gt;The approach is almost the same; you have to use NuGet packages, and the code looks identical. However, for Lambda, storing credentials via Environment Variables is more common.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
public class Function
{
    private static readonly Lazy&amp;lt;IConnectionMultiplexer&amp;gt; _redis = new Lazy&amp;lt;IConnectionMultiplexer&amp;gt;(() =&amp;gt;
        ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING"))
    );
    public async Task&amp;lt;string&amp;gt; FunctionHandler(string input, ILambdaContext context)
    {
        var database = _redis.Value.GetDatabase();
        await database.StringSetAsync("key", input);
        return await database.StringGetAsync("key");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can use a Parameter Store with an IAM Role.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public class Function
{
    private static IConnectionMultiplexer _redis;
    private static readonly AmazonSimpleSystemsManagementClient _ssmClient = new();
    public async Task&amp;lt;string&amp;gt; FunctionHandler(string input, ILambdaContext context)
    {
        // Initialize Redis connection if not already done
        if (_redis == null)
        {
            var parameter = await _ssmClient.GetParameterAsync(new GetParameterRequest
            {
                Name = "/myapp/redis/endpoint"
            });
            _redis = ConnectionMultiplexer.Connect(parameter.Parameter.Value);
        }
        var database = _redis.GetDatabase();
        return await database.StringGetAsync("key");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And your Lambda role should have the following permission:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": ["ssm:GetParameter"],
            "Resource": "arn:aws:ssm:*:*:parameter/myapp/redis/*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While writing Lambda code, make sure to use static variables and reuse the connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// Good - Static connection (reused across invocations)
private static readonly Lazy&amp;lt;IConnectionMultiplexer&amp;gt; _redis = new Lazy&amp;lt;IConnectionMultiplexer&amp;gt;(() =&amp;gt;
    ConnectionMultiplexer.Connect(connectionString)
);
// Bad - New connection per invocation (slow)
public async Task Handler()
{
    var redis = ConnectionMultiplexer.Connect(connectionString); // Don't do this
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use MemoryDB with Lambda, your Lambda must be inside a VPC with the required VPC configuration. The SAM YAML infrastructure as code looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
VpcConfig:
  SecurityGroupIds:
    - sg-12345678    # Allow outbound to Redis port 6379
  SubnetIds:
    - subnet-12345678
    - subnet-87654321
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-World Uses of Caches with AWS ElastiCache or MemoryDB
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS ElastiCache&lt;/strong&gt;&lt;br&gt;
AWS ElastiCache is widely adopted across industries for high-performance caching solutions. Airbnb uses ElastiCache for Redis to cache search results and user sessions, handling millions of property searches with sub-millisecond response times. Snapchat leverages it to store user stories and chat metadata, processing billions of snaps daily while managing massive engagement spikes. Expedia Group caches hotel pricing and availability data to reduce database load for travel searches, while Samsung implements ElastiCache for mobile app backend caching, supporting millions of Galaxy users globally. Duolingo uses ElastiCache for Redis to cache user progress and lesson data for over 500 million language learners, enabling real-time leaderboards and progress tracking. Common use patterns include e-commerce product catalogs and shopping carts, gaming leaderboards and player stats, media content metadata, financial trading data, and social media user feeds. These implementations typically achieve 10–100x performance improvements and significant cost savings for high-traffic applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ElastiCache — Common Use Patterns&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;E-commerce: Product catalogs, shopping carts, user sessions&lt;/li&gt;
&lt;li&gt;Gaming: Leaderboards, player stats, real-time game state&lt;/li&gt;
&lt;li&gt;Media: Content metadata, user preferences, streaming data&lt;/li&gt;
&lt;li&gt;Financial: Trading data, user portfolios, transaction caching&lt;/li&gt;
&lt;li&gt;Social: User feeds, notifications, friend connections&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  AWS MemoryDB for Redis (formerly Memcached)
&lt;/h2&gt;

&lt;p&gt;MemoryDB for Redis is adopted by companies requiring simple, high-performance key-value caching. Pinterest uses MemoryDB for caching user feed data and board recommendations, handling billions of pins with its lightweight architecture and multi-threading capabilities. Reddit implements MemoryDB for caching comment threads and user data, benefiting from its simplicity for high-volume read operations alongside other caching layers. Flickr leverages MemoryDB extensively for photo metadata caching, using its simple protocol to serve millions of photo requests daily with minimal overhead.&lt;/p&gt;

&lt;p&gt;Companies choose MemoryDB over ElastiCache for Redis when they need pure key-value storage without complex data structures, better CPU utilization through multi-threading, lower memory overhead, and faster performance for simple caching operations. Common use cases include web application session storage, database query result caching, API response caching, and simple object caching where Redis’s advanced features would be unnecessary complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MemoryDB — Common Use Patterns&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Web application session storage&lt;/li&gt;
&lt;li&gt;Database query result caching&lt;/li&gt;
&lt;li&gt;API response caching&lt;/li&gt;
&lt;li&gt;Simple object caching&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Taking Advantage of Redis AI Features
&lt;/h2&gt;

&lt;p&gt;Once you have a grasp of basic Redis awareness and how to connect your application, let’s see how to take advantage of some of the AI features offered by Redis. This was the core theme of Himanshu’s presentation. Redis recently launched the Redis MCP Server and a set of AI capabilities along with it. The MCP Server is separate from Redis AI modules (RedisAI, RediSearch, etc.). However, to take advantage of these Redis-specific AI features in AWS, you need to use Redis Cloud or a self-hosted Redis Stack for AI features. We will discuss both of these, starting with using Redis Cloud with AWS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis Cloud with AWS or Self-Hosted to Take Advantage of AI Features?&lt;/strong&gt;&lt;br&gt;
Redis Cloud is a managed service provided by Redis Labs. You have the option to create a Redis environment and an underlying cloud provider (AWS, Azure, or GCP) as needed. Your created environment will be inside a separate account within an AWS VPC. To map your environment (AWS account) to it, you have to use VPC Peering. Your set of services will be inside your VPC, and you have to VPC peer to the Redis Cloud Instance VPC. Alternative options like AWS PrivateLink, Public internet (with security groups), and AWS Transit Gateway are also possible to connect to the Redis environment. Once your VPC is connected to the respective Redis VPC, you can take advantage of Redis AI Offerings. Your applications will interact with the Redis instances hosted in Redis Cloud via the respective SDK.&lt;/p&gt;

&lt;p&gt;Another option is to use a self-hosted Redis Stack on your EC2 instance. While this offers more flexibility, the management overhead related to maintaining EC2 servers, their cost, availability, and upgrading Redis Stack remains with you. Self-hosted Redis Stack on EC2 costs ₹5,000-₹20,000/month in direct AWS charges but requires significant engineering time for setup, maintenance, and operations. Redis Cloud costs ₹8,000-₹25,000/month but is fully managed with zero operational overhead. While self-hosted appears cheaper upfront, Redis Cloud often provides a better total cost of ownership when factoring in engineering resources and operational complexity.&lt;/p&gt;
&lt;h2&gt;
  
  
  MCP Server: How It Helps ?
&lt;/h2&gt;

&lt;p&gt;This is a natural question for most developers: What is the need for an MCP Server for a cache service like Redis? From above, we could see applications interact with Redis (whether it’s managed services like ElastiCache or MemoryDB, or a self-hosted Redis Stack) primarily through Redis protocol/SDKs. The MCP Server allows one to interact with underlying Redis services through Natural Language. This is achieved through a combination of LLM (AI models) plus the MCP server (which allows a protocol for LLMs to interact and initiate actions). The MCP server manages user actions. I’ll provide a few samples for common Redis operations here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Data Operations:&lt;/strong&gt;&lt;br&gt;
User: “Store user John with email &lt;a href="mailto:john@example.com"&gt;john@example.com&lt;/a&gt;” Redis MCP: Executes → HSET user:john email "&lt;a href="mailto:john@example.com"&gt;john@example.com&lt;/a&gt;"&lt;br&gt;
User: “Get all information about user John” Redis MCP: Executes → HGETALL user:john&lt;br&gt;
User: “Delete user John’s data” Redis MCP: Executes → DEL user:john&lt;br&gt;
Search and Analytics&lt;br&gt;
User: “Show me all users who logged in today” Redis MCP: Executes → ZRANGEBYSCORE login_times [today_timestamp] +inf&lt;br&gt;
User: “Find the top 10 most active users this week” Redis MCP: Executes → ZREVRANGE user_activity 0 9 WITHSCORES&lt;br&gt;
User: “How many users are currently online?” Redis MCP: Executes → SCARD online_users&lt;br&gt;
&lt;strong&gt;Ecommerce Examples&lt;/strong&gt;&lt;br&gt;
User: “Add iPhone to John’s shopping cart” Redis MCP: Executes → SADD cart:john "iPhone"&lt;br&gt;
User: “What’s in Sarah’s cart and how much does it cost?” Redis MCP: Executes → SMEMBERS cart:sarah + price lookups&lt;br&gt;
User: “Show me products viewed more than 100 times” Redis MCP: Executes → ZRANGEBYSCORE product_views 100 +inf&lt;br&gt;
&lt;strong&gt;Session Management&lt;/strong&gt;&lt;br&gt;
User: “Is user session abc123 still active?” Redis MCP: Executes → EXISTS session:abc123&lt;br&gt;
User: “Extend user session for another hour” Redis MCP: Executes → EXPIRE session:abc123 3600&lt;br&gt;
User: “Show all active sessions from the last 30 minutes” Redis MCP: Executes → ZRANGEBYSCORE active_sessions [30min_ago] +inf&lt;br&gt;
User: “Cache this API response for 10 minutes” Redis MCP: Executes → SETEX api:response:123 600 "response_data"&lt;br&gt;
User: “Clear all cached data older than 1 hour” Redis MCP: Executes → Custom script with TTL checks&lt;br&gt;
User: “How much memory is Redis using?” Redis MCP: Executes → INFO memory&lt;/p&gt;

&lt;p&gt;The key advantage is that non-technical users can interact with Redis data using plain English instead of learning Redis commands, while developers get the full power of Redis operations translated automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Use Cases with Redis MCP Server&lt;/strong&gt;&lt;br&gt;
As it’s relatively new and too early to adopt as of this writing, there is a potential for the Redis MCP server. I’ve consolidated a few and provided them below:&lt;/p&gt;
&lt;h2&gt;
  
  
  Potential Early Use Cases for Redis MCP Server
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DevOps and Operations:&lt;/strong&gt;&lt;br&gt;
Monitoring dashboards: “Show me Redis memory usage trends for the last hour”&lt;br&gt;
Troubleshooting: “Find all keys that are consuming the most memory”&lt;br&gt;
Performance analysis: “Which Redis operations are slowest today?”&lt;br&gt;
Capacity planning: “How many active sessions do we have right now?”&lt;br&gt;
Business Intelligence and Analytics:&lt;/p&gt;

&lt;p&gt;Real-time metrics: “What are our top-selling products this week?”&lt;br&gt;
User behavior: “How many users logged in from mobile devices today?”&lt;br&gt;
A/B testing: “Compare conversion rates between test groups”&lt;br&gt;
Revenue tracking: “Show me hourly sales data for the past 24 hours”&lt;br&gt;
AI and Chatbot Integration:&lt;/p&gt;

&lt;p&gt;Customer support bots: “Check if user’s session is still active”&lt;br&gt;
Recommendation engines: “Get user’s recently viewed products”&lt;br&gt;
Personalization: “What are this user’s preferences and settings?”&lt;br&gt;
Content delivery: “Retrieve cached content for this geographic region”&lt;br&gt;
Developer Productivity Tools:&lt;/p&gt;

&lt;p&gt;Debugging interfaces: “Show me all failed login attempts in the last 10 minutes”&lt;br&gt;
Data exploration: “List all users who have incomplete profiles”&lt;br&gt;
Testing environments: “Clear all test data from yesterday”&lt;br&gt;
API development: “Cache this API response for 5 minutes”&lt;br&gt;
Internal Business Tools:&lt;/p&gt;

&lt;p&gt;Admin panels: “How many premium subscribers do we have?”&lt;br&gt;
Reporting systems: “Generate user engagement report for last month”&lt;br&gt;
Inventory management: “Check stock levels for products in the cart”&lt;br&gt;
Fraud detection: “Show suspicious login patterns from last week”&lt;br&gt;
These use cases focus on making Redis data accessible to non-technical stakeholders and improving developer productivity through natural language interfaces.&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementing a Redis MCP Server in AWS
&lt;/h2&gt;

&lt;p&gt;A Redis MCP Server can be implemented using a self-hosted Redis Stack on EC2 or by using Redis Cloud with AWS. Additionally, you can also install a Redis MCP Server as a Fargate instance and connect to your AWS ElastiCache or MemoryDB managed services. We will now explore each of these implementations using .NET.&lt;/p&gt;

&lt;p&gt;Let’s start with the self-hosted EC2 Instance. Spin up a new EC2 instance in AWS and connect using SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d -p 6379:6379 -p 3000:3000 redis/redis-stack:latest
npm install -g @redis/mcp-server
redis-mcp-server --redis-url redis://localhost:6379 --port 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And from your .NET application, you can connect to your Redis MCP server. Please be aware that for simplicity, we are keeping the MCP Server and Redis instance on the same EC2. In a real-world application, the MCP and actual Redis instance can be separate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SelfHostedRedisService
{
    private readonly HttpClient _mcpClient;
    private readonly IConnectionMultiplexer _directRedis;
    public SelfHostedRedisService()
    {
        _mcpClient = new HttpClient { BaseAddress = new Uri("http://your-ec2-ip:3000") };
        _directRedis = ConnectionMultiplexer.Connect("your-ec2-ip:6379");
    }
    // Natural language via MCP
    public async Task&amp;lt;string&amp;gt; QueryNaturalLanguage(string query)
    {
        var request = new { query = query };
        var response = await _mcpClient.PostAsJsonAsync("/query", request);
        return await response.Content.ReadAsStringAsync();
    }
    // Direct Redis access
    public async Task&amp;lt;string&amp;gt; GetDirect(string key)
    {
        var db = _directRedis.GetDatabase();
        return await db.StringGetAsync(key);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Data Flow&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[Your .NET App] → [EC2:3000 MCP Server] → [EC2:6379 Redis Stack] → Response&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Redis MCP Server on Redis Cloud with AWS&lt;/strong&gt;&lt;br&gt;
The second approach is to use Redis Cloud. This helps to get all the benefits offered by Redis Cloud with the least management overhead, but you have to consider the cost aspects. By leveraging Redis Cloud, you get all the up-to-date features offered by Redis Cloud. Let’s see how this works in reality.&lt;/p&gt;

&lt;p&gt;For the Redis Cloud approach, you first sign up at redis.com and create a Redis database instance by selecting AWS as your cloud provider to ensure optimal connectivity and performance. Then, you deploy an MCP server on AWS EC2 or Fargate that connects to your Redis Cloud endpoint. Configure VPC peering or PrivateLink between your AWS environment and Redis Cloud for secure connectivity. Finally, connect your .NET Core application to both the MCP server for natural language queries and directly to Redis Cloud for standard operations using the provided connection string that includes authentication credentials.&lt;/p&gt;

&lt;p&gt;Once this is done, set the connection string details in your .NET Core application’s appsettings.json.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
{
  "RedisCloud": {
    "ConnectionString": "redis://:your-password@redis-12345.c1.us-east-1-1.ec2.cloud.redislabs.com:12345",
    "MCPEndpoint": "http://your-mcp-server-ip:3000"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in your application, you simply connect to the Redis MCP server. The main code areas are the RedisCloudService which connects to the MCP endpoint, and the RedisController.cs which simply uses the RedisCloudService.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public class RedisCloudService
{
    private readonly HttpClient _mcpClient;
    private readonly IConnectionMultiplexer _redisCloud;
    public RedisCloudService(IConfiguration config)
    {
        // MCP Server (your AWS infrastructure)
        _mcpClient = new HttpClient {
            BaseAddress = new Uri(config["RedisCloud:MCPEndpoint"])
        };
        // Redis Cloud (external managed service)
        var connectionString = config["RedisCloud:ConnectionString"];
        _redisCloud = ConnectionMultiplexer.Connect(connectionString);
    }
    // Natural language via MCP server
    public async Task&amp;lt;string&amp;gt; QueryNaturalLanguage(string query)
    {
        var request = new {
            query = query,
            database = "redis-cloud"
        };
        var response = await _mcpClient.PostAsJsonAsync("/api/query", request);
        return await response.Content.ReadAsStringAsync();
    }
    // Direct Redis Cloud access
    public async Task&amp;lt;string&amp;gt; GetDirectFromCloud(string key)
    {
        var db = _redisCloud.GetDatabase();
        return await db.StringGetAsync(key);
    }
    // Store data in Redis Cloud
    public async Task SetInCloud(string key, string value, TimeSpan? expiry = null)
    {
        var db = _redisCloud.GetDatabase();
        await db.StringSetAsync(key, value, expiry);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
[ApiController]
[Route("api/[controller]")]
public class RedisController : ControllerBase
{
    private readonly RedisCloudService _redisService;
    public RedisController(RedisCloudService redisService)
    {
        _redisService = redisService;
    }
    [HttpPost("ask")]
    public async Task&amp;lt;IActionResult&amp;gt; AskRedis([FromBody] NaturalLanguageRequest request)
    {
        try
        {
            var result = await _redisService.QueryNaturalLanguage(request.Query); // Changed AskRedis to QueryNaturalLanguage
            return Ok(new { query = request.Query, result = result });
        }
        catch (Exception ex)
        {
            return BadRequest(new { error = ex.Message });
        }
    }
    [HttpGet("get/{key}")]
    public async Task&amp;lt;IActionResult&amp;gt; GetValue(string key)
    {
        try
        {
            var value = await _redisService.GetDirectFromCloud(key); // Changed GetDirect to GetDirectFromCloud
            return Ok(new { key = key, value = value });
        }
        catch (Exception ex)
        {
            return BadRequest(new { error = ex.Message });
        }
    }
    [HttpPost("set")]
    public async Task&amp;lt;IActionResult&amp;gt; SetValue([FromBody] SetValueRequest request)
    {
        try
        {
            await _redisService.SetInCloud(request.Key, request.Value, request.ExpiryMinutes.HasValue ? TimeSpan.FromMinutes(request.ExpiryMinutes.Value) : (TimeSpan?)null); // Changed SetDirect to SetInCloud and added TimeSpan conversion
            return Ok(new { message = "Value set successfully" });
        }
        catch (Exception ex)
        {
            return BadRequest(new { error = ex.Message });
        }
    }
    [HttpPost("query-analytics")]
    public async Task&amp;lt;IActionResult&amp;gt; QueryAnalytics([FromBody] NaturalLanguageRequest request)
    {
        try
        {
            var result = await _redisService.QueryNaturalLanguage($"Analytics: {request.Query}"); // Changed AskRedis to QueryNaturalLanguage
            return Ok(new { query = request.Query, analytics = result });
        }
        catch (Exception ex)
        {
            return BadRequest(new { error = ex.Message });
        }
    }
}
public class NaturalLanguageRequest
{
    public string Query { get; set; }
}
public class SetValueRequest
{
    public string Key { get; set; }
    public string Value { get; set; }
    public int? ExpiryMinutes { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application can query using natural language as given below. The data flow is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.NET app sends natural language query to MCP server&lt;/li&gt;
&lt;li&gt;MCP server (on AWS) translates to Redis commands&lt;/li&gt;
&lt;li&gt;MCP server connects to Redis Cloud database&lt;/li&gt;
&lt;li&gt;Redis Cloud processes commands and returns data&lt;/li&gt;
&lt;li&gt;MCP server formats response back to .NET app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Redis MCP Server on AWS Fargate&lt;/strong&gt;&lt;br&gt;
Finally, we could use the serverless option, which is AWS Fargate, to connect to Redis Cloud.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:18-alpine
RUN npm install -g @redis/mcp-server
EXPOSE 3000
CMD ["redis-mcp-server", "--redis-url", "$REDIS_CLOUD_URL", "--port", "3000", "--host", "0.0.0.0"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows your serverless services to connect via AWS Fargate. The difference with this approach compared to the EC2 approach is that you don’t have to manage an EC2 instance and can save EC2 cost. AWS Fargate allows you to keep persistent connections with Redis Cloud and is always available for requests, thus this model is suitable for serverless scenarios, and the cost will be much cheaper than that of EC2. You cannot use AWS Lambda here as AWS Lambda functions are short-running services that run on demand and lack persistent connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Before winding up, we’ll quickly touch on a few other AI-related offerings from Redis. I will provide you with reference links to explore more. These are additional features added on top of Redis, so all that we discussed related to .NET Core still applies. To utilize these services, you need either Redis Cloud with AWS or a self-hosted Redis Stack in EC2. The AWS Fargate option is applicable only for utilizing the Redis MCP Server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Redis AI Offerings Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;RedisAI: Machine learning model serving platform that allows you to run AI models directly within Redis, supporting TensorFlow, PyTorch, and ONNX models for real-time inference with sub-millisecond latency. Learn more: &lt;a href="https://redis.io/docs/stack/ai/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/ai/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RediSearch with Vector Similarity: Full-text search engine with vector similarity search capabilities, enabling semantic search, recommendation systems, and similarity matching using vector embeddings for AI applications. Learn more: &lt;a href="https://redis.io/docs/stack/search/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/search/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RedisJSON with AI Integration: JSON document database that works seamlessly with AI workflows, allowing storage and querying of complex JSON documents containing embeddings, metadata, and AI model outputs. Learn more: &lt;a href="https://redis.io/docs/stack/json/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/json/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RedisGraph: Graph database for AI applications requiring relationship analysis, social networks, fraud detection, and recommendation engines with graph-based machine learning algorithms. Learn more: &lt;a href="https://redis.io/docs/stack/graph/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/graph/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RedisTimeSeries: Time-series database optimized for AI/ML workloads, IoT data, monitoring metrics, and real-time analytics with built-in aggregation and downsampling capabilities. Learn more: &lt;a href="https://redis.io/docs/stack/timeseries/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/timeseries/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RedisGears: Programmable data processing engine that enables real-time data transformations, ETL pipelines, and AI model triggering based on data changes within Redis. Learn more: &lt;a href="https://redis.io/docs/stack/gears/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/gears/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;RedisBloom: Probabilistic data structures for AI applications including Bloom filters, Cuckoo filters, Count-Min sketches, and Top-K for approximate analytics and machine learning feature engineering. Learn more: &lt;a href="https://redis.io/docs/stack/bloom/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/bloom/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;General Redis Stack Documentation: &lt;a href="https://redis.io/docs/stack/" rel="noopener noreferrer"&gt;https://redis.io/docs/stack/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduuoyvtmqhajb9li1yc4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduuoyvtmqhajb9li1yc4.jpg" alt="With Himanshumali, after the Redis AI session" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Disclaimer : All opinions are personal. &lt;/p&gt;

</description>
      <category>memcache</category>
      <category>elasticcache</category>
      <category>redis</category>
    </item>
    <item>
      <title>Containerization Benefits for Business</title>
      <dc:creator>Vishnu VG</dc:creator>
      <pubDate>Mon, 02 Oct 2023 16:47:54 +0000</pubDate>
      <link>https://dev.to/vishnuvg/containerization-benefits-for-business-7g2</link>
      <guid>https://dev.to/vishnuvg/containerization-benefits-for-business-7g2</guid>
      <description>&lt;p&gt;Containerization is a software deployment model to package your application code, its dependencies, configurations as a self-contained modular package to make it run on any infrastructure, be it your development laptop or in cloud infrastructure. This is a shift from traditional deployment model where you used to install the dependencies in advance before your application gets deployed. Now a days with containerization software developer’s don’t have to worry about the infrastructure installations during deployment time. Instead they could figure out all dependencies during application development itself, add a docker file to containerize it and hand over to any platforms which has container runtime. Typically an enterprise application consists of many modular containerized applications connected to each other through network (Rest API / gRPC) or through some form of cloud -native integrations. To manage or orchestrate multiple containers , enterprises use an orchestrator like Kubernetes or Cloud Kubernetes version like Amazon Elastic Kubernetes service or Amazon Container Service.&lt;/p&gt;

&lt;p&gt;Once an application has been containerized, developers use different forms of containerization technologies to test and deploy it. On the local development system they could use either Docker Desktop / Podman / Rancher to test and run it. For applications that require scale and using kubernetes , MiniKube provides a local development setup for simulate Kubenenetes running on a single cluster on a local system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Containerization use cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Cloud Native Foundation has standardized the implementations using OCI image specification standards and many container runtime vendors are already adopted it, so now a days to containerize an application means , its just a matter of adding a docker file provided if your modular application that you want to containerize has characteristics of microservice architecture. Your application should have ideal microservice characteristics like Modularity, Independent DataStore, Independent Deployability and your service accurately represent a part of business domain. Microservice architecture focus on a particular business domain and practices like EventStorming discussions can help to arrive a domain that you can plan to implement as a microservice or convert your existing monolith to a microservice. You could also consider containers for cases like cloud migration, deploying across IoT or custom devices , or for serverless integrations , event driven-scenarios etc. There are no hard and fast rules like where to use containers and most enterprises are considering containerizing as a part of cloud migration strategy to lift and shift their application to cloud provider to achieve scalability and reduce maintenance overhead, but its most suitable for microservice architecture. Serverless is another model similar to containerization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of Containerization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the above we could understand through containerization better organisation and modularization is what happening. Traditionally monolith applications were splitted based on technology domain as layered architectures/n-tier architecture , however maintanance was still a hurdle. In a layered architecture to make a simple change multiple team co-ordinations are required. Microservice made a change where monolith is split based on business domain and each team own a microservice has end to end visiblity over the microservice they own facilitating implementation hiding. This means they can use their own data store , its own technology suitable for the service, can containerize it and deploy to container platforms, which leads to portability, Better ownership and reduced team dependencies. Scalable services like Kubernetes could scale it and scale down with better isolation than hosting it on a Virtual Machine like (EC2), thus getting better cost effectiveness with better scalability . Fault tolerance increases as modular servies are more resilent to failtures and doesnt affect other services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to start and challenges to be aware of ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For newer application analyse whether a microservice/containerized architecture is feasible. Simple containerized application , as in lift-and shift cloud migration cases, offers portability, easy maintainability and better scalability. For applications that has scope to evolve and scalability spliting business domains and make more modular services connected via network interaces are a great choices. You could take advantage of kubernetes platform in cloud to orchestrate multi-container applications.&lt;/p&gt;

&lt;p&gt;If you planning to migrate your existing application, Analyse your existing application. A monolith application with a huge code base, is an ideal candidate for a evolving into a microservice architecture. You gets the benefits of Independent deployability, better maitanability and scalability however the potential side effects like additional complexity in forming a proper microservice architecture and the cost associated with it. Microservice is a form of distrubuted computing so operational logging and debugging will be a challenge , unless you consider cloud metrics like Cloud Trail/ Cloud Watch. There are other challenges as well associated with Distrubuted computing which you can refer here &lt;a href="https://aws.amazon.com/builders-library/challenges-with-distributed-systems/"&gt;https://aws.amazon.com/builders-library/challenges-with-distributed-systems/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which service to use ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes / Cloud Kubernetes Service like Elastic Kubernetes Service / Redhat Openshift services&lt;/p&gt;

&lt;p&gt;Ideal for scenarios where you have multi-containers which require scaling /orchestration/logging. You can also schedule to run batch container jobs and event triggeed jobs with Keda. Pricing will be high compared to other approaches as Cloud Providers charge a fixed price for Control Plan and a Variable Cost for Worker Nodes and Services.&lt;/p&gt;

&lt;p&gt;Serverless Containers like AWS Fargate &lt;/p&gt;

&lt;p&gt;Ideal for container scenarios without managing servers. In this case you have to run/trigger this services from some other integrated services like AWS Lamda, or EKS . Benefit you gets are zero server management and inbuilt scalability and fault tolerance with consumption model. Most of this model provides runtime to run containers from a container registry or container image&lt;/p&gt;

&lt;p&gt;Containers with Server Level Control&lt;/p&gt;

&lt;p&gt;Amazon Elastic Cloud Instances(EC2) allow to create windows/linux instances and run container instances. This offers great flexibility at the cost of operational overhead.&lt;/p&gt;

&lt;p&gt;Onpremise Scenarios&lt;/p&gt;

&lt;p&gt;For on-premise scenarios Amazon EKS Anywhere offers onpremises kubernetes services at the cost of ownpremise cluster management. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>containers</category>
      <category>eks</category>
      <category>kubernetes</category>
    </item>
  </channel>
</rss>
