Need advice about which tool to choose?Ask the StackShare community!
IndexedDB vs Redis: What are the differences?
Key Differences between IndexedDB and Redis
IndexedDB and Redis are both popular database systems used in web development. While they share some similarities, they also have significant differences that set them apart. This article will highlight the key differences between IndexedDB and Redis.
Data Model: IndexedDB is an object-oriented database that stores data in structured objects, which can be accessed using JavaScript's IndexedDB API. On the other hand, Redis is a key-value store where data is stored as a collection of key-value pairs, and values can be of different types like strings, lists, sets, etc.
Persistence: IndexedDB provides persistent storage, meaning the data remains saved even after the browser is closed or the system restarts. Redis also offers persistence, but it provides different levels of persistence options such as snapshots, append-only files, or both.
Scalability: Redis is known for its excellent scalability and performance. It can handle millions of operations per second and is often used in high-traffic applications. IndexedDB, while suitable for storing smaller amounts of data, may not perform as well when dealing with a large number of records or heavy workloads.
Data Manipulation: IndexedDB provides a powerful querying mechanism that allows for complex data manipulation operations, including indexing, filtering, and sorting. Redis, on the other hand, offers limited data manipulation capabilities. It primarily focuses on data retrieval and storage operations.
Replication and Clustering: Redis comes with built-in support for replication and clustering, allowing for high availability and fault tolerance. It can replicate data across multiple nodes and distribute the workload efficiently. IndexedDB, in contrast, does not offer native replication or clustering features.
Data Expiry: Redis provides options for setting an expiration time on keys, allowing data to expire automatically after a certain period. This feature is useful for implementing caching and managing temporary data. IndexedDB does not have built-in support for automatic data expiry.
In summary, IndexedDB and Redis differ in their data models, persistence, scalability, data manipulation capabilities, support for replication and clustering, and data expiry options. These differences make them suitable for different use cases and scenarios in web development.
I'm currently developing an app that ranks trending stuff ( such as games, memes or movies, etc. ) or events in a particular country or region. Here are the specs: My app does not require registration and requires cookies and localStorage to track users. Users can add new entries to each trending category provided that their country of origin is recorded in cookies. If each category contains more than 100 items then the oldest items get deleted. The question is: what kind of database should I use for managing this app? Thanks in advance
I think your best and cheapest choice is going to be MongoDB, Although Postgres is probably going to be the more scaleable approach, you likely have a good idea of how you want to present your data, and the app seems small enough that you shouldn't need to worry about scaling issues. It also sounds like your app can grow in a linear capacity based on the number of users, and the amount of data, which is the perfect use-case for noSQL databases (linear, predictable scaling).
Correct me if I have any of these assumptions wrong. 1. You're looking to have a relatively high-read with a lower write volume 2. Your app is essentially a list of objects that can belong to a category 3. users can create objects in this list.
I think Mongo is going to be what you're looking for on the following basis: 1. you absolutely need a database that is shared by all users of your app, therefor IndexedDB is out of the question. 2. You have semi-structured data 3. you probably want the cheapest solution.
I think Postgres is wrong for the following reasons: 1. your app is pretty simple in concept, SQL databases will add unnecessary complexity to your system, either through ORMs or SQL queries. (use an ORM if you go with SQL) 2. Hosting SQL databases for production is not cheap! the cheapest solution I know of for Postgres is ElephantSQL. It provides 20MB for free with 5 concurrent connections, you should be okay to manage these limitations if you decide to go Postgres in the end. Whereas mongoDB Atlas has some great free-tier options.
Although your data might be easier to model in Postgres, you can certainly model your data as a single list of items that have a category attached.
I don't want to officially recommend another tool, but you should really checkout prisma, firebase, amplify, or Azure App Services for this app! Just go completely backend-less [Firebase] https://firebase.google.com/ [Amplify] https://aws.amazon.com/amplify/ [Prisma] https://www.prisma.io/ [Azure App Services] https://azure.microsoft.com/en-us/services/app-service/?v=18.51
Pros of IndexedDB
Pros of Redis
- Performance886
- Super fast542
- Ease of use513
- In-memory cache444
- Advanced key-value cache324
- Open source194
- Easy to deploy182
- Stable164
- Free155
- Fast121
- High-Performance42
- High Availability40
- Data Structures35
- Very Scalable32
- Replication24
- Great community22
- Pub/Sub22
- "NoSQL" key-value data store19
- Hashes16
- Sets13
- Sorted Sets11
- NoSQL10
- Lists10
- Async replication9
- BSD licensed9
- Bitmaps8
- Integrates super easy with Sidekiq for Rails background8
- Keys with a limited time-to-live7
- Open Source7
- Lua scripting6
- Strings6
- Awesomeness for Free5
- Hyperloglogs5
- Transactions4
- Outstanding performance4
- Runs server side LUA4
- LRU eviction of keys4
- Feature Rich4
- Written in ANSI C4
- Networked4
- Data structure server3
- Performance & ease of use3
- Dont save data if no subscribers are found2
- Automatic failover2
- Easy to use2
- Temporarily kept on disk2
- Scalable2
- Existing Laravel Integration2
- Channels concept2
- Object [key/value] size each 500 MB2
- Simple2
Sign up to add or upvote prosMake informed product decisions
Cons of IndexedDB
Cons of Redis
- Cannot query objects directly15
- No secondary indexes for non-numeric data types3
- No WAL1