Redis: A tool to combat the onslaught of spam calls and texts.
Suyog Kale
Solution Architect Manager at Redis India | Technology Evangelist | Author | Speaker | Interest - NoSQL, Cloud, bigdata
Did you know that spam calls and SMS in India have reached alarming levels? Multiple sources confirm the scale of the issue.
According to a 2024 survey, 95% of Indians receive unwanted calls daily, with 77% receiving at least three or more such calls every day.?
(source: Business Today)
Here are some shocking statistics:
The above numbers might vary from research to research, but let’s accept the fact that the problem is growing.? The rise of spam has spawned a profitable market for apps like Truecaller and Robokiller that filter out unwanted calls. Both tech companies and governments are actively working to address this consumer issue,
but regulatory measures like the Do Not Disturb (DND) list have proven largely ineffective, as 96% of users registered on the list still receive these calls.
Let's have a look on few examples of of SPAMs incidents:
The SPAMs-blocking Tech companies are building the following solutions:
Redis Enterprise can help build scalable and efficient systems to block such spam using features like in-memory data structures, Redis Vector search, Redis Streams, pub/sub messaging, and high-performance rate limiting. Here’s a technical approach:
1. Real-time Spam Detection and Blocking (rule based)
By leveraging Redis’ low-latency performance and scalable data structures (hashes, sets, sorted sets), spam detection can happen in real-time, ensuring prompt response to known spam patterns. Here’s how Redis Enterprise can fit into the spam-blocking architecture:
SADD spam_numbers <number>
SISMEMBER spam_numbers <incoming_number>
BF.ADD spam_filter <number>
BF.EXISTS spam_filter <incoming_number>
领英推荐
2. Rate Limiting
Redis Enterprise’s in-memory performance and support for atomic operations are ideal for rate-limiting incoming requests or spam attempts. Redis Lua scripts or Redis' native commands can be used to enforce rate limiting based on time intervals, preventing users or bots from overwhelming the system with spam attempts.
For instance, each number could have a rate limit on the number of messages sent per minute, using Redis INCR and EXPIRE commands:
INCRBY number_sms_sent:<number> 1
EXPIRE number_sms_sent:<number> 60
If the value exceeds a threshold, actions can be taken to block further messages from the sender. (Here is the detailed webinar for how to implement Rate limiting in Redis https://www.youtube.com/watch?v=YcmU24x4KyA&t=1603s)
3. Storing Spam Patterns as Vectors
Redis can store spam patterns, behaviors, and metadata related to calls or SMS as vector embeddings. By transforming message content or call data (such as phone numbers, call frequency, and content characteristics) into numerical vector representations, these vectors can be indexed and queried in real-time using Redis' vector database capabilities.
Using Redis Vector Similarity Search (Redis VSS), you can store and search high-dimensional vectors. For instance, embedding spam messages or phone numbers into a vector space using machine learning models allows Redis to perform approximate nearest neighbor (ANN) searches efficiently. This enables real-time matching of incoming calls or SMS to known spam vectors.
# Example of creating an index for spam call vectors
FT.CREATE spam_idx ON HASH PREFIX 1 spam_vectors: SCHEMA embedding VECTOR FLAT 6
4. Real-time Similarity Searches
When an incoming call or SMS is received, its data (e.g., content, frequency, or originating number) can be vectorized and compared against existing vectors in Redis. This allows the system to identify similar spam patterns based on proximity in vector space, making it effective even against evolving spam strategies that may not exactly match known patterns.
Redis' vector database can handle millions of vectors, and with its in-memory structure, spam detection can occur with minimal latency. Redis can perform K-Nearest Neighbors (KNN) searches to identify whether an incoming communication is close to known spam profiles.
FT.SEARCH spam_idx '@embedding:[VECTOR_DISTANCE ... ]'
5. Integration with Machine Learning Models
Redis Enterprise can integrate with machine learning models trained to detect spam. For example, you can use a machine learning pipeline to classify incoming calls and messages, vectorize the outputs, and store them in Redis for future comparisons. By feeding Redis with these vector embeddings from models such as BERT or TF-IDF, spam detection becomes more adaptive to changing patterns.
Redis can act as a high-performance real-time serving layer, where vectors from a machine learning model are searched for matching patterns before calls or messages are allowed through.
6. Scalable Architecture for High Volumes
Redis Enterprise supports horizontal scaling and Active-Active architecture, making it ideal for large-scale, distributed systems handling millions of calls and messages. The Active-Active architecture ensures that even if the spam detection infrastructure is deployed across multiple data centers, it will still operate seamlessly, handling high volumes of incoming communications with low latency.
Conclusion
By using Redis' vector search capabilities, high-dimensional data management, and integration with machine learning models, service providers can build scalable, real-time systems for blocking spam calls and SMS. Redis Enterprise provides the speed, scalability, and robustness needed for such a system to perform efficiently at scale.
For further exploration, you can look into Redis' vector database support and real-time search features in more detail through Redis documentation.
Note: Opinions expressed are solely my own and do not express the views or opinions of my employer.
Principal Architect at Icertis
5 个月Unless we find a way to do this on device, don’t have a lot of hopes form telcos or trai getting this out anytime soon. But do share you views on making this a use case for ondevice AI, Suyog Kale