Leaders Logo

When a Relational Database is Not Enough: The Role of KVS in Modern Architecture

Introduction

In recent years, the amount of data generated and stored has grown exponentially. This data explosion has highlighted the need for new approaches to storage and information management. While relational databases have been the norm for decades, they often struggle to meet the demands for scalability, flexibility, and performance required by modern applications. In this context, Key-Value Stores (KVS) emerge as a viable and effective alternative. This article examines the role of KVS in modern architecture and when their use would be highly beneficial.

Example Design

The diagram below illustrates a hybrid architecture, combining a traditional relational database with a KVS, demonstrating how both can coexist to meet different performance and consistency requirements.

SVG Image of the Article

Relational Databases: Limitations and Challenges

Relational Model

Relational databases organize data into tables, establishing relationships between them (DA SILVA; NETO, 2024). This structure is suitable for many applications but presents limitations in high scalability and data complexity scenarios.

Performance and Scalability

As the volume of data grows, relational databases may face performance challenges, especially in read and write operations. The need for normalization can lead to complex queries that affect performance.

Flexibility

Relational databases require a rigid schema, which can make it difficult to adapt to changes in data requirements. In dynamic environments, this rigidity can be a significant obstacle.

Key-Value Stores: A Modern Alternative

Definition and Characteristics

Key-Value Stores are a type of NoSQL database that stores data as key-value pairs (SEEGER, 2009). This simplicity allows for fast and flexible access to data, making them ideal for applications that require high performance and scalability.

Common Use Cases

KVS are widely used in applications that demand high availability and low latency. Examples include:

  • Storing user sessions in web applications.
  • Data caching for applications that require quick responses.
  • Real-time data management, such as in recommendation systems.

Comparison between Relational Databases and Key-Value Stores

Data Model

While relational databases use a structured model, KVS are more flexible in how they store and access data. This allows KVS to quickly adapt to different data schemas.

Performance and Scalability

KVS are designed to scale horizontally, allowing applications to support an increasing volume of data without compromising performance. Below is an example of implementing a KVS using Redis in C#:


using StackExchange.Redis;

class Program
{
    static void Main(string[] args)
    {
        // Connecting to the Redis server
        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
        IDatabase db = redis.GetDatabase();

        // Storing a value
        db.StringSet("key1", "value1");

        // Retrieving a value
        string value = db.StringGet("key1");
        Console.WriteLine($"Retrieved value: {value}");
    }
}
    

When to Opt for Key-Value Stores?

High Availability

If your application requires high availability and fault tolerance, KVS are an ideal choice. With data replication and distribution, KVS ensure that data is always accessible.

Low Latency

For applications that require real-time responses, such as online games or chat systems, KVS offer extremely low latency due to their simple architecture.

Flexibility and Evolution

The adoption of solutions like Amazon DynamoDB not only eliminates the dependence on fixed schemas but also expands the capacity for horizontal persistence, ensuring high availability and scalability in distributed microservices (SABBAG FILHO, 2025). This approach allows KVS to evolve alongside the application domain, preserving performance even under exponential data growth.

Below is an example of how to store complex data in a KVS using Amazon DynamoDB:


using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DocumentModel;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new AmazonDynamoDBClient();
        var table = Table.LoadTable(client, "MyTable");

        // Creating a document
        var document = new Document();
        document["Id"] = 1;
        document["Name"] = "Product A";
        document["Details"] = new List<string> { "Detail 1", "Detail 2" };

        // Saving the document
        await table.PutItemAsync(document);
    }
}
    

Challenges and Considerations

Data Consistency

KVS often opt for eventual consistency models, which can be a concern in applications that require strong consistency. It is crucial to evaluate consistency requirements before opting for a KVS.

Data Management

Although KVS are flexible, the lack of a schema can lead to more complex data management. This requires robust monitoring and maintenance practices to avoid data integrity issues.

Conclusion

Key-Value Stores are becoming an essential part of modern data architectures, especially in scenarios where scalability, flexibility, and performance are crucial. While relational databases still have their place, it is important to consider KVS as a viable alternative to meet the demands of current applications. The choice between a relational database and a KVS should be based on the specific needs of the application, taking into account factors such as data volume, performance requirements, and the nature of the data to be stored.

References

  • DA SILVA, João Manoel; NETO, Joaquim MF Antunes. The Role of Databases in Data Science Projects: How the Choice of Database Impacts the Efficiency of Analyses. Prospectus (ISSN: 2674-8576), v. 6, n. 2, p. 335-371, 2024. reference.Description
  • SEEGER, Marc; ULTRA-LARGE-SITES, S. Key-value stores: a practical overview. Computer Science and Media, Stuttgart, 2009. reference.Description
  • SABBAG FILHO, Nagib. Redis and DynamoDB: Intelligent Cache and Scalable Persistence in Microservices. Leaders Tec, vol. 2, no. 26, 2025. reference.Description
About the author