Skip to content

Redis Proxy improvements to Support commands PubSub , Streams , Scripts. Info... 50+ commands #38492

Open

Description

@dinesh-murugiah

Title: Redis proxy - More classes and Design patterns to support additional commands

Description:
HI i am Working for https://www.freshworks.com/ . We have self hosted redis cluster in our organisation
we are using Envoy proxy for our clients interaction . The Envoy in its current form lacks support many commands
To make it useful for us we have made changes in envoy to support more than 50+ commands and its been running in production

We would like to contribute those changes to envoy community ,
starting this issue thread to initiate a conversation and understand is anyone else is working on such improvements

Short summary of Proposal

  1. The current redis proxy code follows a chain of responsibility and observer design pattern , such that the commands received in proxy filter is linearly processed in chain and response is sent back
  2. This design pattern will not allow for supporting commands like pubsub, blocking commands , which requires dedicated 1:1 connections between redis and client , rather than going via upstream connection pool
  3. The proposal is to extend or transform the transaction class in to a bridge class , which will have abstractions to support implementations for pubsub , blocking , transaction commands , based on the input command appropriate implementation will be invoked with a dedicated upstream client
  4. When the response is received for such commands , the regular chain of flow will not happen , we can have a mediator object in client impl which will define which flow the response should take , either directly to command filter in case of pubsub commands or regular chain for other commands

we are preparing a detailed document , before that just wanted to understand

  1. is community willing to take such changes
  2. is anyone already working on such changes
  3. what documents are expected from us to take this as a proposal and then implementation

Below are the list of commands for which we have added support in envoy in our local repo

sunion | sdiff | sinter | sinterstore | zunionstore | zinterstore | pfmerge | georadius | georadiusbymember | xrevrange
subscribe | psubscribe | unsubscribe | punsubscribe | publish | pubsub | brpoplpush | bzpopmax | bzpopmin | blpop
brpop | script | flushall | keys | slowlog | config (set & get) | client (getname setname) | info | cluster (slots keyslot) | select
scan | hello* | XCLAIM | rename | xadd | xread | xdel | xtrim | xlen | xrange
getdel | GETEX | SORT | ZMSCORE | SDIFFSTORE | MSETNX | SUBSTR | ZRANGESTORE | ZUNION | ZDIFF
XAUTOCLAIM | XGROUP | XINFO | SUNIONSTORE | SMISMEMBER | HRANDFIELD | GEOSEARCHSTORE | XREADGROUP | ZDIFFSTORE | GEOSEARCH
RANDOMKEY | ZINTER | BLMOVE | ZRANDMEMBER | BITOP | LPOS | RENAMENX |  


[optional Relevant Links:]

Activity

  1. added
    triage
    on Feb 19, 2025
  2. added
    enhancement
    and removed
    triage
    on Feb 20, 2025
  3. adisuissa commented on Feb 20, 2025

    @adisuissa
    Contributor

    Thanks!
    cc'ing redis filter code-owners @msukalski @HenryYYang @mattklein123 @weisisea

  4. MENNAELMESALMY commented on Feb 27, 2025

    @MENNAELMESALMY

    Hey @dinesh-murugiah I am interested in PubSub support, I have a question about PubSub though, if this is added per your proposal, will each client have their own dedicated connection or is there some kind of pooling that will happen?

  5. dinesh-murugiah commented on Feb 27, 2025

    @dinesh-murugiah
    ContributorAuthor

    hi @MENNAELMESALMY for pub sub connections alone it will not be pooled , dedicated upstream clients will be created for each downstream pubsub connection

  6. MENNAELMESALMY commented on Feb 27, 2025

    @MENNAELMESALMY

    Thanks!
    do you know how tricky it is to make it pooled? the main thing we used Envoy for was connection pooling as we have a lot of clients and will possibly run into concurrent clients limitation of Redis (64k) and also the performance degrades with increased client connections.

  7. dinesh-murugiah commented on Feb 27, 2025

    @dinesh-murugiah
    ContributorAuthor

    does your usecase demand many pubsub connections ? In my opinion it brings un necessary complexity to multiplex pubsub connections . In our envoy proxy changes we made sure we distributed the pubsub connections across shards , so that they are evenly distributed . You can horizontally scale the cluster if you need to accomodate more pubsub commands - Just think of it like without a proxy for Pubsub , as this command demands it

  8. MENNAELMESALMY commented on Feb 27, 2025

    @MENNAELMESALMY

    does your usecase demand many pubsub connections ?

    yes we have a lot subscribers into single-topic

    In our envoy proxy changes we made sure we distributed the pubsub connections across shards , so that they are evenly distributed . You can horizontally scale the cluster if you need to accomodate more pubsub commands - Just think of it like without a proxy for Pubsub , as this command demands it

    will the connection be established to a single node in the cluster? so if I were to have 120k subscribers I could have 2 replica nodes in a shard and it should theoretically be fine?

  9. dinesh-murugiah commented on Mar 3, 2025

    @dinesh-murugiah
    ContributorAuthor

    @MENNAELMESALMY

    yes we have a lot subscribers into single-topic
    Hope you are running redis in cluster mode currently , or is it in standalone mode?

    will the connection be established to a single node in the cluster? so if I were to have 120k subscribers I could have 2 replica nodes in a shard and it should theoretically be fine?

    No the connections will be spilt across multiple shards of the cluster , to balance the load.
    In our current implementation we have not classified the subscribe as a read command , but it would be a good idea to do it so that client can subscribe from replicas also

  10. veetar commented on Mar 7, 2025

    @veetar

    @dinesh-murugiah , XGROUP and XREADGROUP should be working as simpleCommands or WriteCommands right ?
    Can you please share your view on the same?

  11. dinesh-murugiah commented on Mar 18, 2025

    @dinesh-murugiah
    ContributorAuthor

    @veetar Yes you are right XGROUP and XREADGROUP are simple commands

  12. zygisa commented on Mar 26, 2025

    @zygisa

    👋 @dinesh-murugiah is the code with the changes mentioned above available publicly? We'd be interested in trying it out if it is.

  13. dinesh-murugiah commented on Apr 4, 2025

    @dinesh-murugiah
    ContributorAuthor

    @zygisa
    https://github.com/freshworks/envoy/tree/v1.28.0-dbaas-RELEASE
    This is our public repo with above features
    NOTE: This has some not so elegant code/Design changes which we plan to repurpose based on community traction, and also it does not have inbuilt test cases (we have external test suites) for features added , which we plan to add sooner
    But the code is quality tested and solid and running in our production

    PS: use the above mentioned branch only

  14. 14 remaining items

  15. dinesh-murugiah commented on Sep 5, 2025

    @dinesh-murugiah
    ContributorAuthor

    hi @bb8gh i plan to take all no key commands as my next upstream chages , i will start with fixing info and scan commands to begin with and then move on to other commands which includes SCRIPT . i expect to submit PR in another 2 weeks worst case which will cover SCRIPT

  16. bb8gh commented on Sep 5, 2025

    @bb8gh
    Contributor

    That's great to hear, I look forward to it. Thanks again!

  17. dinesh-murugiah commented on Oct 7, 2025

    @dinesh-murugiah
    ContributorAuthor

    submitted my second commit for review
    #41381
    in this i have introduced a framework for handling commands that will be sent to all shards of redis and response needs to be handled differently as per the command,subcommand combo
    i have added support for the following commands for now
    script, flushall, flushdb, slowlog, config, cluster info, cluster slots,cluster keyslot,cluster nodes

    i will add more new commands to it as and when we add more frameworks
    the thought process is also to fix and move some of the existing command implementations like info , keys , scan within this framework as it would be better fit in a common framework rather than keep adding some commands individually

    Another point to note is , For now i have used the existing makeFragmentedRequestToShard method to initiate request to redis shard
    but this method has a major pitfall that each call using this method creates new connection with the upstream cluster shards , which will result in performance bottleneck for redis
    in my furture commits i plan to fix that also by using loadbalancer clients for such methods

    cc: @bb8gh @mattklein123

  18. dinesh-murugiah commented on Nov 7, 2025

    @dinesh-murugiah
    ContributorAuthor

    Next i am planning to take next set of changes as below

    1. bring all the existing multishard commands like info , keys , .. in to the new framework thats added - Migrate KEYS, SELECT, and ROLE commands to cluster scope infrastructure #42481
    2. Fix the implementation of Info - INFO Command Optimization and INFO.SHARD Introduction #42153
    3. Add support for hello command to indicate we donot support Resp3 yet- Implement Support for Hello command #42744

    @mattklein123 @yanavlasov

  19. dinesh-murugiah commented on Dec 23, 2025

    @dinesh-murugiah
    ContributorAuthor

    Next i am planning to implement Redis Pub SUB support with Key space notifications
    this may come a litte late as i have other priorities running , will keep you posted
    @MENNAELMESALMY @mattklein123 @nezdolik

  20. Sasidharan3094 commented on Jan 2, 2026

    @Sasidharan3094

    Hi @dinesh-murugiah Please review this - #42823 - This is to add support for Blocking commands.

  21. dinesh-murugiah commented on Jan 2, 2026

    @dinesh-murugiah
    ContributorAuthor

    @Sasidharan3094 can you please raise it to my fork before raising it to public repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/redisenhancementno stalebot

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions