Need advice about which tool to choose?Ask the StackShare community!

Redis

59.7K
44.6K
+ 1
3.9K
Apache Spark

3K
3.5K
+ 1
140
Add tool

Apache Spark vs Redis: What are the differences?

Introduction

Apache Spark and Redis are two popular technologies used in the field of distributed computing. While both are designed to handle large-scale data processing, they have key differences in terms of their architecture, functionality, and use cases.

  1. Architecture: Apache Spark is a distributed computing framework that runs on a cluster of computers, allowing for parallel processing and data storage across multiple nodes. Redis, on the other hand, is an in-memory data structure store that can be used as a database, cache, or message broker. It operates as a single server or a cluster of servers, with data stored primarily in memory for high-speed access.

  2. Data Processing: Apache Spark is primarily designed for big data processing and analytics. It provides a high-level API for distributed data processing, making it easier to write complex data transformations and analytics algorithms. Redis, on the other hand, excels at rapid data access and manipulation. It provides a rich set of data types and operations, allowing for efficient handling of structured and unstructured data in real-time.

  3. Scalability: Apache Spark is highly scalable and can handle large-scale data processing tasks by distributing the workload across multiple nodes in a cluster. It can efficiently process and analyze huge volumes of data in parallel. Redis, on the other hand, is designed for high-speed data access and can handle millions of concurrent operations. It can be scaled horizontally by adding more servers to the cluster to handle increasing data loads.

  4. Persistence: Apache Spark can persist data to disk or external storage systems, allowing for fault tolerance and data recovery in case of failures. It can also cache intermediate results in memory for faster processing. Redis, on the other hand, primarily stores data in memory for high-speed access but can also persist data to disk for durability. It offers different persistence options, including snapshots and append-only files.

  5. Data Manipulation: Apache Spark provides a wide range of data manipulation and analytics capabilities, including SQL queries, data streaming, machine learning, and graph processing. It allows for complex data transformations and analysis within a single framework. Redis, on the other hand, offers a rich set of data manipulation operations for structured and unstructured data, including sorting, set operations, pub/sub messaging, and geospatial support.

  6. Use Cases: Apache Spark is commonly used for big data processing, analytics, and machine learning. It is suitable for batch processing, real-time streaming, and interactive data analysis. Redis, on the other hand, is widely used as a high-performance cache, message broker, and session store. It is commonly used in web applications, real-time analytics, and high-speed data processing.

In summary, Apache Spark is a distributed computing framework for big data processing and analytics, while Redis is an in-memory data structure store for rapid data access and manipulation. They differ in terms of their architecture, data processing capabilities, scalability, persistence options, data manipulation operations, and use cases.

Advice on Redis and Apache Spark
Nilesh Akhade
Technical Architect at Self Employed · | 5 upvotes · 513.9K views

We have a Kafka topic having events of type A and type B. We need to perform an inner join on both type of events using some common field (primary-key). The joined events to be inserted in Elasticsearch.

In usual cases, type A and type B events (with same key) observed to be close upto 15 minutes. But in some cases they may be far from each other, lets say 6 hours. Sometimes event of either of the types never come.

In all cases, we should be able to find joined events instantly after they are joined and not-joined events within 15 minutes.

See more
Replies (2)
Recommends
on
ElasticsearchElasticsearch

The first solution that came to me is to use upsert to update ElasticSearch:

  1. Use the primary-key as ES document id
  2. Upsert the records to ES as soon as you receive them. As you are using upsert, the 2nd record of the same primary-key will not overwrite the 1st one, but will be merged with it.

Cons: The load on ES will be higher, due to upsert.

To use Flink:

  1. Create a KeyedDataStream by the primary-key
  2. In the ProcessFunction, save the first record in a State. At the same time, create a Timer for 15 minutes in the future
  3. When the 2nd record comes, read the 1st record from the State, merge those two, and send out the result, and clear the State and the Timer if it has not fired
  4. When the Timer fires, read the 1st record from the State and send out as the output record.
  5. Have a 2nd Timer of 6 hours (or more) if you are not using Windowing to clean up the State

Pro: if you have already having Flink ingesting this stream. Otherwise, I would just go with the 1st solution.

See more
Akshaya Rawat
Senior Specialist Platform at Publicis Sapient · | 3 upvotes · 359K views
Recommends
on
Apache SparkApache Spark

Please refer "Structured Streaming" feature of Spark. Refer "Stream - Stream Join" at https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#stream-stream-joins . In short you need to specify "Define watermark delays on both inputs" and "Define a constraint on time across the two inputs"

See more
Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of Redis
Pros of Apache Spark
  • 886
    Performance
  • 542
    Super fast
  • 513
    Ease of use
  • 444
    In-memory cache
  • 324
    Advanced key-value cache
  • 194
    Open source
  • 182
    Easy to deploy
  • 164
    Stable
  • 155
    Free
  • 121
    Fast
  • 42
    High-Performance
  • 40
    High Availability
  • 35
    Data Structures
  • 32
    Very Scalable
  • 24
    Replication
  • 22
    Great community
  • 22
    Pub/Sub
  • 19
    "NoSQL" key-value data store
  • 16
    Hashes
  • 13
    Sets
  • 11
    Sorted Sets
  • 10
    NoSQL
  • 10
    Lists
  • 9
    Async replication
  • 9
    BSD licensed
  • 8
    Bitmaps
  • 8
    Integrates super easy with Sidekiq for Rails background
  • 7
    Keys with a limited time-to-live
  • 7
    Open Source
  • 6
    Lua scripting
  • 6
    Strings
  • 5
    Awesomeness for Free
  • 5
    Hyperloglogs
  • 4
    Transactions
  • 4
    Outstanding performance
  • 4
    Runs server side LUA
  • 4
    LRU eviction of keys
  • 4
    Feature Rich
  • 4
    Written in ANSI C
  • 4
    Networked
  • 3
    Data structure server
  • 3
    Performance & ease of use
  • 2
    Dont save data if no subscribers are found
  • 2
    Automatic failover
  • 2
    Easy to use
  • 2
    Temporarily kept on disk
  • 2
    Scalable
  • 2
    Existing Laravel Integration
  • 2
    Channels concept
  • 2
    Object [key/value] size each 500 MB
  • 2
    Simple
  • 61
    Open-source
  • 48
    Fast and Flexible
  • 8
    One platform for every big data problem
  • 8
    Great for distributed SQL like applications
  • 6
    Easy to install and to use
  • 3
    Works well for most Datascience usecases
  • 2
    Interactive Query
  • 2
    Machine learning libratimery, Streaming in real
  • 2
    In memory Computation

Sign up to add or upvote prosMake informed product decisions

Cons of Redis
Cons of Apache Spark
  • 15
    Cannot query objects directly
  • 3
    No secondary indexes for non-numeric data types
  • 1
    No WAL
  • 4
    Speed

Sign up to add or upvote consMake informed product decisions

- No public GitHub repository available -

What is Redis?

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.

What is Apache Spark?

Spark is a fast and general processing engine compatible with Hadoop data. It can run in Hadoop clusters through YARN or Spark's standalone mode, and it can process data in HDFS, HBase, Cassandra, Hive, and any Hadoop InputFormat. It is designed to perform both batch processing (similar to MapReduce) and new workloads like streaming, interactive queries, and machine learning.

Need advice about which tool to choose?Ask the StackShare community!

Jobs that mention Redis and Apache Spark as a desired skillset
LaunchDarkly
Oakland, California, United States
What companies use Redis?
What companies use Apache Spark?
See which teams inside your own company are using Redis or Apache Spark.
Sign up for StackShare EnterpriseLearn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with Redis?
What tools integrate with Apache Spark?

Sign up to get full access to all the tool integrationsMake informed product decisions

Blog Posts

What are some alternatives to Redis and Apache Spark?
Memcached
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
MongoDB
MongoDB stores data in JSON-like documents that can vary in structure, offering a dynamic, flexible schema. MongoDB was also designed for high availability and scalability, with built-in replication and auto-sharding.
RabbitMQ
RabbitMQ gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.
Hazelcast
With its various distributed data structures, distributed caching capabilities, elastic nature, memcache support, integration with Spring and Hibernate and more importantly with so many happy users, Hazelcast is feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.
Cassandra
Partitioning means that Cassandra can distribute your data across multiple machines in an application-transparent matter. Cassandra will automatically repartition as machines are added and removed from the cluster. Row store means that like relational databases, Cassandra organizes data by rows and columns. The Cassandra Query Language (CQL) is a close relative of SQL.
See all alternatives